Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2014 Qualcomm Atheros, Inc. |
| 3 | * All Rights Reserved. |
| 4 | * Qualcomm Atheros Confidential and Proprietary. |
| 5 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6 | /**======================================================================== |
| 7 | |
| 8 | \file wlan_hdd_cfg80211.c |
| 9 | |
| 10 | \brief WLAN Host Device Driver implementation |
| 11 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 12 | Copyright 2008 (c) Qualcomm Technologies, Inc. All Rights Reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 13 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 14 | Qualcomm Technologies Confidential and Proprietary. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 15 | |
| 16 | ========================================================================*/ |
| 17 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 18 | /**========================================================================= |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 19 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 20 | EDIT HISTORY FOR FILE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 21 | |
| 22 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 23 | This section contains comments describing changes made to the module. |
| 24 | Notice that changes are listed in reverse chronological order. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 25 | |
| 26 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 27 | $Header:$ $DateTime: $ $Author: $ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 28 | |
| 29 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 30 | when who what, where, why |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 31 | -------- --- -------------------------------------------------------- |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 32 | 21/12/09 Ashwani Created module. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 33 | |
| 34 | 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 35 | Ganesh K |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 36 | ==========================================================================*/ |
| 37 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 38 | |
| 39 | #include <linux/version.h> |
| 40 | #include <linux/module.h> |
| 41 | #include <linux/kernel.h> |
| 42 | #include <linux/init.h> |
| 43 | #include <linux/wireless.h> |
| 44 | #include <wlan_hdd_includes.h> |
| 45 | #include <net/arp.h> |
| 46 | #include <net/cfg80211.h> |
| 47 | #include <linux/wireless.h> |
| 48 | #include <wlan_hdd_wowl.h> |
| 49 | #include <aniGlobal.h> |
| 50 | #include "ccmApi.h" |
| 51 | #include "sirParams.h" |
| 52 | #include "dot11f.h" |
| 53 | #include "wlan_hdd_assoc.h" |
| 54 | #include "wlan_hdd_wext.h" |
| 55 | #include "sme_Api.h" |
| 56 | #include "wlan_hdd_p2p.h" |
| 57 | #include "wlan_hdd_cfg80211.h" |
| 58 | #include "wlan_hdd_hostapd.h" |
| 59 | #include "sapInternal.h" |
| 60 | #include "wlan_hdd_softap_tx_rx.h" |
| 61 | #include "wlan_hdd_main.h" |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 62 | #include "wlan_hdd_assoc.h" |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 63 | #include "wlan_hdd_power.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 64 | #ifdef WLAN_BTAMP_FEATURE |
| 65 | #include "bap_hdd_misc.h" |
| 66 | #endif |
| 67 | #include <qc_sap_ioctl.h> |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 68 | #ifdef FEATURE_WLAN_TDLS |
| 69 | #include "wlan_hdd_tdls.h" |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 70 | #include "wlan_hdd_wmm.h" |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 71 | #include "wlan_qct_wda.h" |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 72 | #endif |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 73 | #include "wlan_nv.h" |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 74 | #include "wlan_hdd_dev_pwr.h" |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 75 | |
| 76 | #define g_mode_rates_size (12) |
| 77 | #define a_mode_rates_size (8) |
| 78 | #define FREQ_BASE_80211G (2407) |
| 79 | #define FREQ_BAND_DIFF_80211G (5) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 80 | #define MAX_SCAN_SSID 9 |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 81 | #define MAX_PENDING_LOG 5 |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 82 | #define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \ |
| 83 | ((int) OFFSET_OF( tSirBssDescription, ieFields))) |
| 84 | |
| 85 | #define HDD2GHZCHAN(freq, chan, flag) { \ |
| 86 | .band = IEEE80211_BAND_2GHZ, \ |
| 87 | .center_freq = (freq), \ |
| 88 | .hw_value = (chan),\ |
| 89 | .flags = (flag), \ |
| 90 | .max_antenna_gain = 0 ,\ |
| 91 | .max_power = 30, \ |
| 92 | } |
| 93 | |
| 94 | #define HDD5GHZCHAN(freq, chan, flag) { \ |
| 95 | .band = IEEE80211_BAND_5GHZ, \ |
| 96 | .center_freq = (freq), \ |
| 97 | .hw_value = (chan),\ |
| 98 | .flags = (flag), \ |
| 99 | .max_antenna_gain = 0 ,\ |
| 100 | .max_power = 30, \ |
| 101 | } |
| 102 | |
| 103 | #define HDD_G_MODE_RATETAB(rate, rate_id, flag)\ |
| 104 | {\ |
| 105 | .bitrate = rate, \ |
| 106 | .hw_value = rate_id, \ |
| 107 | .flags = flag, \ |
| 108 | } |
| 109 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 110 | #ifndef WLAN_FEATURE_TDLS_DEBUG |
| 111 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO |
| 112 | #else |
| 113 | #define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR |
| 114 | #endif |
| 115 | |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 116 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 117 | #define WLAN_AKM_SUITE_FT_8021X 0x000FAC03 |
| 118 | #define WLAN_AKM_SUITE_FT_PSK 0x000FAC04 |
| 119 | #endif |
| 120 | |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 121 | #define HDD_CHANNEL_14 14 |
| 122 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 123 | static const u32 hdd_cipher_suites[] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 124 | { |
| 125 | WLAN_CIPHER_SUITE_WEP40, |
| 126 | WLAN_CIPHER_SUITE_WEP104, |
| 127 | WLAN_CIPHER_SUITE_TKIP, |
| 128 | #ifdef FEATURE_WLAN_CCX |
| 129 | #define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */ |
| 130 | WLAN_CIPHER_SUITE_KRK, |
| 131 | WLAN_CIPHER_SUITE_CCMP, |
| 132 | #else |
| 133 | WLAN_CIPHER_SUITE_CCMP, |
| 134 | #endif |
| 135 | #ifdef FEATURE_WLAN_WAPI |
| 136 | WLAN_CIPHER_SUITE_SMS4, |
| 137 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 138 | #ifdef WLAN_FEATURE_11W |
| 139 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 140 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 141 | }; |
| 142 | |
| 143 | static inline int is_broadcast_ether_addr(const u8 *addr) |
| 144 | { |
| 145 | return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && |
| 146 | (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); |
| 147 | } |
| 148 | |
| 149 | static struct ieee80211_channel hdd_channels_2_4_GHZ[] = |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 150 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 151 | HDD2GHZCHAN(2412, 1, 0) , |
| 152 | HDD2GHZCHAN(2417, 2, 0) , |
| 153 | HDD2GHZCHAN(2422, 3, 0) , |
| 154 | HDD2GHZCHAN(2427, 4, 0) , |
| 155 | HDD2GHZCHAN(2432, 5, 0) , |
| 156 | HDD2GHZCHAN(2437, 6, 0) , |
| 157 | HDD2GHZCHAN(2442, 7, 0) , |
| 158 | HDD2GHZCHAN(2447, 8, 0) , |
| 159 | HDD2GHZCHAN(2452, 9, 0) , |
| 160 | HDD2GHZCHAN(2457, 10, 0) , |
| 161 | HDD2GHZCHAN(2462, 11, 0) , |
| 162 | HDD2GHZCHAN(2467, 12, 0) , |
| 163 | HDD2GHZCHAN(2472, 13, 0) , |
| 164 | HDD2GHZCHAN(2484, 14, 0) , |
| 165 | }; |
| 166 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 167 | static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] = |
| 168 | { |
| 169 | HDD2GHZCHAN(2412, 1, 0) , |
| 170 | HDD2GHZCHAN(2437, 6, 0) , |
| 171 | HDD2GHZCHAN(2462, 11, 0) , |
| 172 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 173 | |
| 174 | static struct ieee80211_channel hdd_channels_5_GHZ[] = |
| 175 | { |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 176 | HDD5GHZCHAN(4920, 240, 0) , |
| 177 | HDD5GHZCHAN(4940, 244, 0) , |
| 178 | HDD5GHZCHAN(4960, 248, 0) , |
| 179 | HDD5GHZCHAN(4980, 252, 0) , |
| 180 | HDD5GHZCHAN(5040, 208, 0) , |
| 181 | HDD5GHZCHAN(5060, 212, 0) , |
| 182 | HDD5GHZCHAN(5080, 216, 0) , |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 183 | HDD5GHZCHAN(5180, 36, 0) , |
| 184 | HDD5GHZCHAN(5200, 40, 0) , |
| 185 | HDD5GHZCHAN(5220, 44, 0) , |
| 186 | HDD5GHZCHAN(5240, 48, 0) , |
| 187 | HDD5GHZCHAN(5260, 52, 0) , |
| 188 | HDD5GHZCHAN(5280, 56, 0) , |
| 189 | HDD5GHZCHAN(5300, 60, 0) , |
| 190 | HDD5GHZCHAN(5320, 64, 0) , |
| 191 | HDD5GHZCHAN(5500,100, 0) , |
| 192 | HDD5GHZCHAN(5520,104, 0) , |
| 193 | HDD5GHZCHAN(5540,108, 0) , |
| 194 | HDD5GHZCHAN(5560,112, 0) , |
| 195 | HDD5GHZCHAN(5580,116, 0) , |
| 196 | HDD5GHZCHAN(5600,120, 0) , |
| 197 | HDD5GHZCHAN(5620,124, 0) , |
| 198 | HDD5GHZCHAN(5640,128, 0) , |
| 199 | HDD5GHZCHAN(5660,132, 0) , |
| 200 | HDD5GHZCHAN(5680,136, 0) , |
| 201 | HDD5GHZCHAN(5700,140, 0) , |
Leo Chang | 80de3c2 | 2013-11-26 10:52:12 -0800 | [diff] [blame] | 202 | #ifdef FEATURE_WLAN_CH144 |
| 203 | HDD5GHZCHAN(5720,144, 0) , |
| 204 | #endif /* FEATURE_WLAN_CH144 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 205 | HDD5GHZCHAN(5745,149, 0) , |
| 206 | HDD5GHZCHAN(5765,153, 0) , |
| 207 | HDD5GHZCHAN(5785,157, 0) , |
| 208 | HDD5GHZCHAN(5805,161, 0) , |
| 209 | HDD5GHZCHAN(5825,165, 0) , |
| 210 | }; |
| 211 | |
| 212 | static struct ieee80211_rate g_mode_rates[] = |
| 213 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 214 | HDD_G_MODE_RATETAB(10, 0x1, 0), |
| 215 | HDD_G_MODE_RATETAB(20, 0x2, 0), |
| 216 | HDD_G_MODE_RATETAB(55, 0x4, 0), |
| 217 | HDD_G_MODE_RATETAB(110, 0x8, 0), |
| 218 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 219 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 220 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 221 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 222 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 223 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 224 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 225 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 226 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 227 | |
| 228 | static struct ieee80211_rate a_mode_rates[] = |
| 229 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 230 | HDD_G_MODE_RATETAB(60, 0x10, 0), |
| 231 | HDD_G_MODE_RATETAB(90, 0x20, 0), |
| 232 | HDD_G_MODE_RATETAB(120, 0x40, 0), |
| 233 | HDD_G_MODE_RATETAB(180, 0x80, 0), |
| 234 | HDD_G_MODE_RATETAB(240, 0x100, 0), |
| 235 | HDD_G_MODE_RATETAB(360, 0x200, 0), |
| 236 | HDD_G_MODE_RATETAB(480, 0x400, 0), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 237 | HDD_G_MODE_RATETAB(540, 0x800, 0), |
| 238 | }; |
| 239 | |
| 240 | static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ = |
| 241 | { |
| 242 | .channels = hdd_channels_2_4_GHZ, |
| 243 | .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ), |
| 244 | .band = IEEE80211_BAND_2GHZ, |
| 245 | .bitrates = g_mode_rates, |
| 246 | .n_bitrates = g_mode_rates_size, |
| 247 | .ht_cap.ht_supported = 1, |
| 248 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 249 | | IEEE80211_HT_CAP_GRN_FLD |
| 250 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 251 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 252 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 253 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 254 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 255 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 256 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 257 | }; |
| 258 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 259 | static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ = |
| 260 | { |
| 261 | .channels = hdd_social_channels_2_4_GHZ, |
| 262 | .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ), |
| 263 | .band = IEEE80211_BAND_2GHZ, |
| 264 | .bitrates = g_mode_rates, |
| 265 | .n_bitrates = g_mode_rates_size, |
| 266 | .ht_cap.ht_supported = 1, |
| 267 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 268 | | IEEE80211_HT_CAP_GRN_FLD |
| 269 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 270 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT, |
| 271 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 272 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 273 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 274 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 275 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 276 | }; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 277 | |
| 278 | static struct ieee80211_supported_band wlan_hdd_band_5_GHZ = |
| 279 | { |
| 280 | .channels = hdd_channels_5_GHZ, |
| 281 | .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ), |
| 282 | .band = IEEE80211_BAND_5GHZ, |
| 283 | .bitrates = a_mode_rates, |
| 284 | .n_bitrates = a_mode_rates_size, |
| 285 | .ht_cap.ht_supported = 1, |
| 286 | .ht_cap.cap = IEEE80211_HT_CAP_SGI_20 |
| 287 | | IEEE80211_HT_CAP_GRN_FLD |
| 288 | | IEEE80211_HT_CAP_DSSSCCK40 |
| 289 | | IEEE80211_HT_CAP_LSIG_TXOP_PROT |
| 290 | | IEEE80211_HT_CAP_SGI_40 |
| 291 | | IEEE80211_HT_CAP_SUP_WIDTH_20_40, |
| 292 | .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, |
| 293 | .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16, |
| 294 | .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, |
| 295 | .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ), |
| 296 | .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED, |
| 297 | }; |
| 298 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 299 | /* This structure contain information what kind of frame are expected in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 300 | TX/RX direction for each kind of interface */ |
| 301 | static const struct ieee80211_txrx_stypes |
| 302 | wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = { |
| 303 | [NL80211_IFTYPE_STATION] = { |
| 304 | .tx = 0xffff, |
| 305 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 306 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 307 | }, |
| 308 | [NL80211_IFTYPE_AP] = { |
| 309 | .tx = 0xffff, |
| 310 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 311 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 312 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 313 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 314 | BIT(SIR_MAC_MGMT_AUTH) | |
| 315 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 316 | BIT(SIR_MAC_MGMT_ACTION), |
| 317 | }, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 318 | [NL80211_IFTYPE_ADHOC] = { |
| 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 | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 328 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 329 | .tx = 0xffff, |
| 330 | .rx = BIT(SIR_MAC_MGMT_ACTION) | |
| 331 | BIT(SIR_MAC_MGMT_PROBE_REQ), |
| 332 | }, |
| 333 | [NL80211_IFTYPE_P2P_GO] = { |
| 334 | /* This is also same as for SoftAP */ |
| 335 | .tx = 0xffff, |
| 336 | .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) | |
| 337 | BIT(SIR_MAC_MGMT_REASSOC_REQ) | |
| 338 | BIT(SIR_MAC_MGMT_PROBE_REQ) | |
| 339 | BIT(SIR_MAC_MGMT_DISASSOC) | |
| 340 | BIT(SIR_MAC_MGMT_AUTH) | |
| 341 | BIT(SIR_MAC_MGMT_DEAUTH) | |
| 342 | BIT(SIR_MAC_MGMT_ACTION), |
| 343 | }, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 344 | }; |
| 345 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 346 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 347 | static const struct ieee80211_iface_limit |
| 348 | wlan_hdd_iface_limit[] = { |
| 349 | { |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 350 | /* max = 3 ; Our driver create two interfaces during driver init |
| 351 | * wlan0 and p2p0 interfaces. p2p0 is considered as station |
| 352 | * interface until a group is formed. In JB architecture, once the |
| 353 | * group is formed, interface type of p2p0 is changed to P2P GO or |
| 354 | * Client. |
| 355 | * When supplicant remove the group, it first issue a set interface |
| 356 | * cmd to change the mode back to Station. In JB this works fine as |
| 357 | * we advertize two station type interface during driver init. |
| 358 | * Some vendors create separate interface for P2P GO/Client, |
| 359 | * after group formation(Third one). But while group remove |
| 360 | * supplicant first tries to change the mode(3rd interface) to STATION |
| 361 | * But as we advertized only two sta type interfaces nl80211 was |
| 362 | * returning error for the third one which was leading to failure in |
| 363 | * delete interface. Ideally while removing the group, supplicant |
| 364 | * should not try to change the 3rd interface mode to Station type. |
| 365 | * Till we get a fix in wpa_supplicant, we advertize max STA |
| 366 | * interface type to 3 |
| 367 | */ |
| 368 | .max = 3, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 369 | .types = BIT(NL80211_IFTYPE_STATION), |
| 370 | }, |
| 371 | { |
| 372 | .max = 1, |
Jeff Johnson | bc00620 | 2013-04-29 14:05:30 -0700 | [diff] [blame] | 373 | .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP), |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 374 | }, |
| 375 | { |
| 376 | .max = 1, |
| 377 | .types = BIT(NL80211_IFTYPE_P2P_GO) | |
| 378 | BIT(NL80211_IFTYPE_P2P_CLIENT), |
| 379 | }, |
| 380 | }; |
| 381 | |
| 382 | /* By default, only single channel concurrency is allowed */ |
| 383 | static struct ieee80211_iface_combination |
| 384 | wlan_hdd_iface_combination = { |
| 385 | .limits = wlan_hdd_iface_limit, |
| 386 | .num_different_channels = 1, |
Sunil Ravi | a72c399 | 2013-01-31 06:12:22 -0800 | [diff] [blame] | 387 | /* |
| 388 | * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0 |
| 389 | * and p2p0 interfaces during driver init |
| 390 | * Some vendors create separate interface for P2P operations. |
| 391 | * wlan0: STA interface |
| 392 | * p2p0: P2P Device interface, action frames goes |
| 393 | * through this interface. |
| 394 | * p2p-xx: P2P interface, After GO negotiation this interface is |
| 395 | * created for p2p operations(GO/CLIENT interface). |
| 396 | */ |
| 397 | .max_interfaces = WLAN_MAX_INTERFACES, |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 398 | .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit), |
| 399 | .beacon_int_infra_match = false, |
| 400 | }; |
| 401 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 402 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 403 | static struct cfg80211_ops wlan_hdd_cfg80211_ops; |
| 404 | |
| 405 | /* Data rate 100KBPS based on IE Index */ |
| 406 | struct index_data_rate_type |
| 407 | { |
| 408 | v_U8_t beacon_rate_index; |
| 409 | v_U16_t supported_rate[4]; |
| 410 | }; |
| 411 | |
| 412 | /* 11B, 11G Rate table include Basic rate and Extended rate |
| 413 | The IDX field is the rate index |
| 414 | The HI field is the rate when RSSI is strong or being ignored |
| 415 | (in this case we report actual rate) |
| 416 | The MID field is the rate when RSSI is moderate |
| 417 | (in this case we cap 11b rates at 5.5 and 11g rates at 24) |
| 418 | The LO field is the rate when RSSI is low |
| 419 | (in this case we don't report rates, actual current rate used) |
| 420 | */ |
| 421 | static const struct |
| 422 | { |
| 423 | v_U8_t beacon_rate_index; |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 424 | v_U16_t supported_rate[4]; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 425 | } supported_data_rate[] = |
| 426 | { |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 427 | /* IDX HI HM LM LO (RSSI-based index */ |
| 428 | {2, { 10, 10, 10, 0}}, |
| 429 | {4, { 20, 20, 10, 0}}, |
| 430 | {11, { 55, 20, 10, 0}}, |
| 431 | {12, { 60, 55, 20, 0}}, |
| 432 | {18, { 90, 55, 20, 0}}, |
| 433 | {22, {110, 55, 20, 0}}, |
| 434 | {24, {120, 90, 60, 0}}, |
| 435 | {36, {180, 120, 60, 0}}, |
| 436 | {44, {220, 180, 60, 0}}, |
| 437 | {48, {240, 180, 90, 0}}, |
| 438 | {66, {330, 180, 90, 0}}, |
| 439 | {72, {360, 240, 90, 0}}, |
| 440 | {96, {480, 240, 120, 0}}, |
| 441 | {108, {540, 240, 120, 0}} |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 442 | }; |
| 443 | |
| 444 | /* MCS Based rate table */ |
| 445 | static struct index_data_rate_type supported_mcs_rate[] = |
| 446 | { |
| 447 | /* MCS L20 L40 S20 S40 */ |
| 448 | {0, {65, 135, 72, 150}}, |
| 449 | {1, {130, 270, 144, 300}}, |
| 450 | {2, {195, 405, 217, 450}}, |
| 451 | {3, {260, 540, 289, 600}}, |
| 452 | {4, {390, 810, 433, 900}}, |
| 453 | {5, {520, 1080, 578, 1200}}, |
| 454 | {6, {585, 1215, 650, 1350}}, |
| 455 | {7, {650, 1350, 722, 1500}} |
| 456 | }; |
| 457 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 458 | #ifdef WLAN_FEATURE_11AC |
| 459 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 460 | #define DATA_RATE_11AC_MCS_MASK 0x03 |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 461 | |
| 462 | struct index_vht_data_rate_type |
| 463 | { |
| 464 | v_U8_t beacon_rate_index; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 465 | v_U16_t supported_VHT80_rate[2]; |
| 466 | v_U16_t supported_VHT40_rate[2]; |
| 467 | v_U16_t supported_VHT20_rate[2]; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 468 | }; |
| 469 | |
| 470 | typedef enum |
| 471 | { |
| 472 | DATA_RATE_11AC_MAX_MCS_7, |
| 473 | DATA_RATE_11AC_MAX_MCS_8, |
| 474 | DATA_RATE_11AC_MAX_MCS_9, |
| 475 | DATA_RATE_11AC_MAX_MCS_NA |
| 476 | } eDataRate11ACMaxMcs; |
| 477 | |
| 478 | /* MCS Based VHT rate table */ |
| 479 | static struct index_vht_data_rate_type supported_vht_mcs_rate[] = |
| 480 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 481 | /* MCS L80 S80 L40 S40 L20 S40*/ |
| 482 | {0, {293, 325}, {135, 150}, {65, 72}}, |
| 483 | {1, {585, 650}, {270, 300}, {130, 144}}, |
| 484 | {2, {878, 975}, {405, 450}, {195, 217}}, |
| 485 | {3, {1170, 1300}, {540, 600}, {260, 289}}, |
| 486 | {4, {1755, 1950}, {810, 900}, {390, 433}}, |
| 487 | {5, {2340, 2600}, {1080, 1200}, {520, 578}}, |
| 488 | {6, {2633, 2925}, {1215, 1350}, {585, 650}}, |
| 489 | {7, {2925, 3250}, {1350, 1500}, {650, 722}}, |
| 490 | {8, {3510, 3900}, {1620, 1800}, {780, 867}}, |
| 491 | {9, {3900, 4333}, {1800, 2000}, {780, 867}} |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 492 | }; |
| 493 | #endif /* WLAN_FEATURE_11AC */ |
| 494 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 495 | extern struct net_device_ops net_ops_struct; |
| 496 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 497 | #ifdef WLAN_NL80211_TESTMODE |
| 498 | enum wlan_hdd_tm_attr |
| 499 | { |
| 500 | WLAN_HDD_TM_ATTR_INVALID = 0, |
| 501 | WLAN_HDD_TM_ATTR_CMD = 1, |
| 502 | WLAN_HDD_TM_ATTR_DATA = 2, |
| 503 | WLAN_HDD_TM_ATTR_TYPE = 3, |
| 504 | /* keep last */ |
| 505 | WLAN_HDD_TM_ATTR_AFTER_LAST, |
| 506 | WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1, |
| 507 | }; |
| 508 | |
| 509 | enum wlan_hdd_tm_cmd |
| 510 | { |
| 511 | WLAN_HDD_TM_CMD_WLAN_HB = 1, |
| 512 | }; |
| 513 | |
| 514 | #define WLAN_HDD_TM_DATA_MAX_LEN 5000 |
| 515 | |
| 516 | static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] = |
| 517 | { |
| 518 | [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 }, |
| 519 | [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY, |
| 520 | .len = WLAN_HDD_TM_DATA_MAX_LEN }, |
| 521 | }; |
| 522 | #endif /* WLAN_NL80211_TESTMODE */ |
| 523 | |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 524 | #ifdef FEATURE_WLAN_CH_AVOID |
| 525 | /* |
| 526 | * FUNCTION: wlan_hdd_send_avoid_freq_event |
| 527 | * This is called when wlan driver needs to send vendor specific |
| 528 | * avoid frequency range event to userspace |
| 529 | */ |
| 530 | int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx, |
| 531 | tHddAvoidFreqList *pAvoidFreqList) |
| 532 | { |
| 533 | struct sk_buff *vendor_event; |
| 534 | |
| 535 | ENTER(); |
| 536 | |
| 537 | if (!pHddCtx) |
| 538 | { |
| 539 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 540 | "%s: HDD context is null", __func__); |
| 541 | return -1; |
| 542 | } |
| 543 | |
| 544 | if (!pAvoidFreqList) |
| 545 | { |
| 546 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 547 | "%s: pAvoidFreqList is null", __func__); |
| 548 | return -1; |
| 549 | } |
| 550 | |
| 551 | vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy, |
| 552 | sizeof(tHddAvoidFreqList), |
| 553 | QCOM_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX, |
| 554 | GFP_KERNEL); |
| 555 | if (!vendor_event) |
| 556 | { |
| 557 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 558 | "%s: cfg80211_vendor_event_alloc failed", __func__); |
| 559 | return -1; |
| 560 | } |
| 561 | |
| 562 | memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)), |
| 563 | (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList)); |
| 564 | |
| 565 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 566 | |
| 567 | EXIT(); |
| 568 | return 0; |
| 569 | } |
| 570 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 571 | |
| 572 | /* vendor specific events */ |
| 573 | static const struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] = |
| 574 | { |
| 575 | #ifdef FEATURE_WLAN_CH_AVOID |
| 576 | { |
| 577 | .vendor_id = QCOM_NL80211_VENDOR_ID, |
| 578 | .subcmd = QCOM_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY |
| 579 | }, |
| 580 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 581 | }; |
| 582 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 583 | /* |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 584 | * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 585 | * This function is called by hdd_wlan_startup() |
| 586 | * during initialization. |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 587 | * This function is used to allocate wiphy structure. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 588 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 589 | struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 590 | { |
| 591 | struct wiphy *wiphy; |
| 592 | ENTER(); |
| 593 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 594 | /* |
| 595 | * Create wiphy device |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 596 | */ |
| 597 | wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size); |
| 598 | |
| 599 | if (!wiphy) |
| 600 | { |
| 601 | /* Print error and jump into err label and free the memory */ |
| 602 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__); |
| 603 | return NULL; |
| 604 | } |
| 605 | |
| 606 | return wiphy; |
| 607 | } |
| 608 | |
| 609 | /* |
| 610 | * FUNCTION: wlan_hdd_cfg80211_update_band |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 611 | * This function is called from the supplicant through a |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 612 | * private ioctl to change the band value |
| 613 | */ |
| 614 | int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand) |
| 615 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 616 | int i, j; |
| 617 | eNVChannelEnabledType channelEnabledState; |
| 618 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 619 | ENTER(); |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 620 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 621 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 622 | |
| 623 | if (NULL == wiphy->bands[i]) |
| 624 | { |
| 625 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 626 | __func__, i); |
| 627 | continue; |
| 628 | } |
| 629 | |
| 630 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 631 | { |
| 632 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 633 | |
| 634 | channelEnabledState = vos_nv_getChannelEnabledState( |
| 635 | band->channels[j].hw_value); |
| 636 | |
| 637 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only |
| 638 | { |
| 639 | // Enable Social channels for P2P |
| 640 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) && |
| 641 | NV_CHANNEL_ENABLE == channelEnabledState) |
| 642 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 643 | else |
| 644 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 645 | continue; |
| 646 | } |
| 647 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only |
| 648 | { |
| 649 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 650 | continue; |
| 651 | } |
| 652 | |
| 653 | if (NV_CHANNEL_DISABLE == channelEnabledState || |
| 654 | NV_CHANNEL_INVALID == channelEnabledState) |
| 655 | { |
| 656 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 657 | } |
| 658 | else if (NV_CHANNEL_DFS == channelEnabledState) |
| 659 | { |
| 660 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 661 | band->channels[j].flags |= IEEE80211_CHAN_RADAR; |
| 662 | } |
| 663 | else |
| 664 | { |
| 665 | band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED |
| 666 | |IEEE80211_CHAN_RADAR); |
| 667 | } |
| 668 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 669 | } |
| 670 | return 0; |
| 671 | } |
| 672 | /* |
| 673 | * FUNCTION: wlan_hdd_cfg80211_init |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 674 | * This function is called by hdd_wlan_startup() |
| 675 | * during initialization. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 676 | * This function is used to initialize and register wiphy structure. |
| 677 | */ |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 678 | int wlan_hdd_cfg80211_init(struct device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 679 | struct wiphy *wiphy, |
| 680 | hdd_config_t *pCfg |
| 681 | ) |
| 682 | { |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 683 | int i, j; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 684 | ENTER(); |
| 685 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 686 | /* Now bind the underlying wlan device with wiphy */ |
| 687 | set_wiphy_dev(wiphy, dev); |
| 688 | |
| 689 | wiphy->mgmt_stypes = wlan_hdd_txrx_stypes; |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 690 | |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 691 | #ifndef CONFIG_ENABLE_LINUX_REG |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 692 | /* the flag for the other case would be initialzed in |
| 693 | vos_init_wiphy_from_nv_bin */ |
Amar Singhal | 0a40223 | 2013-10-11 20:57:16 -0700 | [diff] [blame] | 694 | wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 695 | #endif |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 696 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 697 | /* This will disable updating of NL channels from passive to |
| 698 | * active if a beacon is received on passive channel. */ |
| 699 | wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS; |
Amar Singhal | f007319 | 2013-09-20 12:34:56 -0700 | [diff] [blame] | 700 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 701 | |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 702 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 703 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 704 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME |
| 705 | | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
| 706 | | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 707 | | WIPHY_FLAG_OFFCHAN_TX; |
Kiet Lam | 6c58333 | 2013-10-14 05:37:09 +0530 | [diff] [blame] | 708 | wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 709 | #endif |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 710 | |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 711 | #if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) |
| 712 | if (pCfg->isFastTransitionEnabled |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 713 | #ifdef FEATURE_WLAN_LFR |
Srinivas Girigowda | 640728a | 2013-03-28 12:21:54 -0700 | [diff] [blame] | 714 | || pCfg->isFastRoamIniFeatureEnabled |
| 715 | #endif |
| 716 | #ifdef FEATURE_WLAN_CCX |
| 717 | || pCfg->isCcxIniFeatureEnabled |
| 718 | #endif |
| 719 | ) |
| 720 | { |
| 721 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; |
| 722 | } |
James Zmuda | 77fb5ae | 2013-01-29 08:00:17 -0800 | [diff] [blame] | 723 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 724 | #ifdef FEATURE_WLAN_TDLS |
| 725 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
| 726 | | WIPHY_FLAG_TDLS_EXTERNAL_SETUP; |
| 727 | #endif |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 728 | #ifdef FEATURE_WLAN_SCAN_PNO |
Hardik Kantilal Patel | 3dfd879 | 2013-11-13 20:34:57 +0530 | [diff] [blame] | 729 | if (pCfg->configPNOScanSupport) |
| 730 | { |
| 731 | wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; |
| 732 | wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS; |
| 733 | wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS; |
| 734 | wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
| 735 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 736 | #endif/*FEATURE_WLAN_SCAN_PNO*/ |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 737 | |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 738 | #ifdef CONFIG_ENABLE_LINUX_REG |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 739 | /* even with WIPHY_FLAG_CUSTOM_REGULATORY, |
| 740 | driver can still register regulatory callback and |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 741 | it will get regulatory settings in wiphy->band[], but |
Madan Mohan Koyyalamudi | c3a240c | 2012-09-28 15:34:08 -0700 | [diff] [blame] | 742 | driver need to determine what to do with both |
| 743 | regulatory settings */ |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 744 | |
| 745 | wiphy->reg_notifier = wlan_hdd_linux_reg_notifier; |
Amar Singhal | a49cbc5 | 2013-10-08 18:37:44 -0700 | [diff] [blame] | 746 | #else |
| 747 | wiphy->reg_notifier = wlan_hdd_crda_reg_notifier; |
Amar Singhal | fddc28c | 2013-09-05 13:03:40 -0700 | [diff] [blame] | 748 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 749 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 750 | wiphy->max_scan_ssids = MAX_SCAN_SSID; |
| 751 | |
Madan Mohan Koyyalamudi | 6815b16 | 2013-07-19 17:17:46 +0530 | [diff] [blame] | 752 | wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 753 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 754 | wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS; |
| 755 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 756 | /* Supports STATION & AD-HOC modes right now */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 757 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 758 | | BIT(NL80211_IFTYPE_ADHOC) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 759 | | BIT(NL80211_IFTYPE_P2P_CLIENT) |
| 760 | | BIT(NL80211_IFTYPE_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 761 | | BIT(NL80211_IFTYPE_AP); |
| 762 | |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 763 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 764 | if( pCfg->enableMCC ) |
| 765 | { |
| 766 | /* Currently, supports up to two channels */ |
| 767 | wlan_hdd_iface_combination.num_different_channels = 2; |
| 768 | |
| 769 | if( !pCfg->allowMCCGODiffBI ) |
| 770 | wlan_hdd_iface_combination.beacon_int_infra_match = true; |
| 771 | |
| 772 | } |
| 773 | wiphy->iface_combinations = &wlan_hdd_iface_combination; |
| 774 | wiphy->n_iface_combinations = 1; |
| 775 | #endif |
Sudhir Sattayappa Kohalli | 278eee5 | 2013-01-16 17:35:13 -0800 | [diff] [blame] | 776 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 777 | /* Before registering we need to update the ht capabilitied based |
| 778 | * on ini values*/ |
| 779 | if( !pCfg->ShortGI20MhzEnable ) |
| 780 | { |
| 781 | wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 782 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 783 | wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 784 | } |
| 785 | |
| 786 | if( !pCfg->ShortGI40MhzEnable ) |
| 787 | { |
| 788 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 789 | } |
| 790 | |
| 791 | if( !pCfg->nChannelBondingMode5GHz ) |
| 792 | { |
| 793 | wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 794 | } |
| 795 | |
Gopichand Nakkala | 1f7a64f | 2013-04-01 18:37:17 +0530 | [diff] [blame] | 796 | wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ; |
| 797 | wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ; |
| 798 | |
| 799 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 800 | { |
| 801 | |
| 802 | if (NULL == wiphy->bands[i]) |
| 803 | { |
| 804 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d", |
| 805 | __func__, i); |
| 806 | continue; |
| 807 | } |
| 808 | |
| 809 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 810 | { |
| 811 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 812 | |
| 813 | if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only |
| 814 | { |
| 815 | // Enable social channels for P2P |
| 816 | if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq)) |
| 817 | band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED; |
| 818 | else |
| 819 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 820 | continue; |
| 821 | } |
| 822 | else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only |
| 823 | { |
| 824 | band->channels[j].flags |= IEEE80211_CHAN_DISABLED; |
| 825 | continue; |
| 826 | } |
| 827 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 828 | } |
| 829 | /*Initialise the supported cipher suite details*/ |
| 830 | wiphy->cipher_suites = hdd_cipher_suites; |
| 831 | wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites); |
| 832 | |
| 833 | /*signal strength in mBm (100*dBm) */ |
| 834 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 835 | |
| 836 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 837 | wiphy->max_remain_on_channel_duration = 1000; |
| 838 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 839 | |
Rajesh Chauhan | 98a31f8 | 2014-01-06 20:15:25 -0800 | [diff] [blame] | 840 | wiphy->n_vendor_commands = 0; |
| 841 | wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events; |
| 842 | wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events); |
| 843 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 844 | EXIT(); |
| 845 | return 0; |
| 846 | } |
| 847 | |
| 848 | /* In this function we are registering wiphy. */ |
| 849 | int wlan_hdd_cfg80211_register(struct wiphy *wiphy) |
| 850 | { |
| 851 | ENTER(); |
| 852 | /* Register our wiphy dev with cfg80211 */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 853 | if (0 > wiphy_register(wiphy)) |
| 854 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 855 | /* print error */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 856 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__); |
| 857 | return -EIO; |
| 858 | } |
| 859 | |
| 860 | EXIT(); |
| 861 | return 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 862 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 863 | |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 864 | /* In this function we are updating channel list when, |
| 865 | regulatory domain is FCC and country code is US. |
| 866 | Here In FCC standard 5GHz UNII-1 Bands are indoor only. |
| 867 | As per FCC smart phone is not a indoor device. |
| 868 | GO should not opeate on indoor channels */ |
| 869 | void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy) |
| 870 | { |
| 871 | int j; |
| 872 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 873 | tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE; |
| 874 | //Default counrtycode from NV at the time of wiphy initialization. |
| 875 | if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal, |
| 876 | &defaultCountryCode[0])) |
| 877 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 878 | hddLog(LOGE, FL("Failed to get default country code from NV")); |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 879 | } |
| 880 | if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S')) |
| 881 | { |
Madan Mohan Koyyalamudi | 7127826 | 2013-04-12 22:00:48 +0530 | [diff] [blame] | 882 | if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ]) |
| 883 | { |
| 884 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ ); |
| 885 | return; |
| 886 | } |
| 887 | for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++) |
| 888 | { |
| 889 | struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ]; |
| 890 | // Mark UNII -1 band channel as passive |
| 891 | if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq)) |
| 892 | band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN; |
| 893 | } |
| 894 | } |
| 895 | } |
| 896 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 897 | /* In this function we will do all post VOS start initialization. |
| 898 | In this function we will register for all frame in which supplicant |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 899 | is interested. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 900 | */ |
| 901 | void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter) |
| 902 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 903 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 904 | /* Register for all P2P action, public action etc frames */ |
| 905 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 906 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 907 | ENTER(); |
| 908 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 909 | /* Right now we are registering these frame when driver is getting |
| 910 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 911 | frame register ops, we will move this code as a part of that */ |
| 912 | /* GAS Initial Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 913 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 914 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 915 | |
| 916 | /* GAS Initial Response */ |
| 917 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 918 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 919 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 920 | /* GAS Comeback Request */ |
| 921 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 922 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 923 | |
| 924 | /* GAS Comeback Response */ |
| 925 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 926 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 927 | |
| 928 | /* P2P Public Action */ |
| 929 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 930 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 931 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 932 | |
| 933 | /* P2P Action */ |
| 934 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 935 | (v_U8_t*)P2P_ACTION_FRAME, |
| 936 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 937 | |
Gopichand Nakkala | e3d56e7 | 2013-04-21 23:33:32 +0530 | [diff] [blame] | 938 | /* WNM BSS Transition Request frame */ |
| 939 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 940 | (v_U8_t*)WNM_BSS_ACTION_FRAME, |
| 941 | WNM_BSS_ACTION_FRAME_SIZE ); |
| 942 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 943 | #ifdef WLAN_FEATURE_11W |
| 944 | /* SA Query Response Action Frame */ |
| 945 | sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 946 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 947 | SA_QUERY_FRAME_RSP_SIZE ); |
| 948 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter) |
| 952 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 953 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 954 | /* Register for all P2P action, public action etc frames */ |
| 955 | v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4); |
| 956 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 957 | ENTER(); |
| 958 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 959 | /* Right now we are registering these frame when driver is getting |
| 960 | initialized. Once we will move to 2.6.37 kernel, in which we have |
| 961 | frame register ops, we will move this code as a part of that */ |
| 962 | /* GAS Initial Request */ |
| 963 | |
| 964 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 965 | (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE ); |
| 966 | |
| 967 | /* GAS Initial Response */ |
| 968 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 969 | (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 970 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 971 | /* GAS Comeback Request */ |
| 972 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 973 | (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE ); |
| 974 | |
| 975 | /* GAS Comeback Response */ |
| 976 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 977 | (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE ); |
| 978 | |
| 979 | /* P2P Public Action */ |
| 980 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 981 | (v_U8_t*)P2P_PUBLIC_ACTION_FRAME, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 982 | P2P_PUBLIC_ACTION_FRAME_SIZE ); |
| 983 | |
| 984 | /* P2P Action */ |
| 985 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 986 | (v_U8_t*)P2P_ACTION_FRAME, |
| 987 | P2P_ACTION_FRAME_SIZE ); |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 988 | |
| 989 | #ifdef WLAN_FEATURE_11W |
| 990 | /* SA Query Response Action Frame */ |
| 991 | sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type, |
| 992 | (v_U8_t*)SA_QUERY_FRAME_RSP, |
| 993 | SA_QUERY_FRAME_RSP_SIZE ); |
| 994 | #endif /* WLAN_FEATURE_11W */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | #ifdef FEATURE_WLAN_WAPI |
| 998 | void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index, |
| 999 | const u8 *mac_addr, u8 *key , int key_Len) |
| 1000 | { |
| 1001 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1002 | tCsrRoamSetKey setKey; |
| 1003 | v_BOOL_t isConnected = TRUE; |
| 1004 | int status = 0; |
| 1005 | v_U32_t roamId= 0xFF; |
| 1006 | tANI_U8 *pKeyPtr = NULL; |
| 1007 | int n = 0; |
| 1008 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1009 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1010 | __func__,pAdapter->device_mode); |
| 1011 | |
Gopichand Nakkala | e748020 | 2013-02-11 15:24:22 +0530 | [diff] [blame] | 1012 | vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1013 | setKey.keyId = key_index; // Store Key ID |
| 1014 | setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption |
| 1015 | setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX |
| 1016 | setKey.paeRole = 0 ; // the PAE role |
| 1017 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 1018 | { |
| 1019 | vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac ); |
| 1020 | } |
| 1021 | else |
| 1022 | { |
| 1023 | isConnected = hdd_connIsConnected(pHddStaCtx); |
| 1024 | vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN); |
| 1025 | } |
| 1026 | setKey.keyLength = key_Len; |
| 1027 | pKeyPtr = setKey.Key; |
| 1028 | memcpy( pKeyPtr, key, key_Len); |
| 1029 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1030 | hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1031 | __func__, key_Len); |
| 1032 | for (n = 0 ; n < key_Len; n++) |
| 1033 | hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ", |
| 1034 | __func__,n,setKey.Key[n]); |
| 1035 | |
| 1036 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 1037 | if ( isConnected ) |
| 1038 | { |
| 1039 | status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 1040 | pAdapter->sessionId, &setKey, &roamId ); |
| 1041 | } |
| 1042 | if ( status != 0 ) |
| 1043 | { |
| 1044 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1045 | "[%4d] sme_RoamSetKey returned ERROR status= %d", |
| 1046 | __LINE__, status ); |
| 1047 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 1048 | } |
| 1049 | } |
| 1050 | #endif /* FEATURE_WLAN_WAPI*/ |
| 1051 | |
| 1052 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1053 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1054 | beacon_data_t **ppBeacon, |
| 1055 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1056 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1057 | int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1058 | beacon_data_t **ppBeacon, |
| 1059 | struct cfg80211_beacon_data *params, |
| 1060 | int dtim_period) |
| 1061 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1062 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1063 | int size; |
| 1064 | beacon_data_t *beacon = NULL; |
| 1065 | beacon_data_t *old = NULL; |
| 1066 | int head_len,tail_len; |
| 1067 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1068 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1069 | if (params->head && !params->head_len) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 1070 | { |
| 1071 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1072 | FL("head_len is NULL")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1073 | return -EINVAL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 1074 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1075 | |
| 1076 | old = pAdapter->sessionCtx.ap.beacon; |
| 1077 | |
| 1078 | if (!params->head && !old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 1079 | { |
| 1080 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1081 | FL("session(%d) old and new heads points to NULL"), |
| 1082 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1083 | return -EINVAL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 1084 | } |
| 1085 | |
| 1086 | if (params->tail && !params->tail_len) |
| 1087 | { |
| 1088 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1089 | FL("tail_len is zero but tail is not NULL")); |
| 1090 | return -EINVAL; |
| 1091 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1092 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1093 | #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38)) |
| 1094 | /* Kernel 3.0 is not updating dtim_period for set beacon */ |
| 1095 | if (!params->dtim_period) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 1096 | { |
| 1097 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1098 | FL("dtim period is 0")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1099 | return -EINVAL; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 1100 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1101 | #endif |
| 1102 | |
| 1103 | if(params->head) |
| 1104 | head_len = params->head_len; |
| 1105 | else |
| 1106 | head_len = old->head_len; |
| 1107 | |
| 1108 | if(params->tail || !old) |
| 1109 | tail_len = params->tail_len; |
| 1110 | else |
| 1111 | tail_len = old->tail_len; |
| 1112 | |
| 1113 | size = sizeof(beacon_data_t) + head_len + tail_len; |
| 1114 | |
| 1115 | beacon = kzalloc(size, GFP_KERNEL); |
| 1116 | |
| 1117 | if( beacon == NULL ) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 1118 | { |
| 1119 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1120 | FL("Mem allocation for beacon failed")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1121 | return -ENOMEM; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 1122 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1123 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1124 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1125 | if(params->dtim_period || !old ) |
| 1126 | beacon->dtim_period = params->dtim_period; |
| 1127 | else |
| 1128 | beacon->dtim_period = old->dtim_period; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1129 | #else |
| 1130 | if(dtim_period || !old ) |
| 1131 | beacon->dtim_period = dtim_period; |
| 1132 | else |
| 1133 | beacon->dtim_period = old->dtim_period; |
| 1134 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1135 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1136 | beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t); |
| 1137 | beacon->tail = beacon->head + head_len; |
| 1138 | beacon->head_len = head_len; |
| 1139 | beacon->tail_len = tail_len; |
| 1140 | |
| 1141 | if(params->head) { |
| 1142 | memcpy (beacon->head,params->head,beacon->head_len); |
| 1143 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1144 | else { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1145 | if(old) |
| 1146 | memcpy (beacon->head,old->head,beacon->head_len); |
| 1147 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1148 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1149 | if(params->tail) { |
| 1150 | memcpy (beacon->tail,params->tail,beacon->tail_len); |
| 1151 | } |
| 1152 | else { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1153 | if(old) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1154 | memcpy (beacon->tail,old->tail,beacon->tail_len); |
| 1155 | } |
| 1156 | |
| 1157 | *ppBeacon = beacon; |
| 1158 | |
| 1159 | kfree(old); |
| 1160 | |
| 1161 | return 0; |
| 1162 | |
| 1163 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1164 | |
| 1165 | v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid) |
| 1166 | { |
| 1167 | int left = length; |
| 1168 | v_U8_t *ptr = pIes; |
| 1169 | v_U8_t elem_id,elem_len; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1170 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1171 | while(left >= 2) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1172 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1173 | elem_id = ptr[0]; |
| 1174 | elem_len = ptr[1]; |
| 1175 | left -= 2; |
| 1176 | if(elem_len > left) |
| 1177 | { |
| 1178 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1179 | FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1180 | eid,elem_len,left); |
| 1181 | return NULL; |
| 1182 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1183 | if (elem_id == eid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1184 | { |
| 1185 | return ptr; |
| 1186 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1187 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1188 | left -= elem_len; |
| 1189 | ptr += (elem_len + 2); |
| 1190 | } |
| 1191 | return NULL; |
| 1192 | } |
| 1193 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1194 | /* Check if rate is 11g rate or not */ |
| 1195 | static int wlan_hdd_rate_is_11g(u8 rate) |
| 1196 | { |
Sanjay Devnani | 28322e2 | 2013-06-21 16:13:40 -0700 | [diff] [blame] | 1197 | 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] | 1198 | u8 i; |
| 1199 | for (i = 0; i < 8; i++) |
| 1200 | { |
| 1201 | if(rate == gRateArray[i]) |
| 1202 | return TRUE; |
| 1203 | } |
| 1204 | return FALSE; |
| 1205 | } |
| 1206 | |
| 1207 | /* Check for 11g rate and set proper 11g only mode */ |
| 1208 | static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht, |
| 1209 | u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode) |
| 1210 | { |
| 1211 | u8 i, num_rates = pIe[0]; |
| 1212 | |
| 1213 | pIe += 1; |
| 1214 | for ( i = 0; i < num_rates; i++) |
| 1215 | { |
| 1216 | if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK))) |
| 1217 | { |
| 1218 | /* If rate set have 11g rate than change the mode to 11G */ |
| 1219 | *pSapHw_mode = eSAP_DOT11_MODE_11g; |
| 1220 | if (pIe[i] & BASIC_RATE_MASK) |
| 1221 | { |
| 1222 | /* If we have 11g rate as basic rate, it means mode |
| 1223 | is 11g only mode. |
| 1224 | */ |
| 1225 | *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY; |
| 1226 | *pCheckRatesfor11g = FALSE; |
| 1227 | } |
| 1228 | } |
| 1229 | else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i]) |
| 1230 | { |
| 1231 | *require_ht = TRUE; |
| 1232 | } |
| 1233 | } |
| 1234 | return; |
| 1235 | } |
| 1236 | |
| 1237 | static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter) |
| 1238 | { |
| 1239 | tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1240 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1241 | struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1242 | u8 checkRatesfor11g = TRUE; |
| 1243 | u8 require_ht = FALSE; |
| 1244 | u8 *pIe=NULL; |
| 1245 | |
| 1246 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11b; |
| 1247 | |
| 1248 | pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0], |
| 1249 | pBeacon->head_len, WLAN_EID_SUPP_RATES); |
| 1250 | if (pIe != NULL) |
| 1251 | { |
| 1252 | pIe += 1; |
| 1253 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1254 | &pConfig->SapHw_mode); |
| 1255 | } |
| 1256 | |
| 1257 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1258 | WLAN_EID_EXT_SUPP_RATES); |
| 1259 | if (pIe != NULL) |
| 1260 | { |
| 1261 | |
| 1262 | pIe += 1; |
| 1263 | wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g, |
| 1264 | &pConfig->SapHw_mode); |
| 1265 | } |
| 1266 | |
| 1267 | if( pConfig->channel > 14 ) |
| 1268 | { |
| 1269 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11a; |
| 1270 | } |
| 1271 | |
| 1272 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
| 1273 | WLAN_EID_HT_CAPABILITY); |
| 1274 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1275 | if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1276 | { |
| 1277 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n; |
| 1278 | if(require_ht) |
| 1279 | pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY; |
| 1280 | } |
| 1281 | } |
| 1282 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1283 | static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie, |
| 1284 | v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size) |
| 1285 | { |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 1286 | v_U16_t ielen = 0; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1287 | v_U8_t *pIe = NULL; |
| 1288 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1289 | |
| 1290 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size, |
| 1291 | pBeacon->tail, pBeacon->tail_len); |
| 1292 | |
| 1293 | if (pIe) |
| 1294 | { |
| 1295 | ielen = pIe[1] + 2; |
| 1296 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 1297 | { |
| 1298 | vos_mem_copy(&genie[*total_ielen], pIe, ielen); |
| 1299 | } |
| 1300 | else |
| 1301 | { |
| 1302 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***"); |
| 1303 | return -EINVAL; |
| 1304 | } |
| 1305 | *total_ielen += ielen; |
| 1306 | } |
| 1307 | return 0; |
| 1308 | } |
| 1309 | |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 1310 | static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter, |
| 1311 | v_U8_t *genie, v_U8_t *total_ielen) |
| 1312 | { |
| 1313 | beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1314 | int left = pBeacon->tail_len; |
| 1315 | v_U8_t *ptr = pBeacon->tail; |
| 1316 | v_U8_t elem_id, elem_len; |
| 1317 | v_U16_t ielen = 0; |
| 1318 | |
| 1319 | if ( NULL == ptr || 0 == left ) |
| 1320 | return; |
| 1321 | |
| 1322 | while (left >= 2) |
| 1323 | { |
| 1324 | elem_id = ptr[0]; |
| 1325 | elem_len = ptr[1]; |
| 1326 | left -= 2; |
| 1327 | if (elem_len > left) |
| 1328 | { |
| 1329 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 1330 | "****Invalid IEs eid = %d elem_len=%d left=%d*****", |
| 1331 | elem_id, elem_len, left); |
| 1332 | return; |
| 1333 | } |
| 1334 | if (IE_EID_VENDOR == elem_id) |
| 1335 | { |
| 1336 | /* skipping the VSIE's which we don't want to include or |
| 1337 | * it will be included by existing code |
| 1338 | */ |
| 1339 | if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) && |
| 1340 | #ifdef WLAN_FEATURE_WFD |
| 1341 | (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) && |
| 1342 | #endif |
| 1343 | (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 1344 | (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 1345 | (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) && |
| 1346 | (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) && |
| 1347 | (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0)) |
| 1348 | { |
| 1349 | ielen = ptr[1] + 2; |
| 1350 | if ((*total_ielen + ielen) <= MAX_GENIE_LEN) |
| 1351 | { |
| 1352 | vos_mem_copy(&genie[*total_ielen], ptr, ielen); |
| 1353 | *total_ielen += ielen; |
| 1354 | } |
| 1355 | else |
| 1356 | { |
| 1357 | hddLog( VOS_TRACE_LEVEL_ERROR, |
| 1358 | "IE Length is too big " |
| 1359 | "IEs eid=%d elem_len=%d total_ie_lent=%d", |
| 1360 | elem_id, elem_len, *total_ielen); |
| 1361 | } |
| 1362 | } |
| 1363 | } |
| 1364 | |
| 1365 | left -= elem_len; |
| 1366 | ptr += (elem_len + 2); |
| 1367 | } |
| 1368 | return; |
| 1369 | } |
| 1370 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1371 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1372 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1373 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1374 | #else |
| 1375 | static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter, |
| 1376 | struct cfg80211_beacon_data *params) |
| 1377 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1378 | { |
| 1379 | v_U8_t *genie; |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1380 | v_U8_t total_ielen = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1381 | v_U8_t addIE[1] = {0}; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1382 | int ret = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1383 | |
| 1384 | genie = vos_mem_malloc(MAX_GENIE_LEN); |
| 1385 | |
| 1386 | if(genie == NULL) { |
| 1387 | |
| 1388 | return -ENOMEM; |
| 1389 | } |
| 1390 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1391 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1392 | &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1393 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 1394 | hddLog(LOGE, |
| 1395 | FL("Adding WPS IE failed")); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1396 | ret = -EINVAL; |
| 1397 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1398 | } |
| 1399 | |
| 1400 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1401 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1402 | &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE)) |
| 1403 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 1404 | hddLog(LOGE, |
| 1405 | FL("Adding WFD IE failed")); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1406 | ret = -EINVAL; |
| 1407 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1408 | } |
| 1409 | #endif |
| 1410 | |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1411 | if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie, |
| 1412 | &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1413 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 1414 | hddLog(LOGE, |
| 1415 | FL("Adding P2P IE failed")); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1416 | ret = -EINVAL; |
| 1417 | goto done; |
| 1418 | } |
| 1419 | |
| 1420 | if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode) |
| 1421 | { |
Arif Hussain | e7f3ea5 | 2013-09-12 21:56:36 -0700 | [diff] [blame] | 1422 | wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1423 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1424 | |
| 1425 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1426 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL, |
| 1427 | eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 1428 | { |
| 1429 | hddLog(LOGE, |
| 1430 | "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] | 1431 | ret = -EINVAL; |
| 1432 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1433 | } |
| 1434 | |
| 1435 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1436 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 1437 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1438 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1439 | ==eHAL_STATUS_FAILURE) |
| 1440 | { |
| 1441 | hddLog(LOGE, |
| 1442 | "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] | 1443 | ret = -EINVAL; |
| 1444 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1445 | } |
| 1446 | |
| 1447 | // Added for ProResp IE |
| 1448 | if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) ) |
| 1449 | { |
| 1450 | u16 rem_probe_resp_ie_len = params->proberesp_ies_len; |
| 1451 | u8 probe_rsp_ie_len[3] = {0}; |
| 1452 | u8 counter = 0; |
| 1453 | /* Check Probe Resp Length if it is greater then 255 then Store |
| 1454 | Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 & |
| 1455 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able |
| 1456 | Store More then 255 bytes into One Variable. |
| 1457 | */ |
| 1458 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 1459 | { |
| 1460 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 1461 | { |
| 1462 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 1463 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 1464 | } |
| 1465 | else |
| 1466 | { |
| 1467 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 1468 | rem_probe_resp_ie_len = 0; |
| 1469 | } |
| 1470 | } |
| 1471 | |
| 1472 | rem_probe_resp_ie_len = 0; |
| 1473 | |
| 1474 | if (probe_rsp_ie_len[0] > 0) |
| 1475 | { |
| 1476 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1477 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 1478 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1479 | probe_rsp_ie_len[0], NULL, |
| 1480 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1481 | { |
| 1482 | hddLog(LOGE, |
| 1483 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1484 | ret = -EINVAL; |
| 1485 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1486 | } |
| 1487 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 1488 | } |
| 1489 | |
| 1490 | if (probe_rsp_ie_len[1] > 0) |
| 1491 | { |
| 1492 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1493 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 1494 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1495 | probe_rsp_ie_len[1], NULL, |
| 1496 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1497 | { |
| 1498 | hddLog(LOGE, |
| 1499 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1500 | ret = -EINVAL; |
| 1501 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1502 | } |
| 1503 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 1504 | } |
| 1505 | |
| 1506 | if (probe_rsp_ie_len[2] > 0) |
| 1507 | { |
| 1508 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1509 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 1510 | (tANI_U8*)¶ms->proberesp_ies[rem_probe_resp_ie_len], |
| 1511 | probe_rsp_ie_len[2], NULL, |
| 1512 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1513 | { |
| 1514 | hddLog(LOGE, |
| 1515 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1516 | ret = -EINVAL; |
| 1517 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1518 | } |
| 1519 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 1520 | } |
| 1521 | |
| 1522 | if (probe_rsp_ie_len[1] == 0 ) |
| 1523 | { |
| 1524 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1525 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL, |
| 1526 | eANI_BOOLEAN_FALSE) ) |
| 1527 | { |
| 1528 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1529 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1530 | } |
| 1531 | } |
| 1532 | |
| 1533 | if (probe_rsp_ie_len[2] == 0 ) |
| 1534 | { |
| 1535 | if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1536 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL, |
| 1537 | eANI_BOOLEAN_FALSE) ) |
| 1538 | { |
| 1539 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1540 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1541 | } |
| 1542 | } |
| 1543 | |
| 1544 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1545 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 1546 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1547 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1548 | == eHAL_STATUS_FAILURE) |
| 1549 | { |
| 1550 | hddLog(LOGE, |
| 1551 | "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1552 | ret = -EINVAL; |
| 1553 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1554 | } |
| 1555 | } |
| 1556 | else |
| 1557 | { |
| 1558 | // Reset WNI_CFG_PROBE_RSP Flags |
| 1559 | wlan_hdd_reset_prob_rspies(pHostapdAdapter); |
| 1560 | |
| 1561 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1562 | "%s: No Probe Response IE received in set beacon", |
| 1563 | __func__); |
| 1564 | } |
| 1565 | |
| 1566 | // Added for AssocResp IE |
| 1567 | if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) ) |
| 1568 | { |
| 1569 | if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1570 | WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies, |
| 1571 | params->assocresp_ies_len, NULL, |
| 1572 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 1573 | { |
| 1574 | hddLog(LOGE, |
| 1575 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1576 | ret = -EINVAL; |
| 1577 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1578 | } |
| 1579 | |
| 1580 | if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1581 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL, |
| 1582 | test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ? |
| 1583 | eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE) |
| 1584 | == eHAL_STATUS_FAILURE) |
| 1585 | { |
| 1586 | hddLog(LOGE, |
| 1587 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1588 | ret = -EINVAL; |
| 1589 | goto done; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1590 | } |
| 1591 | } |
| 1592 | else |
| 1593 | { |
| 1594 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 1595 | "%s: No Assoc Response IE received in set beacon", |
| 1596 | __func__); |
| 1597 | |
| 1598 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal, |
| 1599 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 1600 | eANI_BOOLEAN_FALSE) ) |
| 1601 | { |
| 1602 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1603 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1604 | } |
| 1605 | } |
| 1606 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 1607 | done: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1608 | vos_mem_free(genie); |
Gopichand Nakkala | 2b25f4e | 2013-03-21 19:14:07 +0530 | [diff] [blame] | 1609 | return ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1610 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1611 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1612 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1613 | * FUNCTION: wlan_hdd_validate_operation_channel |
| 1614 | * called by wlan_hdd_cfg80211_start_bss() and |
| 1615 | * wlan_hdd_cfg80211_set_channel() |
| 1616 | * This function validates whether given channel is part of valid |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1617 | * channel list. |
| 1618 | */ |
Varun Reddy Yeturu | 920df21 | 2013-05-22 08:07:23 -0700 | [diff] [blame] | 1619 | 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] | 1620 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1621 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1622 | v_U32_t num_ch = 0; |
| 1623 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 1624 | u32 indx = 0; |
| 1625 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1626 | v_U8_t fValidChannel = FALSE, count = 0; |
| 1627 | 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] | 1628 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1629 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1630 | |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1631 | if ( hdd_pConfig_ini->sapAllowAllChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1632 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1633 | /* Validate the channel */ |
| 1634 | for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1635 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1636 | if ( channel == rfChannels[count].channelNum ) |
| 1637 | { |
| 1638 | fValidChannel = TRUE; |
| 1639 | break; |
| 1640 | } |
| 1641 | } |
| 1642 | if (fValidChannel != TRUE) |
| 1643 | { |
| 1644 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1645 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1646 | return VOS_STATUS_E_FAILURE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1647 | } |
| 1648 | } |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1649 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1650 | { |
Madan Mohan Koyylamudi | 64267f7 | 2013-02-05 14:07:08 +0530 | [diff] [blame] | 1651 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 1652 | valid_ch, &num_ch)) |
| 1653 | { |
| 1654 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1655 | "%s: failed to get valid channel list", __func__); |
| 1656 | return VOS_STATUS_E_FAILURE; |
| 1657 | } |
| 1658 | for (indx = 0; indx < num_ch; indx++) |
| 1659 | { |
| 1660 | if (channel == valid_ch[indx]) |
| 1661 | { |
| 1662 | break; |
| 1663 | } |
| 1664 | } |
| 1665 | |
| 1666 | if (indx >= num_ch) |
| 1667 | { |
| 1668 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 1669 | "%s: Invalid Channel [%d]", __func__, channel); |
| 1670 | return VOS_STATUS_E_FAILURE; |
| 1671 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1672 | } |
| 1673 | return VOS_STATUS_SUCCESS; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1674 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1675 | } |
| 1676 | |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1677 | /** |
| 1678 | * FUNCTION: wlan_hdd_cfg80211_set_channel |
| 1679 | * This function is used to set the channel number |
| 1680 | */ |
| 1681 | static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev, |
| 1682 | struct ieee80211_channel *chan, |
| 1683 | enum nl80211_channel_type channel_type |
| 1684 | ) |
| 1685 | { |
| 1686 | v_U32_t num_ch = 0; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 1687 | int channel = 0; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1688 | hdd_adapter_t *pAdapter = NULL; |
| 1689 | int freq = chan->center_freq; /* freq is in MHZ */ |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1690 | hdd_context_t *pHddCtx; |
| 1691 | int status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1692 | |
| 1693 | ENTER(); |
| 1694 | |
| 1695 | if( NULL == dev ) |
| 1696 | { |
| 1697 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1698 | "%s: Called with dev = NULL.", __func__); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1699 | return -ENODEV; |
| 1700 | } |
| 1701 | pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 1702 | |
| 1703 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1704 | "%s: device_mode = %d freq = %d", __func__, |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1705 | pAdapter->device_mode, chan->center_freq); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1706 | |
| 1707 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 1708 | status = wlan_hdd_validate_context(pHddCtx); |
| 1709 | |
| 1710 | if (0 != status) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1711 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1712 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 1713 | "%s: HDD context is not valid", __func__); |
| 1714 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1715 | } |
| 1716 | |
| 1717 | /* |
| 1718 | * Do freq to chan conversion |
| 1719 | * TODO: for 11a |
| 1720 | */ |
| 1721 | |
| 1722 | channel = ieee80211_frequency_to_channel(freq); |
| 1723 | |
| 1724 | /* Check freq range */ |
| 1725 | if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) || |
| 1726 | (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel)) |
| 1727 | { |
| 1728 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1729 | "%s: Channel [%d] is outside valid range from %d to %d", |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1730 | __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN, |
| 1731 | WNI_CFG_CURRENT_CHANNEL_STAMAX); |
| 1732 | return -EINVAL; |
| 1733 | } |
| 1734 | |
| 1735 | num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 1736 | |
Gopichand Nakkala | 6ab1956 | 2013-03-07 13:59:42 +0530 | [diff] [blame] | 1737 | if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) && |
| 1738 | (WLAN_HDD_P2P_GO != pAdapter->device_mode)) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1739 | { |
| 1740 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1741 | { |
| 1742 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1743 | "%s: Invalid Channel [%d]", __func__, channel); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1744 | return -EINVAL; |
| 1745 | } |
| 1746 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1747 | "%s: set channel to [%d] for device mode =%d", |
| 1748 | __func__, channel,pAdapter->device_mode); |
| 1749 | } |
| 1750 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1751 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1752 | ) |
| 1753 | { |
| 1754 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 1755 | tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile; |
| 1756 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 1757 | |
| 1758 | if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) |
| 1759 | { |
| 1760 | /* Link is up then return cant set channel*/ |
| 1761 | hddLog( VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1762 | "%s: IBSS Associated, can't set the channel", __func__); |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1763 | return -EINVAL; |
| 1764 | } |
| 1765 | |
| 1766 | num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 1767 | pHddStaCtx->conn_info.operationChannel = channel; |
| 1768 | pRoamProfile->ChannelInfo.ChannelList = |
| 1769 | &pHddStaCtx->conn_info.operationChannel; |
| 1770 | } |
| 1771 | else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1772 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1773 | ) |
| 1774 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1775 | if (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 1776 | { |
| 1777 | if(VOS_STATUS_SUCCESS != |
| 1778 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1779 | { |
| 1780 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1781 | "%s: Invalid Channel [%d]", __func__, channel); |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1782 | return -EINVAL; |
| 1783 | } |
| 1784 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1785 | } |
| 1786 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1787 | { |
| 1788 | hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini; |
| 1789 | |
| 1790 | /* If auto channel selection is configured as enable/ 1 then ignore |
| 1791 | channel set by supplicant |
| 1792 | */ |
| 1793 | if ( cfg_param->apAutoChannelSelection ) |
| 1794 | { |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1795 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = |
| 1796 | AUTO_CHANNEL_SELECT; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1797 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 1798 | "%s: set channel to auto channel (0) for device mode =%d", |
| 1799 | __func__, pAdapter->device_mode); |
| 1800 | } |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1801 | else |
| 1802 | { |
| 1803 | if(VOS_STATUS_SUCCESS != |
| 1804 | wlan_hdd_validate_operation_channel(pAdapter,channel)) |
| 1805 | { |
| 1806 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1807 | "%s: Invalid Channel [%d]", __func__, channel); |
Gopichand Nakkala | c8fa7b6 | 2013-03-11 13:56:41 +0530 | [diff] [blame] | 1808 | return -EINVAL; |
| 1809 | } |
| 1810 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel; |
| 1811 | } |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1812 | } |
| 1813 | } |
| 1814 | else |
| 1815 | { |
| 1816 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 1817 | "%s: Invalid device mode failed to set valid channel", __func__); |
| 1818 | return -EINVAL; |
| 1819 | } |
| 1820 | EXIT(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 1821 | return status; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 1822 | } |
| 1823 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1824 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 1825 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1826 | struct beacon_parameters *params) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 1827 | #else |
| 1828 | static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter, |
| 1829 | struct cfg80211_beacon_data *params, |
| 1830 | const u8 *ssid, size_t ssid_len, |
| 1831 | enum nl80211_hidden_ssid hidden_ssid) |
| 1832 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1833 | { |
| 1834 | tsap_Config_t *pConfig; |
| 1835 | beacon_data_t *pBeacon = NULL; |
| 1836 | struct ieee80211_mgmt *pMgmt_frame; |
| 1837 | v_U8_t *pIe=NULL; |
| 1838 | v_U16_t capab_info; |
| 1839 | eCsrAuthType RSNAuthType; |
| 1840 | eCsrEncryptionType RSNEncryptType; |
| 1841 | eCsrEncryptionType mcRSNEncryptType; |
| 1842 | int status = VOS_STATUS_SUCCESS; |
| 1843 | tpWLAN_SAPEventCB pSapEventCallback; |
| 1844 | hdd_hostapd_state_t *pHostapdState; |
| 1845 | v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2 |
| 1846 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext; |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1847 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1848 | struct qc_mac_acl_entry *acl_entry = NULL; |
| 1849 | v_SINT_t i; |
Madan Mohan Koyyalamudi | 543172b | 2012-12-05 16:40:18 -0800 | [diff] [blame] | 1850 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1851 | |
| 1852 | ENTER(); |
| 1853 | |
| 1854 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter); |
| 1855 | |
| 1856 | pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig; |
| 1857 | |
| 1858 | pBeacon = pHostapdAdapter->sessionCtx.ap.beacon; |
| 1859 | |
| 1860 | pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head; |
| 1861 | |
| 1862 | pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int; |
| 1863 | |
| 1864 | //channel is already set in the set_channel Call back |
| 1865 | //pConfig->channel = pCommitConfig->channel; |
| 1866 | |
| 1867 | /*Protection parameter to enable or disable*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1868 | pConfig->protEnabled = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1869 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled; |
| 1870 | |
| 1871 | pConfig->dtim_period = pBeacon->dtim_period; |
| 1872 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1873 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1874 | pConfig->dtim_period); |
| 1875 | |
| 1876 | |
Madan Mohan Koyyalamudi | e0ca11f | 2012-11-27 15:57:52 -0800 | [diff] [blame] | 1877 | if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1878 | { |
| 1879 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1880 | WLAN_EID_COUNTRY); |
Kiet Lam | 083504c | 2013-11-25 14:17:45 +0530 | [diff] [blame] | 1881 | if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0) |
| 1882 | { |
| 1883 | tANI_BOOLEAN restartNeeded; |
| 1884 | pConfig->ieee80211d = 1; |
| 1885 | vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3); |
| 1886 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 1887 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
| 1888 | } |
| 1889 | else if(pIe) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1890 | { |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1891 | tANI_BOOLEAN restartNeeded; |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1892 | pConfig->ieee80211d = 1; |
| 1893 | vos_mem_copy(pConfig->countryCode, &pIe[2], 3); |
| 1894 | sme_setRegInfo(hHal, pConfig->countryCode); |
| 1895 | sme_ResetCountryCodeInformation(hHal, &restartNeeded); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1896 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1897 | else |
| 1898 | { |
| 1899 | pConfig->ieee80211d = 0; |
| 1900 | } |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1901 | /* |
| 1902 | * If auto channel is configured i.e. channel is 0, |
| 1903 | * so skip channel validation. |
| 1904 | */ |
| 1905 | if( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 1906 | { |
| 1907 | if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel)) |
| 1908 | { |
| 1909 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1910 | "%s: Invalid Channel [%d]", __func__, pConfig->channel); |
Madan Mohan Koyylamudi | a16d020 | 2013-02-01 11:05:57 +0530 | [diff] [blame] | 1911 | return -EINVAL; |
| 1912 | } |
| 1913 | } |
| 1914 | else |
| 1915 | { |
| 1916 | if(1 != pHddCtx->is_dynamic_channel_range_set) |
| 1917 | { |
| 1918 | hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini; |
| 1919 | WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum, |
| 1920 | hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand); |
| 1921 | } |
| 1922 | pHddCtx->is_dynamic_channel_range_set = 0; |
| 1923 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1924 | } |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 1925 | else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1926 | { |
| 1927 | pConfig->ieee80211d = 0; |
| 1928 | } |
| 1929 | pConfig->authType = eSAP_AUTO_SWITCH; |
| 1930 | |
| 1931 | capab_info = pMgmt_frame->u.beacon.capab_info; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1932 | |
| 1933 | pConfig->privacy = (pMgmt_frame->u.beacon.capab_info & |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1934 | WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE; |
| 1935 | |
| 1936 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy; |
| 1937 | |
| 1938 | /*Set wps station to configured*/ |
| 1939 | pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len); |
| 1940 | |
| 1941 | if(pIe) |
| 1942 | { |
| 1943 | if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE)) |
| 1944 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 1945 | hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1946 | return -EINVAL; |
| 1947 | } |
| 1948 | else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0) |
| 1949 | { |
Madan Mohan Koyyalamudi | 8bdd311 | 2012-09-24 13:55:14 -0700 | [diff] [blame] | 1950 | hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1951 | /* Check 15 bit of WPS IE as it contain information for wps state |
| 1952 | * WPS state |
| 1953 | */ |
| 1954 | if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15]) |
| 1955 | { |
| 1956 | pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED; |
| 1957 | } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15]) |
| 1958 | { |
| 1959 | pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED; |
| 1960 | } |
| 1961 | } |
| 1962 | } |
| 1963 | else |
| 1964 | { |
| 1965 | pConfig->wps_state = SAP_WPS_DISABLED; |
| 1966 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1967 | pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1968 | |
| 1969 | pConfig->RSNWPAReqIELength = 0; |
| 1970 | pConfig->pRSNWPAReqIE = NULL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1971 | pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1972 | WLAN_EID_RSN); |
| 1973 | if(pIe && pIe[1]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1974 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1975 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 1976 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 1977 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1978 | /* The actual processing may eventually be more extensive than |
| 1979 | * this. Right now, just consume any PMKIDs that are sent in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1980 | * by the app. |
| 1981 | * */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1982 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1983 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 1984 | &RSNEncryptType, |
| 1985 | &mcRSNEncryptType, |
| 1986 | &RSNAuthType, |
| 1987 | pConfig->pRSNWPAReqIE[1]+2, |
| 1988 | pConfig->pRSNWPAReqIE ); |
| 1989 | |
| 1990 | if( VOS_STATUS_SUCCESS == status ) |
| 1991 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 1992 | /* Now copy over all the security attributes you have |
| 1993 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1994 | * */ |
| 1995 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 1996 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 1997 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 1998 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 1999 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2000 | "EncryptionType = %d mcEncryptionType = %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2001 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 2002 | } |
| 2003 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2004 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2005 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 2006 | pBeacon->tail, pBeacon->tail_len); |
| 2007 | |
| 2008 | if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA)) |
| 2009 | { |
| 2010 | if (pConfig->pRSNWPAReqIE) |
| 2011 | { |
| 2012 | /*Mixed mode WPA/WPA2*/ |
| 2013 | memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2); |
| 2014 | pConfig->RSNWPAReqIELength += pIe[1] + 2; |
| 2015 | } |
| 2016 | else |
| 2017 | { |
| 2018 | pConfig->RSNWPAReqIELength = pIe[1] + 2; |
| 2019 | memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength); |
| 2020 | pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2021 | status = hdd_softap_unpackIE( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2022 | vos_get_context( VOS_MODULE_ID_SME, pVosContext), |
| 2023 | &RSNEncryptType, |
| 2024 | &mcRSNEncryptType, |
| 2025 | &RSNAuthType, |
| 2026 | pConfig->pRSNWPAReqIE[1]+2, |
| 2027 | pConfig->pRSNWPAReqIE ); |
| 2028 | |
| 2029 | if( VOS_STATUS_SUCCESS == status ) |
| 2030 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2031 | /* Now copy over all the security attributes you have |
| 2032 | * parsed out |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2033 | * */ |
| 2034 | pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE |
| 2035 | pConfig->mcRSNEncryptType = mcRSNEncryptType; |
| 2036 | (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType |
| 2037 | = RSNEncryptType; |
Gopichand Nakkala | 66c0bd0 | 2013-04-10 11:36:29 +0530 | [diff] [blame] | 2038 | hddLog( LOG1, FL("CSR AuthType = %d, " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2039 | "EncryptionType = %d mcEncryptionType = %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2040 | RSNAuthType, RSNEncryptType, mcRSNEncryptType); |
| 2041 | } |
| 2042 | } |
| 2043 | } |
| 2044 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2045 | if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) { |
| 2046 | hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***"); |
| 2047 | return -EINVAL; |
| 2048 | } |
| 2049 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2050 | pConfig->SSIDinfo.ssidHidden = VOS_FALSE; |
| 2051 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2052 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2053 | if (params->ssid != NULL) |
| 2054 | { |
| 2055 | memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len); |
| 2056 | pConfig->SSIDinfo.ssid.length = params->ssid_len; |
| 2057 | if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 2058 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 2059 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2060 | #else |
| 2061 | if (ssid != NULL) |
| 2062 | { |
| 2063 | memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len); |
| 2064 | pConfig->SSIDinfo.ssid.length = ssid_len; |
| 2065 | if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE) |
| 2066 | pConfig->SSIDinfo.ssidHidden = VOS_TRUE; |
| 2067 | } |
| 2068 | #endif |
| 2069 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2070 | vos_mem_copy(pConfig->self_macaddr.bytes, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2071 | pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t)); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2072 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2073 | /* default value */ |
| 2074 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 2075 | pConfig->num_accept_mac = 0; |
| 2076 | pConfig->num_deny_mac = 0; |
| 2077 | |
| 2078 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 2079 | pBeacon->tail, pBeacon->tail_len); |
| 2080 | |
| 2081 | /* pIe for black list is following form: |
| 2082 | type : 1 byte |
| 2083 | length : 1 byte |
| 2084 | OUI : 4 bytes |
| 2085 | acl type : 1 byte |
| 2086 | no of mac addr in black list: 1 byte |
| 2087 | 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] | 2088 | */ |
| 2089 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2090 | { |
| 2091 | pConfig->SapMacaddr_acl = pIe[6]; |
| 2092 | pConfig->num_deny_mac = pIe[7]; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2093 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2094 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 2095 | if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS) |
| 2096 | pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2097 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 2098 | for (i = 0; i < pConfig->num_deny_mac; i++) |
| 2099 | { |
| 2100 | vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 2101 | acl_entry++; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2102 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2103 | } |
| 2104 | pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE, |
| 2105 | pBeacon->tail, pBeacon->tail_len); |
| 2106 | |
| 2107 | /* pIe for white list is following form: |
| 2108 | type : 1 byte |
| 2109 | length : 1 byte |
| 2110 | OUI : 4 bytes |
| 2111 | acl type : 1 byte |
| 2112 | no of mac addr in white list: 1 byte |
| 2113 | 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] | 2114 | */ |
| 2115 | if ((pIe != NULL) && (pIe[1] != 0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2116 | { |
| 2117 | pConfig->SapMacaddr_acl = pIe[6]; |
| 2118 | pConfig->num_accept_mac = pIe[7]; |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2119 | hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2120 | pIe[6], pIe[7]); |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 2121 | if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS) |
| 2122 | pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2123 | acl_entry = (struct qc_mac_acl_entry *)(pIe + 8); |
| 2124 | for (i = 0; i < pConfig->num_accept_mac; i++) |
| 2125 | { |
| 2126 | vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr)); |
| 2127 | acl_entry++; |
| 2128 | } |
| 2129 | } |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 2130 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2131 | wlan_hdd_set_sapHwmode(pHostapdAdapter); |
| 2132 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2133 | #ifdef WLAN_FEATURE_11AC |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 2134 | /* Overwrite the hostapd setting for HW mode only for 11ac. |
Kiet Lam | 0f32042 | 2013-11-21 19:29:17 +0530 | [diff] [blame] | 2135 | * This is valid only if mode is set to 11n in hostapd, either AUTO or |
| 2136 | * 11ac in .ini and 11ac is supported by both host and firmware. |
| 2137 | * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) |
| 2138 | */ |
Ravi Kumar Vaishnav | bbaebbe | 2013-01-15 17:09:48 -0800 | [diff] [blame] | 2139 | if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) || |
| 2140 | (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2141 | (((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] | 2142 | ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) || |
Kiet Lam | 0f32042 | 2013-11-21 19:29:17 +0530 | [diff] [blame] | 2143 | ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) && |
| 2144 | (sme_IsFeatureSupportedByDriver(DOT11AC)) && (sme_IsFeatureSupportedByFW(DOT11AC)) ) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2145 | { |
| 2146 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac; |
Ravi Joshi | 83bfaa1 | 2013-05-28 22:12:08 -0700 | [diff] [blame] | 2147 | |
| 2148 | /* Disable VHT support in 2.4 GHz band */ |
| 2149 | if (pConfig->channel <= 14 && |
| 2150 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE) |
| 2151 | { |
| 2152 | pConfig->SapHw_mode = eSAP_DOT11_MODE_11n; |
| 2153 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2154 | } |
| 2155 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2156 | |
Ravi Joshi | aeb7d9e | 2013-05-02 12:28:14 -0700 | [diff] [blame] | 2157 | if ( AUTO_CHANNEL_SELECT != pConfig->channel ) |
| 2158 | { |
| 2159 | sme_SelectCBMode(hHal, |
| 2160 | sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode), |
| 2161 | pConfig->channel); |
| 2162 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2163 | // ht_capab is not what the name conveys,this is used for protection bitmap |
| 2164 | pConfig->ht_capab = |
| 2165 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection; |
| 2166 | |
| 2167 | if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) ) |
| 2168 | { |
| 2169 | hddLog(LOGE, FL("SAP Not able to set AP IEs")); |
| 2170 | return -EINVAL; |
| 2171 | } |
| 2172 | |
| 2173 | //Uapsd Enabled Bit |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2174 | pConfig->UapsdEnable = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2175 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled; |
| 2176 | //Enable OBSS protection |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2177 | pConfig->obssProtEnabled = |
| 2178 | (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2179 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2180 | hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2181 | MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes)); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2182 | hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"), |
| 2183 | pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int, |
| 2184 | (int)pConfig->channel); |
| 2185 | hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"), |
| 2186 | pConfig->SapHw_mode, pConfig->privacy, |
| 2187 | pConfig->authType); |
| 2188 | hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"), |
| 2189 | (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable); |
| 2190 | hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"), |
| 2191 | pConfig->protEnabled, pConfig->obssProtEnabled); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2192 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2193 | if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2194 | { |
| 2195 | //Bss already started. just return. |
| 2196 | //TODO Probably it should update some beacon params. |
| 2197 | hddLog( LOGE, "Bss Already started...Ignore the request"); |
| 2198 | EXIT(); |
| 2199 | return 0; |
| 2200 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2201 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2202 | pConfig->persona = pHostapdAdapter->device_mode; |
| 2203 | |
| 2204 | pSapEventCallback = hdd_hostapd_SAPEventCB; |
| 2205 | if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig, |
| 2206 | (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS) |
| 2207 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2208 | hddLog(LOGE,FL("SAP Start Bss fail")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2209 | return -EINVAL; |
| 2210 | } |
| 2211 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2212 | hddLog(LOG1, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2213 | FL("Waiting for Scan to complete(auto mode) and BSS to start")); |
| 2214 | |
| 2215 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2216 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2217 | if (!VOS_IS_STATUS_SUCCESS(status)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2218 | { |
| 2219 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2220 | ("ERROR: HDD vos wait for single_event failed!!")); |
Tushnim Bhattacharyya | ad37df1 | 2013-10-02 12:01:33 -0700 | [diff] [blame] | 2221 | smeGetCommandQStatus(hHal); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2222 | VOS_ASSERT(0); |
| 2223 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2224 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2225 | //Succesfully started Bss update the state bit. |
| 2226 | set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags); |
| 2227 | |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2228 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2229 | if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO) |
| 2230 | { |
| 2231 | if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) |
| 2232 | { |
| 2233 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2234 | hddLog(LOGE,"[P2P State] From Go nego completed to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2235 | "Non-autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2236 | } |
| 2237 | else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE) |
| 2238 | { |
| 2239 | globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE; |
| 2240 | hddLog(LOGE,"[P2P State] From Inactive to " |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 2241 | "Autonomous Group started"); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2242 | } |
| 2243 | } |
| 2244 | #endif |
| 2245 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2246 | pHostapdState->bCommit = TRUE; |
| 2247 | EXIT(); |
| 2248 | |
| 2249 | return 0; |
| 2250 | } |
| 2251 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2252 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2253 | static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy, |
| 2254 | struct net_device *dev, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2255 | struct beacon_parameters *params) |
| 2256 | { |
| 2257 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2258 | hdd_context_t *pHddCtx; |
| 2259 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2260 | |
| 2261 | ENTER(); |
| 2262 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2263 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d",pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2264 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2265 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2266 | status = wlan_hdd_validate_context(pHddCtx); |
| 2267 | |
| 2268 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2269 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2270 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2271 | "%s: HDD context is not valid", __func__); |
| 2272 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2273 | } |
| 2274 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2275 | if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2276 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2277 | ) |
| 2278 | { |
| 2279 | beacon_data_t *old,*new; |
| 2280 | |
| 2281 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2282 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2283 | if (old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2284 | { |
| 2285 | hddLog(VOS_TRACE_LEVEL_WARN, |
| 2286 | FL("already beacon info added to session(%d)"), |
| 2287 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2288 | return -EALREADY; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2289 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2290 | |
| 2291 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2292 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2293 | if(status != VOS_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2294 | { |
| 2295 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2296 | "%s:Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2297 | return -EINVAL; |
| 2298 | } |
| 2299 | |
| 2300 | pAdapter->sessionCtx.ap.beacon = new; |
| 2301 | |
| 2302 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2303 | } |
| 2304 | |
| 2305 | EXIT(); |
| 2306 | return status; |
| 2307 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2308 | |
| 2309 | static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2310 | struct net_device *dev, |
| 2311 | struct beacon_parameters *params) |
| 2312 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2313 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2314 | hdd_context_t *pHddCtx; |
| 2315 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2316 | |
| 2317 | ENTER(); |
| 2318 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2319 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2320 | __func__,pAdapter->device_mode); |
| 2321 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2322 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2323 | status = wlan_hdd_validate_context(pHddCtx); |
| 2324 | |
| 2325 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2326 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2327 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2328 | "%s: HDD context is not valid", __func__); |
| 2329 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2330 | } |
| 2331 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2332 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2333 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2334 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2335 | { |
| 2336 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2337 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2338 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2339 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2340 | if (!old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2341 | { |
| 2342 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2343 | FL("session(%d) old and new heads points to NULL"), |
| 2344 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2345 | return -ENOENT; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2346 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2347 | |
| 2348 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params); |
| 2349 | |
| 2350 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2351 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2352 | "%s: Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2353 | return -EINVAL; |
| 2354 | } |
| 2355 | |
| 2356 | pAdapter->sessionCtx.ap.beacon = new; |
| 2357 | |
| 2358 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params); |
| 2359 | } |
| 2360 | |
| 2361 | EXIT(); |
| 2362 | return status; |
| 2363 | } |
| 2364 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2365 | #endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 2366 | |
| 2367 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2368 | static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy, |
| 2369 | struct net_device *dev) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2370 | #else |
| 2371 | static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy, |
| 2372 | struct net_device *dev) |
| 2373 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2374 | { |
| 2375 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2376 | hdd_context_t *pHddCtx = NULL; |
| 2377 | hdd_scaninfo_t *pScanInfo = NULL; |
| 2378 | hdd_adapter_t *staAdapter = NULL; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2379 | VOS_STATUS status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2380 | |
| 2381 | ENTER(); |
| 2382 | |
| 2383 | if (NULL == pAdapter) |
| 2384 | { |
| 2385 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 2386 | "%s: HDD adapter context is Null", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2387 | return -ENODEV; |
| 2388 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2389 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2390 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2391 | status = wlan_hdd_validate_context(pHddCtx); |
| 2392 | |
| 2393 | if (0 != status) |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2394 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2395 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2396 | "%s: HDD context is not valid", __func__); |
| 2397 | return status; |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2398 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2399 | |
| 2400 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION); |
| 2401 | if (NULL == staAdapter) |
| 2402 | { |
| 2403 | staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT); |
| 2404 | if (NULL == staAdapter) |
| 2405 | { |
Rajesh Chauhan | 52d885b | 2013-11-01 10:54:25 -0700 | [diff] [blame] | 2406 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 2407 | "%s: HDD adapter context for STA/P2P-CLI is Null", |
| 2408 | __func__); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 2409 | } |
| 2410 | } |
| 2411 | |
| 2412 | pScanInfo = &pHddCtx->scan_info; |
| 2413 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2414 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2415 | __func__,pAdapter->device_mode); |
| 2416 | |
Rajesh Chauhan | 52d885b | 2013-11-01 10:54:25 -0700 | [diff] [blame] | 2417 | if ((pScanInfo != NULL) && pScanInfo->mScanPending && staAdapter) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2418 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2419 | long ret; |
| 2420 | |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2421 | INIT_COMPLETION(pScanInfo->abortscan_event_var); |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 2422 | hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId, |
| 2423 | eCSR_SCAN_ABORT_DEFAULT); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2424 | ret = wait_for_completion_interruptible_timeout( |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 2425 | &pScanInfo->abortscan_event_var, |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2426 | msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2427 | if (ret <= 0) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2428 | { |
Rajesh Chauhan | 52d885b | 2013-11-01 10:54:25 -0700 | [diff] [blame] | 2429 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2430 | FL("Timeout occurred while waiting for abortscan %ld"), |
| 2431 | ret); |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 2432 | |
| 2433 | if (pHddCtx->isLogpInProgress) |
| 2434 | { |
| 2435 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2436 | "%s: LOGP in Progress. Ignore!!!", __func__); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2437 | |
| 2438 | VOS_ASSERT(pScanInfo->mScanPending); |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 2439 | return -EAGAIN; |
| 2440 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2441 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2442 | } |
| 2443 | } |
| 2444 | |
Arun Kumar Khandavalli | a3bd800 | 2014-01-17 16:21:19 +0530 | [diff] [blame] | 2445 | hdd_hostapd_stop(dev); |
| 2446 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2447 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2448 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2449 | ) |
| 2450 | { |
| 2451 | beacon_data_t *old; |
| 2452 | |
| 2453 | old = pAdapter->sessionCtx.ap.beacon; |
| 2454 | |
| 2455 | if (!old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2456 | { |
| 2457 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2458 | FL("session(%d) beacon data points to NULL"), |
| 2459 | pAdapter->sessionId); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2460 | return -ENOENT; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2461 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2462 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2463 | hdd_cleanup_actionframe(pHddCtx, pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2464 | |
| 2465 | mutex_lock(&pHddCtx->sap_lock); |
| 2466 | if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags)) |
| 2467 | { |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2468 | if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2469 | { |
| 2470 | hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 2471 | |
| 2472 | status = vos_wait_single_event(&pHostapdState->vosEvent, 10000); |
| 2473 | |
| 2474 | if (!VOS_IS_STATUS_SUCCESS(status)) |
| 2475 | { |
| 2476 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2477 | ("ERROR: HDD vos wait for single_event failed!!")); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2478 | VOS_ASSERT(0); |
| 2479 | } |
| 2480 | } |
| 2481 | clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags); |
| 2482 | } |
| 2483 | mutex_unlock(&pHddCtx->sap_lock); |
| 2484 | |
| 2485 | if(status != VOS_STATUS_SUCCESS) |
| 2486 | { |
| 2487 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2488 | "%s:Error!!! Stopping the BSS",__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2489 | return -EINVAL; |
| 2490 | } |
| 2491 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2492 | if (ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2493 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE) |
| 2494 | ==eHAL_STATUS_FAILURE) |
| 2495 | { |
| 2496 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2497 | "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2498 | } |
| 2499 | |
Jeff Johnson | 4416a78 | 2013-03-25 14:17:50 -0700 | [diff] [blame] | 2500 | if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2501 | WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL, |
| 2502 | eANI_BOOLEAN_FALSE) ) |
| 2503 | { |
| 2504 | hddLog(LOGE, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2505 | "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2506 | } |
| 2507 | |
| 2508 | // Reset WNI_CFG_PROBE_RSP Flags |
| 2509 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 2510 | |
| 2511 | pAdapter->sessionCtx.ap.beacon = NULL; |
| 2512 | kfree(old); |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 2513 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 2514 | if((pAdapter->device_mode == WLAN_HDD_P2P_GO) && |
| 2515 | (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE)) |
| 2516 | { |
| 2517 | hddLog(LOGE,"[P2P State] From GO completed to Inactive state " |
| 2518 | "GO got removed"); |
| 2519 | globalP2PConnectionStatus = P2P_NOT_ACTIVE; |
| 2520 | } |
| 2521 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2522 | } |
| 2523 | EXIT(); |
| 2524 | return status; |
| 2525 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2526 | |
| 2527 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2528 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2529 | static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy, |
| 2530 | struct net_device *dev, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2531 | struct cfg80211_ap_settings *params) |
| 2532 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2533 | hdd_adapter_t *pAdapter; |
| 2534 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2535 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2536 | |
| 2537 | ENTER(); |
| 2538 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2539 | if (NULL == dev) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2540 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2541 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2542 | "%s: Device is Null", __func__); |
| 2543 | return -ENODEV; |
| 2544 | } |
| 2545 | |
| 2546 | pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2547 | if (NULL == pAdapter) |
| 2548 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2549 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2550 | "%s: HDD adapter is Null", __func__); |
| 2551 | return -ENODEV; |
| 2552 | } |
| 2553 | |
| 2554 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) |
| 2555 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2556 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2557 | "%s: HDD adapter magic is invalid", __func__); |
| 2558 | return -ENODEV; |
| 2559 | } |
| 2560 | |
| 2561 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2562 | status = wlan_hdd_validate_context(pHddCtx); |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2563 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2564 | if (0 != status) |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2565 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2566 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2567 | "%s: HDD context is not valid", __func__); |
| 2568 | return status; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2569 | } |
| 2570 | |
| 2571 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d", |
| 2572 | __func__, pAdapter->device_mode); |
| 2573 | |
| 2574 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2575 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2576 | ) |
| 2577 | { |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2578 | beacon_data_t *old, *new; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2579 | |
| 2580 | old = pAdapter->sessionCtx.ap.beacon; |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2581 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2582 | if (old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2583 | { |
| 2584 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 2585 | FL("already beacon info added to session(%d)"), |
| 2586 | pAdapter->sessionId); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2587 | return -EALREADY; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2588 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2589 | |
| 2590 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, ¶ms->beacon, params->dtim_period); |
| 2591 | |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2592 | if (status != 0) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2593 | { |
| 2594 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Pratik Bhalgat | a0c7f26 | 2012-11-22 17:40:24 +0530 | [diff] [blame] | 2595 | "%s:Error!!! Allocating the new beacon", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2596 | return -EINVAL; |
| 2597 | } |
| 2598 | pAdapter->sessionCtx.ap.beacon = new; |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2599 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 2600 | wlan_hdd_cfg80211_set_channel(wiphy, dev, |
| 2601 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) |
| 2602 | params->channel, params->channel_type); |
| 2603 | #else |
| 2604 | params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef))); |
| 2605 | #endif |
Viral Modi | 3a32cc5 | 2013-02-08 11:14:52 -0800 | [diff] [blame] | 2606 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2607 | status = wlan_hdd_cfg80211_start_bss(pAdapter, ¶ms->beacon, params->ssid, |
| 2608 | params->ssid_len, params->hidden_ssid); |
| 2609 | } |
| 2610 | |
| 2611 | EXIT(); |
| 2612 | return status; |
| 2613 | } |
| 2614 | |
| 2615 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2616 | static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2617 | struct net_device *dev, |
| 2618 | struct cfg80211_beacon_data *params) |
| 2619 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2620 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2621 | hdd_context_t *pHddCtx; |
| 2622 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2623 | |
| 2624 | ENTER(); |
| 2625 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2626 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2627 | __func__, pAdapter->device_mode); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2628 | |
| 2629 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2630 | status = wlan_hdd_validate_context(pHddCtx); |
| 2631 | |
| 2632 | if (0 != status) |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2633 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2634 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2635 | "%s: HDD context is not valid", __func__); |
| 2636 | return status; |
Madan Mohan Koyyalamudi | b2c3689 | 2012-10-18 20:52:38 -0700 | [diff] [blame] | 2637 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2638 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2639 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2640 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2641 | ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2642 | { |
| 2643 | beacon_data_t *old,*new; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2644 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2645 | old = pAdapter->sessionCtx.ap.beacon; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2646 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2647 | if (!old) |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2648 | { |
| 2649 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2650 | FL("session(%d) beacon data points to NULL"), |
| 2651 | pAdapter->sessionId); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2652 | return -ENOENT; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2653 | } |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2654 | |
| 2655 | status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0); |
| 2656 | |
| 2657 | if(status != VOS_STATUS_SUCCESS) { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2658 | hddLog(VOS_TRACE_LEVEL_FATAL, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2659 | "%s: Error!!! Allocating the new beacon",__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 2660 | return -EINVAL; |
| 2661 | } |
| 2662 | |
| 2663 | pAdapter->sessionCtx.ap.beacon = new; |
| 2664 | |
| 2665 | status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0); |
| 2666 | } |
| 2667 | |
| 2668 | EXIT(); |
| 2669 | return status; |
| 2670 | } |
| 2671 | |
| 2672 | #endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0)) |
| 2673 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2674 | |
| 2675 | static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy, |
| 2676 | struct net_device *dev, |
| 2677 | struct bss_parameters *params) |
| 2678 | { |
| 2679 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2680 | |
| 2681 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2682 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2683 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2684 | __func__,pAdapter->device_mode); |
| 2685 | |
| 2686 | if((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2687 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2688 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2689 | { |
| 2690 | /* ap_isolate == -1 means that in change bss, upper layer doesn't |
| 2691 | * want to update this parameter */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2692 | if (-1 != params->ap_isolate) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2693 | { |
| 2694 | pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2695 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2696 | } |
| 2697 | |
| 2698 | EXIT(); |
| 2699 | return 0; |
| 2700 | } |
| 2701 | |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2702 | /* FUNCTION: wlan_hdd_change_country_code_cd |
| 2703 | * to wait for contry code completion |
| 2704 | */ |
| 2705 | void* wlan_hdd_change_country_code_cb(void *pAdapter) |
| 2706 | { |
| 2707 | hdd_adapter_t *call_back_pAdapter = pAdapter; |
| 2708 | complete(&call_back_pAdapter->change_country_code); |
| 2709 | return NULL; |
| 2710 | } |
| 2711 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2712 | /* |
| 2713 | * FUNCTION: wlan_hdd_cfg80211_change_iface |
| 2714 | * This function is used to set the interface type (INFRASTRUCTURE/ADHOC) |
| 2715 | */ |
| 2716 | int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy, |
| 2717 | struct net_device *ndev, |
| 2718 | enum nl80211_iftype type, |
| 2719 | u32 *flags, |
| 2720 | struct vif_params *params |
| 2721 | ) |
| 2722 | { |
| 2723 | struct wireless_dev *wdev; |
| 2724 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 2725 | hdd_context_t *pHddCtx; |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2726 | hdd_adapter_t *pP2pAdapter = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2727 | tCsrRoamProfile *pRoamProfile = NULL; |
| 2728 | eCsrRoamBssType LastBSSType; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2729 | hdd_config_t *pConfig = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2730 | eMib_dot11DesiredBssType connectedBssType; |
| 2731 | VOS_STATUS status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2732 | long ret; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2733 | |
| 2734 | ENTER(); |
| 2735 | |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 2736 | if (!pAdapter) |
| 2737 | { |
| 2738 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2739 | "%s: Adapter context is null", __func__); |
| 2740 | return VOS_STATUS_E_FAILURE; |
| 2741 | } |
| 2742 | |
| 2743 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 2744 | if (!pHddCtx) |
| 2745 | { |
| 2746 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2747 | "%s: HDD context is null", __func__); |
| 2748 | return VOS_STATUS_E_FAILURE; |
| 2749 | } |
| 2750 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2751 | status = wlan_hdd_validate_context(pHddCtx); |
| 2752 | |
| 2753 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2754 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2755 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2756 | "%s: HDD context is not valid", __func__); |
| 2757 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2758 | } |
| 2759 | |
| 2760 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 2761 | __func__, pAdapter->device_mode); |
| 2762 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 2763 | pConfig = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2764 | wdev = ndev->ieee80211_ptr; |
| 2765 | |
| 2766 | #ifdef WLAN_BTAMP_FEATURE |
| 2767 | if((NL80211_IFTYPE_P2P_CLIENT == type)|| |
| 2768 | (NL80211_IFTYPE_ADHOC == type)|| |
| 2769 | (NL80211_IFTYPE_AP == type)|| |
| 2770 | (NL80211_IFTYPE_P2P_GO == type)) |
| 2771 | { |
| 2772 | pHddCtx->isAmpAllowed = VOS_FALSE; |
| 2773 | // stop AMP traffic |
| 2774 | status = WLANBAP_StopAmp(); |
| 2775 | if(VOS_STATUS_SUCCESS != status ) |
| 2776 | { |
| 2777 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 2778 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2779 | "%s: Failed to stop AMP", __func__); |
| 2780 | return -EINVAL; |
| 2781 | } |
| 2782 | } |
| 2783 | #endif //WLAN_BTAMP_FEATURE |
| 2784 | /* Reset the current device mode bit mask*/ |
| 2785 | wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode); |
| 2786 | |
| 2787 | if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2788 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2789 | || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2790 | ) |
| 2791 | { |
| 2792 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 2793 | if (!pWextState) |
| 2794 | { |
| 2795 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2796 | "%s: pWextState is null", __func__); |
| 2797 | return VOS_STATUS_E_FAILURE; |
| 2798 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2799 | pRoamProfile = &pWextState->roamProfile; |
| 2800 | LastBSSType = pRoamProfile->BSSType; |
| 2801 | |
| 2802 | switch (type) |
| 2803 | { |
| 2804 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2805 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2806 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2807 | "%s: setting interface Type to INFRASTRUCTURE", __func__); |
| 2808 | pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2809 | #ifdef WLAN_FEATURE_11AC |
| 2810 | if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO) |
| 2811 | { |
| 2812 | pConfig->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 2813 | } |
| 2814 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2815 | pRoamProfile->phyMode = |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 2816 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2817 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2818 | //Check for sub-string p2p to confirm its a p2p interface |
| 2819 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2820 | { |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2821 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 2822 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 2823 | } |
| 2824 | else |
| 2825 | { |
| 2826 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2827 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 2828 | } |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 2829 | #ifdef FEATURE_WLAN_TDLS |
| 2830 | /* The open adapter for the p2p shall skip initializations in |
| 2831 | * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for |
| 2832 | * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke |
| 2833 | * tdls_init when the change_iface sets the device mode to |
| 2834 | * WLAN_HDD_P2P_CLIENT. |
| 2835 | */ |
| 2836 | |
| 2837 | if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
| 2838 | { |
| 2839 | if (0 != wlan_hdd_tdls_init (pAdapter)) |
| 2840 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2841 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 2842 | "%s: tdls initialization failed", __func__); |
Madan Mohan Koyyalamudi | 8174692 | 2013-07-17 14:38:51 +0530 | [diff] [blame] | 2843 | return -EINVAL; |
| 2844 | } |
| 2845 | } |
| 2846 | #endif |
| 2847 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2848 | break; |
| 2849 | case NL80211_IFTYPE_ADHOC: |
| 2850 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 2851 | "%s: setting interface Type to ADHOC", __func__); |
| 2852 | pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS; |
| 2853 | pRoamProfile->phyMode = |
| 2854 | hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode); |
Shailender Karmuchi | a734f33 | 2013-04-19 14:02:48 -0700 | [diff] [blame] | 2855 | pAdapter->device_mode = WLAN_HDD_IBSS; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2856 | wdev->iftype = type; |
| 2857 | break; |
| 2858 | |
| 2859 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2860 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2861 | { |
| 2862 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 2863 | "%s: setting interface Type to %s", __func__, |
| 2864 | (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo"); |
| 2865 | |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 2866 | //Cancel any remain on channel for GO mode |
| 2867 | if (NL80211_IFTYPE_P2P_GO == type) |
| 2868 | { |
| 2869 | wlan_hdd_cancel_existing_remain_on_channel(pAdapter); |
| 2870 | } |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2871 | if (NL80211_IFTYPE_AP == type) |
| 2872 | { |
| 2873 | /* As Loading WLAN Driver one interface being created for p2p device |
| 2874 | * address. This will take one HW STA and the max number of clients |
| 2875 | * that can connect to softAP will be reduced by one. so while changing |
| 2876 | * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0 |
| 2877 | * interface as it is not required in SoftAP mode. |
| 2878 | */ |
| 2879 | |
| 2880 | // Get P2P Adapter |
| 2881 | pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE); |
| 2882 | |
| 2883 | if (pP2pAdapter) |
| 2884 | { |
| 2885 | hdd_stop_adapter(pHddCtx, pP2pAdapter); |
| 2886 | hdd_deinit_adapter(pHddCtx, pP2pAdapter); |
| 2887 | hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE); |
| 2888 | } |
| 2889 | } |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2890 | #ifdef FEATURE_WLAN_TDLS |
Mohit Khanna | 0f23209 | 2012-09-11 14:46:08 -0700 | [diff] [blame] | 2891 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2892 | /* A Mutex Lock is introduced while changing the mode to |
| 2893 | * protect the concurrent access for the Adapters by TDLS |
| 2894 | * module. |
| 2895 | */ |
| 2896 | if (mutex_lock_interruptible(&pHddCtx->tdls_lock)) |
| 2897 | { |
| 2898 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2899 | "%s: unable to lock list", __func__); |
| 2900 | return -EINVAL; |
| 2901 | } |
| 2902 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2903 | //De-init the adapter. |
| 2904 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 2905 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
| 2906 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2907 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 2908 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 2909 | #ifdef FEATURE_WLAN_TDLS |
| 2910 | mutex_unlock(&pHddCtx->tdls_lock); |
| 2911 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2912 | |
| 2913 | //Disable BMPS and IMPS if enabled |
| 2914 | //before starting Go |
| 2915 | if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 2916 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 2917 | if(VOS_STATUS_E_FAILURE == |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2918 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO)) |
| 2919 | { |
| 2920 | //Fail to Exit BMPS |
| 2921 | VOS_ASSERT(0); |
| 2922 | } |
| 2923 | } |
| 2924 | |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2925 | if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) && |
| 2926 | (pConfig->apRandomBssidEnabled)) |
| 2927 | { |
| 2928 | /* To meet Android requirements create a randomized |
| 2929 | MAC address of the form 02:1A:11:Fx:xx:xx */ |
| 2930 | get_random_bytes(&ndev->dev_addr[3], 3); |
| 2931 | ndev->dev_addr[0] = 0x02; |
| 2932 | ndev->dev_addr[1] = 0x1A; |
| 2933 | ndev->dev_addr[2] = 0x11; |
| 2934 | ndev->dev_addr[3] |= 0xF0; |
| 2935 | memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr, |
| 2936 | VOS_MAC_ADDR_SIZE); |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 2937 | pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n", |
| 2938 | MAC_ADDR_ARRAY(ndev->dev_addr)); |
Madan Mohan Koyyalamudi | 3ff2a0b | 2012-10-15 14:33:46 -0700 | [diff] [blame] | 2939 | } |
| 2940 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2941 | hdd_set_ap_ops( pAdapter->dev ); |
| 2942 | |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2943 | /* This is for only SAP mode where users can |
| 2944 | * control country through ini. |
| 2945 | * P2P GO follows station country code |
| 2946 | * acquired during the STA scanning. */ |
| 2947 | if((NL80211_IFTYPE_AP == type) && |
| 2948 | (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)) |
| 2949 | { |
| 2950 | int status = 0; |
| 2951 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO, |
| 2952 | "%s: setting country code from INI ", __func__); |
| 2953 | init_completion(&pAdapter->change_country_code); |
| 2954 | status = (int)sme_ChangeCountryCode(pHddCtx->hHal, |
| 2955 | (void *)(tSmeChangeCountryCallback) |
| 2956 | wlan_hdd_change_country_code_cb, |
| 2957 | pConfig->apCntryCode, pAdapter, |
| 2958 | pHddCtx->pvosContext, |
Abhishek Singh | a306a44 | 2013-11-07 18:39:01 +0530 | [diff] [blame] | 2959 | eSIR_FALSE, |
| 2960 | eSIR_TRUE); |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2961 | if (eHAL_STATUS_SUCCESS == status) |
| 2962 | { |
| 2963 | /* Wait for completion */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2964 | ret = wait_for_completion_interruptible_timeout( |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2965 | &pAdapter->change_country_code, |
| 2966 | msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2967 | if (ret <= 0) |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2968 | { |
| 2969 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 2970 | FL("SME Timed out while setting country code %ld"), |
| 2971 | ret); |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 2972 | |
| 2973 | if (pHddCtx->isLogpInProgress) |
| 2974 | { |
| 2975 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 2976 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 2977 | return -EAGAIN; |
| 2978 | } |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2979 | } |
| 2980 | } |
| 2981 | else |
| 2982 | { |
| 2983 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 2984 | "%s: SME Change Country code failed",__func__); |
Kiet Lam | 1084136 | 2013-11-01 11:36:50 +0530 | [diff] [blame] | 2985 | return -EINVAL; |
| 2986 | } |
| 2987 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2988 | status = hdd_init_ap_mode(pAdapter); |
| 2989 | if(status != VOS_STATUS_SUCCESS) |
| 2990 | { |
| 2991 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 2992 | "%s: Error initializing the ap mode", __func__); |
| 2993 | return -EINVAL; |
| 2994 | } |
| 2995 | hdd_set_conparam(1); |
| 2996 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 2997 | /*interface type changed update in wiphy structure*/ |
| 2998 | if(wdev) |
| 2999 | { |
| 3000 | wdev->iftype = type; |
| 3001 | pHddCtx->change_iface = type; |
| 3002 | } |
| 3003 | else |
| 3004 | { |
| 3005 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3006 | "%s: ERROR !!!! Wireless dev is NULL", __func__); |
| 3007 | return -EINVAL; |
| 3008 | } |
| 3009 | goto done; |
| 3010 | } |
| 3011 | |
| 3012 | default: |
| 3013 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 3014 | __func__); |
| 3015 | return -EOPNOTSUPP; |
| 3016 | } |
| 3017 | } |
| 3018 | else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3019 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3020 | ) |
| 3021 | { |
| 3022 | switch(type) |
| 3023 | { |
| 3024 | case NL80211_IFTYPE_STATION: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3025 | case NL80211_IFTYPE_P2P_CLIENT: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3026 | case NL80211_IFTYPE_ADHOC: |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 3027 | #ifdef FEATURE_WLAN_TDLS |
| 3028 | |
| 3029 | /* A Mutex Lock is introduced while changing the mode to |
| 3030 | * protect the concurrent access for the Adapters by TDLS |
| 3031 | * module. |
| 3032 | */ |
| 3033 | if (mutex_lock_interruptible(&pHddCtx->tdls_lock)) |
| 3034 | { |
| 3035 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3036 | "%s: unable to lock list", __func__); |
| 3037 | return -EINVAL; |
| 3038 | } |
| 3039 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 3040 | hdd_stop_adapter( pHddCtx, pAdapter ); |
| 3041 | hdd_deinit_adapter( pHddCtx, pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3042 | wdev->iftype = type; |
Gopichand Nakkala | f527dc6 | 2012-12-31 16:35:10 -0800 | [diff] [blame] | 3043 | //Check for sub-string p2p to confirm its a p2p interface |
| 3044 | if (NULL != strstr(ndev->name,"p2p")) |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 3045 | { |
| 3046 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
| 3047 | WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT; |
| 3048 | } |
| 3049 | else |
| 3050 | { |
| 3051 | pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ? |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3052 | WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT; |
Gopichand Nakkala | 864d355 | 2012-12-31 16:08:51 -0800 | [diff] [blame] | 3053 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3054 | hdd_set_conparam(0); |
| 3055 | pHddCtx->change_iface = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3056 | memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx)); |
| 3057 | hdd_set_station_ops( pAdapter->dev ); |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 3058 | #ifdef FEATURE_WLAN_TDLS |
| 3059 | mutex_unlock(&pHddCtx->tdls_lock); |
| 3060 | #endif |
Sunil Dutt | 66485cb | 2013-12-19 19:05:03 +0530 | [diff] [blame] | 3061 | status = hdd_init_station_mode( pAdapter ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3062 | if( VOS_STATUS_SUCCESS != status ) |
| 3063 | return -EOPNOTSUPP; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3064 | /* In case of JB, for P2P-GO, only change interface will be called, |
| 3065 | * This is the right place to enable back bmps_imps() |
| 3066 | */ |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 3067 | if (pHddCtx->hdd_wlan_suspended) |
| 3068 | { |
| 3069 | hdd_set_pwrparams(pHddCtx); |
| 3070 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3071 | hdd_enable_bmps_imps(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3072 | goto done; |
| 3073 | case NL80211_IFTYPE_AP: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3074 | case NL80211_IFTYPE_P2P_GO: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3075 | wdev->iftype = type; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3076 | pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ? |
| 3077 | WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3078 | goto done; |
| 3079 | default: |
| 3080 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type", |
| 3081 | __func__); |
| 3082 | return -EOPNOTSUPP; |
| 3083 | |
| 3084 | } |
| 3085 | |
| 3086 | } |
| 3087 | else |
| 3088 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3089 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%d)", |
| 3090 | __func__, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3091 | return -EOPNOTSUPP; |
| 3092 | } |
| 3093 | |
| 3094 | |
| 3095 | if(pRoamProfile) |
| 3096 | { |
| 3097 | if ( LastBSSType != pRoamProfile->BSSType ) |
| 3098 | { |
| 3099 | /*interface type changed update in wiphy structure*/ |
| 3100 | wdev->iftype = type; |
| 3101 | |
| 3102 | /*the BSS mode changed, We need to issue disconnect |
| 3103 | if connected or in IBSS disconnect state*/ |
| 3104 | if ( hdd_connGetConnectedBssType( |
| 3105 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) || |
| 3106 | ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) ) |
| 3107 | { |
| 3108 | /*need to issue a disconnect to CSR.*/ |
| 3109 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 3110 | if( eHAL_STATUS_SUCCESS == |
| 3111 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3112 | pAdapter->sessionId, |
| 3113 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 3114 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3115 | ret = wait_for_completion_interruptible_timeout( |
| 3116 | &pAdapter->disconnect_comp_var, |
| 3117 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 3118 | if (ret <= 0) |
| 3119 | { |
| 3120 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3121 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 3122 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3123 | } |
| 3124 | } |
| 3125 | } |
| 3126 | } |
| 3127 | |
| 3128 | done: |
| 3129 | /*set bitmask based on updated value*/ |
| 3130 | wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode); |
Leo Chang | 6fe1f92 | 2013-06-07 19:21:24 -0700 | [diff] [blame] | 3131 | |
| 3132 | /* Only STA mode support TM now |
| 3133 | * all other mode, TM feature should be disabled */ |
| 3134 | if ( (pHddCtx->cfg_ini->thermalMitigationEnable) && |
| 3135 | (~VOS_STA & pHddCtx->concurrency_mode) ) |
| 3136 | { |
| 3137 | hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0); |
| 3138 | } |
| 3139 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3140 | #ifdef WLAN_BTAMP_FEATURE |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3141 | if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3142 | (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1)) |
| 3143 | { |
| 3144 | //we are ok to do AMP |
| 3145 | pHddCtx->isAmpAllowed = VOS_TRUE; |
| 3146 | } |
| 3147 | #endif //WLAN_BTAMP_FEATURE |
| 3148 | EXIT(); |
| 3149 | return 0; |
| 3150 | } |
| 3151 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3152 | #ifdef FEATURE_WLAN_TDLS |
| 3153 | static int wlan_hdd_tdls_add_station(struct wiphy *wiphy, |
| 3154 | struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams) |
| 3155 | { |
| 3156 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 3157 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 3158 | VOS_STATUS status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3159 | hddTdlsPeer_t *pTdlsPeer; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3160 | long ret; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3161 | |
| 3162 | ENTER(); |
| 3163 | |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3164 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3165 | { |
| 3166 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3167 | "Invalid arguments"); |
| 3168 | return -EINVAL; |
| 3169 | } |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 3170 | |
| 3171 | if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) || |
| 3172 | (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)) |
| 3173 | { |
| 3174 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3175 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 3176 | MAC_ADDRESS_STR " Request declined.", |
| 3177 | __func__, MAC_ADDR_ARRAY(mac)); |
| 3178 | return -ENOTSUPP; |
| 3179 | } |
| 3180 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3181 | if (pHddCtx->isLogpInProgress) |
| 3182 | { |
| 3183 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3184 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3185 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3186 | return -EBUSY; |
| 3187 | } |
| 3188 | |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 3189 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3190 | |
| 3191 | if ( NULL == pTdlsPeer ) { |
| 3192 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3193 | "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid", |
| 3194 | __func__, MAC_ADDR_ARRAY(mac), update); |
| 3195 | return -EINVAL; |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3196 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3197 | |
| 3198 | /* in add station, we accept existing valid staId if there is */ |
| 3199 | if ((0 == update) && |
| 3200 | ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) || |
| 3201 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3202 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3203 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3204 | "%s: " MAC_ADDRESS_STR |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3205 | " link_status %d. staId %d. add station ignored.", |
| 3206 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId); |
| 3207 | return 0; |
| 3208 | } |
| 3209 | /* in change station, we accept only when staId is valid */ |
| 3210 | if ((1 == update) && |
| 3211 | ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) || |
| 3212 | (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)))) |
| 3213 | { |
| 3214 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3215 | "%s: " MAC_ADDRESS_STR |
| 3216 | " link status %d. staId %d. change station %s.", |
| 3217 | __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId, |
| 3218 | (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined"); |
| 3219 | return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3220 | } |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3221 | |
| 3222 | /* when others are on-going, we want to change link_status to idle */ |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 3223 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3224 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3225 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3226 | "%s: " MAC_ADDRESS_STR |
| 3227 | " TDLS setup is ongoing. Request declined.", |
| 3228 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3229 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3230 | } |
| 3231 | |
| 3232 | /* first to check if we reached to maximum supported TDLS peer. |
| 3233 | TODO: for now, return -EPERM looks working fine, |
| 3234 | but need to check if any other errno fit into this category.*/ |
| 3235 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
| 3236 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3237 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3238 | "%s: " MAC_ADDRESS_STR |
| 3239 | " TDLS Max peer already connected. Request declined.", |
| 3240 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3241 | goto error; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3242 | } |
| 3243 | else |
| 3244 | { |
| 3245 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 3246 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3247 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3248 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3249 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3250 | "%s: " MAC_ADDRESS_STR " already connected. Request declined.", |
| 3251 | __func__, MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3252 | return -EPERM; |
| 3253 | } |
| 3254 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3255 | if (0 == update) |
| 3256 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING); |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3257 | |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 3258 | /* debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3259 | if (NULL != StaParams) |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3260 | { |
| 3261 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3262 | "%s: TDLS Peer Parameters.", __func__); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3263 | if(StaParams->htcap_present) |
| 3264 | { |
| 3265 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3266 | "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo); |
| 3267 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3268 | "ht_capa->extended_capabilities: %0x", |
| 3269 | StaParams->HTCap.extendedHtCapInfo); |
| 3270 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3271 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3272 | "params->capability: %0x",StaParams->capability); |
| 3273 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 3274 | "params->ext_capab_len: %0x",StaParams->extn_capability[0]); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3275 | if(StaParams->vhtcap_present) |
| 3276 | { |
| 3277 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3278 | "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x", |
| 3279 | StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest, |
| 3280 | StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest); |
| 3281 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3282 | { |
| 3283 | int i = 0; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3284 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:"); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3285 | for (i = 0; i < sizeof(StaParams->supported_rates); i++) |
| 3286 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 3287 | "[%d]: %x ", i, StaParams->supported_rates[i]); |
| 3288 | } |
Jeff Johnson | d75fe01 | 2013-04-06 10:53:06 -0700 | [diff] [blame] | 3289 | } /* end debug code */ |
Gopichand Nakkala | 838be5d | 2013-04-10 22:41:51 +0530 | [diff] [blame] | 3290 | else if ((1 == update) && (NULL == StaParams)) |
| 3291 | { |
| 3292 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3293 | "%s : update is true, but staParams is NULL. Error!", __func__); |
| 3294 | return -EPERM; |
| 3295 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3296 | |
| 3297 | INIT_COMPLETION(pAdapter->tdls_add_station_comp); |
| 3298 | |
| 3299 | if (!update) |
| 3300 | { |
| 3301 | status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3302 | pAdapter->sessionId, mac); |
| 3303 | } |
| 3304 | else |
| 3305 | { |
| 3306 | status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3307 | pAdapter->sessionId, mac, StaParams); |
| 3308 | } |
| 3309 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3310 | ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3311 | msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA)); |
| 3312 | |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3313 | if (ret <= 0) |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3314 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3315 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3316 | "%s: timeout waiting for tdls add station indication %ld", |
| 3317 | __func__, ret); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3318 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3319 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3320 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3321 | if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus) |
| 3322 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 3323 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3324 | "%s: Add Station is unsucessful", __func__); |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 3325 | return -EPERM; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3326 | } |
| 3327 | |
| 3328 | return 0; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 3329 | |
| 3330 | error: |
| 3331 | wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE); |
| 3332 | return -EPERM; |
| 3333 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3334 | } |
| 3335 | #endif |
| 3336 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3337 | static int wlan_hdd_change_station(struct wiphy *wiphy, |
| 3338 | struct net_device *dev, |
| 3339 | u8 *mac, |
| 3340 | struct station_parameters *params) |
| 3341 | { |
| 3342 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 3343 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3344 | hdd_context_t *pHddCtx; |
| 3345 | hdd_station_ctx_t *pHddStaCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3346 | v_MACADDR_t STAMacAddress; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3347 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3348 | tCsrStaParams StaParams = {0}; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3349 | tANI_U8 isBufSta = 0; |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 3350 | tANI_U8 isOffChannelSupported = 0; |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3351 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3352 | ENTER(); |
| 3353 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3354 | if ((NULL == pAdapter)) |
| 3355 | { |
| 3356 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3357 | "invalid adapter "); |
| 3358 | return -EINVAL; |
| 3359 | } |
| 3360 | |
| 3361 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3362 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3363 | |
| 3364 | if ((NULL == pHddCtx) || (NULL == pHddStaCtx)) |
| 3365 | { |
| 3366 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 3367 | "invalid HDD state or HDD station context"); |
| 3368 | return -EINVAL; |
| 3369 | } |
| 3370 | |
| 3371 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3372 | { |
| 3373 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3374 | "%s:LOGP in Progress. Ignore!!!", __func__); |
| 3375 | return -EAGAIN; |
| 3376 | } |
| 3377 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3378 | vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t)); |
| 3379 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3380 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
| 3381 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3382 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3383 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3384 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3385 | status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3386 | WLANTL_STA_AUTHENTICATED); |
| 3387 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3388 | if (status != VOS_STATUS_SUCCESS) |
| 3389 | { |
| 3390 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3391 | "%s: Not able to change TL state to AUTHENTICATED", __func__); |
| 3392 | return -EINVAL; |
| 3393 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3394 | } |
| 3395 | } |
Hoonki Lee | a6d49be | 2013-04-05 09:43:25 -0700 | [diff] [blame] | 3396 | else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
| 3397 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3398 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3399 | if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 3400 | StaParams.capability = params->capability; |
| 3401 | StaParams.uapsd_queues = params->uapsd_queues; |
| 3402 | StaParams.max_sp = params->max_sp; |
| 3403 | |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 3404 | /* Convert (first channel , number of channels) tuple to |
| 3405 | * the total list of channels. This goes with the assumption |
| 3406 | * that if the first channel is < 14, then the next channels |
| 3407 | * are an incremental of 1 else an incremental of 4 till the number |
| 3408 | * of channels. |
| 3409 | */ |
| 3410 | if (0 != params->supported_channels_len) { |
| 3411 | int i = 0,j = 0,k = 0, no_of_channels = 0 ; |
| 3412 | for ( i = 0 ; i < params->supported_channels_len ; i+=2) |
| 3413 | { |
| 3414 | int wifi_chan_index; |
| 3415 | StaParams.supported_channels[j] = params->supported_channels[i]; |
| 3416 | wifi_chan_index = |
| 3417 | ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 ); |
| 3418 | no_of_channels = params->supported_channels[i+1]; |
| 3419 | for(k=1; k <= no_of_channels; k++) |
| 3420 | { |
| 3421 | StaParams.supported_channels[j+1] = |
| 3422 | StaParams.supported_channels[j] + wifi_chan_index; |
| 3423 | j+=1; |
| 3424 | } |
| 3425 | } |
| 3426 | StaParams.supported_channels_len = j; |
| 3427 | } |
| 3428 | vos_mem_copy(StaParams.supported_oper_classes, |
| 3429 | params->supported_oper_classes, |
| 3430 | params->supported_oper_classes_len); |
| 3431 | StaParams.supported_oper_classes_len = |
| 3432 | params->supported_oper_classes_len; |
| 3433 | |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3434 | if (0 != params->ext_capab_len) |
| 3435 | vos_mem_copy(StaParams.extn_capability, params->ext_capab, |
| 3436 | sizeof(StaParams.extn_capability)); |
| 3437 | |
| 3438 | if (NULL != params->ht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3439 | { |
| 3440 | StaParams.htcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3441 | vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3442 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3443 | |
| 3444 | StaParams.supported_rates_len = params->supported_rates_len; |
| 3445 | |
| 3446 | /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32. |
| 3447 | * The supported_rates array , for all the structures propogating till Add Sta |
| 3448 | * to the firmware has to be modified , if the supplicant (ieee80211) is |
| 3449 | * modified to send more rates. |
| 3450 | */ |
| 3451 | |
| 3452 | /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES |
| 3453 | */ |
| 3454 | if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES) |
| 3455 | StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES; |
| 3456 | |
| 3457 | if (0 != StaParams.supported_rates_len) { |
| 3458 | int i = 0; |
| 3459 | vos_mem_copy(StaParams.supported_rates, params->supported_rates, |
| 3460 | StaParams.supported_rates_len); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3461 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3462 | "Supported Rates with Length %d", StaParams.supported_rates_len); |
| 3463 | for (i=0; i < StaParams.supported_rates_len; i++) |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 3464 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3465 | "[%d]: %0x", i, StaParams.supported_rates[i]); |
| 3466 | } |
| 3467 | |
| 3468 | if (NULL != params->vht_capa) |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3469 | { |
| 3470 | StaParams.vhtcap_present = 1; |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3471 | vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap)); |
Hoonki Lee | 66b75f3 | 2013-04-16 18:30:07 -0700 | [diff] [blame] | 3472 | } |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 3473 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3474 | if (0 != params->ext_capab_len ) { |
| 3475 | /*Define A Macro : TODO Sunil*/ |
| 3476 | if ((1<<4) & StaParams.extn_capability[3]) { |
| 3477 | isBufSta = 1; |
| 3478 | } |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 3479 | /* TDLS Channel Switching Support */ |
| 3480 | if ((1<<6) & StaParams.extn_capability[3]) { |
| 3481 | isOffChannelSupported = 1; |
| 3482 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3483 | } |
Naresh Jayaram | 3180aa4 | 2014-02-12 21:47:26 +0530 | [diff] [blame] | 3484 | status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, |
| 3485 | &StaParams, isBufSta, |
| 3486 | isOffChannelSupported); |
| 3487 | |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 3488 | if (VOS_STATUS_SUCCESS != status) { |
| 3489 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3490 | "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__); |
| 3491 | return -EINVAL; |
| 3492 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 3493 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams); |
| 3494 | |
| 3495 | if (VOS_STATUS_SUCCESS != status) { |
| 3496 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3497 | "%s: sme_ChangeTdlsPeerSta failed!", __func__); |
| 3498 | return -EINVAL; |
| 3499 | } |
| 3500 | } |
Gopichand Nakkala | b085622 | 2013-03-12 22:39:05 -0700 | [diff] [blame] | 3501 | #endif |
Gopichand Nakkala | 6239acd | 2013-06-14 14:48:00 +0530 | [diff] [blame] | 3502 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 3503 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3504 | return status; |
| 3505 | } |
| 3506 | |
| 3507 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3508 | * FUNCTION: wlan_hdd_cfg80211_add_key |
| 3509 | * This function is used to initialize the key information |
| 3510 | */ |
| 3511 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3512 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3513 | struct net_device *ndev, |
| 3514 | u8 key_index, bool pairwise, |
| 3515 | const u8 *mac_addr, |
| 3516 | struct key_params *params |
| 3517 | ) |
| 3518 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3519 | static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3520 | struct net_device *ndev, |
| 3521 | u8 key_index, const u8 *mac_addr, |
| 3522 | struct key_params *params |
| 3523 | ) |
| 3524 | #endif |
| 3525 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3526 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3527 | tCsrRoamSetKey setKey; |
| 3528 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3529 | int status; |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3530 | v_U32_t roamId= 0xFF; |
| 3531 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3532 | hdd_hostapd_state_t *pHostapdState; |
| 3533 | VOS_STATUS vos_status; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3534 | eHalStatus halStatus; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3535 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3536 | |
| 3537 | ENTER(); |
| 3538 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3539 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 3540 | status = wlan_hdd_validate_context(pHddCtx); |
| 3541 | |
| 3542 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3543 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 3544 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3545 | "%s: HDD context is not valid", __func__); |
| 3546 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 3547 | } |
| 3548 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3549 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
| 3550 | __func__, pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3551 | |
| 3552 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3553 | { |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3554 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3555 | key_index); |
| 3556 | |
| 3557 | return -EINVAL; |
| 3558 | } |
| 3559 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3560 | if (CSR_MAX_KEY_LEN < params->key_len) |
| 3561 | { |
| 3562 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__, |
| 3563 | params->key_len); |
| 3564 | |
| 3565 | return -EINVAL; |
| 3566 | } |
| 3567 | |
| 3568 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 3569 | "%s: called with key index = %d & key length %d", |
| 3570 | __func__, key_index, params->key_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3571 | |
| 3572 | /*extract key idx, key len and key*/ |
| 3573 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3574 | setKey.keyId = key_index; |
| 3575 | setKey.keyLength = params->key_len; |
| 3576 | vos_mem_copy(&setKey.Key[0],params->key, params->key_len); |
| 3577 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3578 | switch (params->cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3579 | { |
| 3580 | case WLAN_CIPHER_SUITE_WEP40: |
| 3581 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 3582 | break; |
| 3583 | |
| 3584 | case WLAN_CIPHER_SUITE_WEP104: |
| 3585 | setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY; |
| 3586 | break; |
| 3587 | |
| 3588 | case WLAN_CIPHER_SUITE_TKIP: |
| 3589 | { |
| 3590 | u8 *pKey = &setKey.Key[0]; |
| 3591 | setKey.encType = eCSR_ENCRYPT_TYPE_TKIP; |
| 3592 | |
| 3593 | vos_mem_zero(pKey, CSR_MAX_KEY_LEN); |
| 3594 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3595 | /*Supplicant sends the 32bytes key in this order |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3596 | |
| 3597 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3598 | | Tk1 |TX-MIC | RX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3599 | |--------------|----------|----------| |
| 3600 | <---16bytes---><--8bytes--><--8bytes--> |
| 3601 | |
| 3602 | */ |
| 3603 | /*Sme expects the 32 bytes key to be in the below order |
| 3604 | |
| 3605 | |--------------|----------|----------| |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3606 | | Tk1 |RX-MIC | TX Mic | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3607 | |--------------|----------|----------| |
| 3608 | <---16bytes---><--8bytes--><--8bytes--> |
| 3609 | */ |
| 3610 | /* Copy the Temporal Key 1 (TK1) */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3611 | vos_mem_copy(pKey, params->key, 16); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3612 | |
| 3613 | /*Copy the rx mic first*/ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3614 | vos_mem_copy(&pKey[16], ¶ms->key[24], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3615 | |
| 3616 | /*Copy the tx mic */ |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3617 | vos_mem_copy(&pKey[24], ¶ms->key[16], 8); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3618 | |
| 3619 | |
| 3620 | break; |
| 3621 | } |
| 3622 | |
| 3623 | case WLAN_CIPHER_SUITE_CCMP: |
| 3624 | setKey.encType = eCSR_ENCRYPT_TYPE_AES; |
| 3625 | break; |
| 3626 | |
| 3627 | #ifdef FEATURE_WLAN_WAPI |
| 3628 | case WLAN_CIPHER_SUITE_SMS4: |
| 3629 | { |
| 3630 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3631 | wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr, |
| 3632 | params->key, params->key_len); |
| 3633 | return 0; |
| 3634 | } |
| 3635 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3636 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3637 | #ifdef FEATURE_WLAN_CCX |
| 3638 | case WLAN_CIPHER_SUITE_KRK: |
| 3639 | setKey.encType = eCSR_ENCRYPT_TYPE_KRK; |
| 3640 | break; |
| 3641 | #endif |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3642 | |
| 3643 | #ifdef WLAN_FEATURE_11W |
| 3644 | case WLAN_CIPHER_SUITE_AES_CMAC: |
| 3645 | setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC; |
Chet Lanctot | 3b5158a | 2013-03-31 16:45:21 -0700 | [diff] [blame] | 3646 | break; |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 3647 | #endif |
| 3648 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3649 | default: |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 3650 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3651 | __func__, params->cipher); |
| 3652 | return -EOPNOTSUPP; |
| 3653 | } |
| 3654 | |
| 3655 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d", |
| 3656 | __func__, setKey.encType); |
| 3657 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3658 | if ( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3659 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3660 | (!pairwise) |
| 3661 | #else |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3662 | (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3663 | #endif |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3664 | ) |
| 3665 | { |
| 3666 | /* set group key*/ |
| 3667 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3668 | "%s- %d: setting Broadcast key", |
| 3669 | __func__, __LINE__); |
| 3670 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3671 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3672 | } |
| 3673 | else |
| 3674 | { |
| 3675 | /* set pairwise key*/ |
| 3676 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3677 | "%s- %d: setting pairwise key", |
| 3678 | __func__, __LINE__); |
| 3679 | setKey.keyDirection = eSIR_TX_RX; |
| 3680 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 3681 | } |
| 3682 | if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise) |
| 3683 | { |
| 3684 | setKey.keyDirection = eSIR_TX_RX; |
| 3685 | /*Set the group key*/ |
| 3686 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3687 | pAdapter->sessionId, &setKey, &roamId ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3688 | |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 3689 | if ( 0 != status ) |
| 3690 | { |
| 3691 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3692 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3693 | return -EINVAL; |
| 3694 | } |
| 3695 | /*Save the keys here and call sme_RoamSetKey for setting |
| 3696 | the PTK after peer joins the IBSS network*/ |
| 3697 | vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key, |
| 3698 | &setKey, sizeof(tCsrRoamSetKey)); |
| 3699 | return status; |
| 3700 | } |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 3701 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) || |
| 3702 | (pAdapter->device_mode == WLAN_HDD_P2P_GO)) |
| 3703 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3704 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3705 | if( pHostapdState->bssState == BSS_START ) |
| 3706 | { |
c_hpothu | 7c55da6 | 2014-01-23 18:34:02 +0530 | [diff] [blame] | 3707 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3708 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3709 | |
| 3710 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3711 | { |
| 3712 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3713 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3714 | __LINE__, vos_status ); |
| 3715 | |
| 3716 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3717 | |
| 3718 | return -EINVAL; |
| 3719 | } |
| 3720 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3721 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
| 3722 | |
| 3723 | if ( status != eHAL_STATUS_SUCCESS ) |
| 3724 | { |
| 3725 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3726 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 3727 | __LINE__, status ); |
| 3728 | } |
| 3729 | } |
| 3730 | |
| 3731 | /* Saving WEP keys */ |
| 3732 | else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType || |
| 3733 | eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType ) |
| 3734 | { |
| 3735 | //Save the wep key in ap context. Issue setkey after the BSS is started. |
| 3736 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 3737 | vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey)); |
| 3738 | } |
| 3739 | else |
| 3740 | { |
| 3741 | //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] | 3742 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3743 | vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey)); |
| 3744 | } |
| 3745 | } |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3746 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) || |
| 3747 | (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3748 | { |
| 3749 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3750 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 3751 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3752 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 3753 | if (!pairwise) |
| 3754 | #else |
| 3755 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) |
| 3756 | #endif |
| 3757 | { |
| 3758 | /* set group key*/ |
| 3759 | if (pHddStaCtx->roam_info.deferKeyComplete) |
| 3760 | { |
| 3761 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 3762 | "%s- %d: Perform Set key Complete", |
| 3763 | __func__, __LINE__); |
| 3764 | hdd_PerformRoamSetKeyComplete(pAdapter); |
| 3765 | } |
| 3766 | } |
| 3767 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3768 | pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len; |
| 3769 | |
Venkata Prathyusha Kuntupalli | ee2ce71 | 2013-01-17 14:09:24 -0800 | [diff] [blame] | 3770 | pWextState->roamProfile.Keys.defaultIndex = key_index; |
| 3771 | |
| 3772 | |
Jeff Johnson | f77ef0a | 2013-03-27 09:29:14 -0700 | [diff] [blame] | 3773 | vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3774 | params->key, params->key_len); |
| 3775 | |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3776 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3777 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 3778 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3779 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3780 | "%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] | 3781 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3782 | setKey.peerMac[2], setKey.peerMac[3], |
| 3783 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3784 | setKey.keyDirection); |
| 3785 | |
| 3786 | vos_status = wlan_hdd_check_ula_done(pAdapter); |
| 3787 | |
| 3788 | if ( vos_status != VOS_STATUS_SUCCESS ) |
| 3789 | { |
| 3790 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 3791 | "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d", |
| 3792 | __LINE__, vos_status ); |
| 3793 | |
| 3794 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3795 | |
| 3796 | return -EINVAL; |
| 3797 | |
| 3798 | } |
| 3799 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3800 | #ifdef WLAN_FEATURE_VOWIFI_11R |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3801 | /* The supplicant may attempt to set the PTK once pre-authentication |
| 3802 | is done. Save the key in the UMAC and include it in the ADD BSS |
| 3803 | request */ |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3804 | halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey); |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3805 | if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS ) |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3806 | { |
Gopichand Nakkala | 3d29592 | 2013-05-07 16:19:14 +0530 | [diff] [blame] | 3807 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
| 3808 | "%s: Update PreAuth Key success", __func__); |
| 3809 | return 0; |
| 3810 | } |
| 3811 | else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED ) |
| 3812 | { |
| 3813 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3814 | "%s: Update PreAuth Key failed", __func__); |
Gopichand Nakkala | d7d1365 | 2013-02-15 01:48:00 +0530 | [diff] [blame] | 3815 | return -EINVAL; |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 3816 | } |
| 3817 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3818 | |
| 3819 | /* issue set key request to SME*/ |
| 3820 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 3821 | pAdapter->sessionId, &setKey, &roamId ); |
| 3822 | |
| 3823 | if ( 0 != status ) |
| 3824 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3825 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3826 | "%s: sme_RoamSetKey failed, returned %d", __func__, status); |
| 3827 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3828 | return -EINVAL; |
| 3829 | } |
| 3830 | |
| 3831 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3832 | /* in case of IBSS as there was no information available about WEP keys during |
| 3833 | * 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] | 3834 | * with correct value*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3835 | if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) && |
| 3836 | !( ( IW_AUTH_KEY_MGMT_802_1X |
| 3837 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3838 | && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) |
| 3839 | ) |
| 3840 | && |
| 3841 | ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher) |
| 3842 | || (WLAN_CIPHER_SUITE_WEP104 == params->cipher) |
| 3843 | ) |
| 3844 | ) |
| 3845 | { |
| 3846 | setKey.keyDirection = eSIR_RX_ONLY; |
| 3847 | vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN); |
| 3848 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3849 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3850 | "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3851 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 3852 | setKey.peerMac[2], setKey.peerMac[3], |
| 3853 | setKey.peerMac[4], setKey.peerMac[5], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3854 | setKey.keyDirection); |
| 3855 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3856 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3857 | pAdapter->sessionId, &setKey, &roamId ); |
| 3858 | |
| 3859 | if ( 0 != status ) |
| 3860 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3861 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 3862 | "%s: sme_RoamSetKey failed for group key (IBSS), returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3863 | __func__, status); |
| 3864 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 3865 | return -EINVAL; |
| 3866 | } |
| 3867 | } |
| 3868 | } |
| 3869 | |
| 3870 | return 0; |
| 3871 | } |
| 3872 | |
| 3873 | /* |
| 3874 | * FUNCTION: wlan_hdd_cfg80211_get_key |
| 3875 | * This function is used to get the key information |
| 3876 | */ |
| 3877 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3878 | static int wlan_hdd_cfg80211_get_key( |
| 3879 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3880 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3881 | u8 key_index, bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3882 | const u8 *mac_addr, void *cookie, |
| 3883 | void (*callback)(void *cookie, struct key_params*) |
| 3884 | ) |
| 3885 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3886 | static int wlan_hdd_cfg80211_get_key( |
| 3887 | struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3888 | struct net_device *ndev, |
| 3889 | u8 key_index, const u8 *mac_addr, void *cookie, |
| 3890 | void (*callback)(void *cookie, struct key_params*) |
| 3891 | ) |
| 3892 | #endif |
| 3893 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3894 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3895 | hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 3896 | tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile); |
| 3897 | struct key_params params; |
| 3898 | |
| 3899 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3900 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 3901 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3902 | __func__,pAdapter->device_mode); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3903 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3904 | memset(¶ms, 0, sizeof(params)); |
| 3905 | |
| 3906 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3907 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 3908 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3909 | return -EINVAL; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3910 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3911 | |
| 3912 | switch(pRoamProfile->EncryptionType.encryptionType[0]) |
| 3913 | { |
| 3914 | case eCSR_ENCRYPT_TYPE_NONE: |
| 3915 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3916 | break; |
| 3917 | |
| 3918 | case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY: |
| 3919 | case eCSR_ENCRYPT_TYPE_WEP40: |
| 3920 | params.cipher = WLAN_CIPHER_SUITE_WEP40; |
| 3921 | break; |
| 3922 | |
| 3923 | case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY: |
| 3924 | case eCSR_ENCRYPT_TYPE_WEP104: |
| 3925 | params.cipher = WLAN_CIPHER_SUITE_WEP104; |
| 3926 | break; |
| 3927 | |
| 3928 | case eCSR_ENCRYPT_TYPE_TKIP: |
| 3929 | params.cipher = WLAN_CIPHER_SUITE_TKIP; |
| 3930 | break; |
| 3931 | |
| 3932 | case eCSR_ENCRYPT_TYPE_AES: |
| 3933 | params.cipher = WLAN_CIPHER_SUITE_AES_CMAC; |
| 3934 | break; |
| 3935 | |
| 3936 | default: |
| 3937 | params.cipher = IW_AUTH_CIPHER_NONE; |
| 3938 | break; |
| 3939 | } |
| 3940 | |
| 3941 | params.key_len = pRoamProfile->Keys.KeyLength[key_index]; |
| 3942 | params.seq_len = 0; |
| 3943 | params.seq = NULL; |
| 3944 | params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0]; |
| 3945 | callback(cookie, ¶ms); |
| 3946 | return 0; |
| 3947 | } |
| 3948 | |
| 3949 | /* |
| 3950 | * FUNCTION: wlan_hdd_cfg80211_del_key |
| 3951 | * This function is used to delete the key information |
| 3952 | */ |
| 3953 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3954 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3955 | struct net_device *ndev, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3956 | u8 key_index, |
| 3957 | bool pairwise, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3958 | const u8 *mac_addr |
| 3959 | ) |
| 3960 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3961 | static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3962 | struct net_device *ndev, |
| 3963 | u8 key_index, |
| 3964 | const u8 *mac_addr |
| 3965 | ) |
| 3966 | #endif |
| 3967 | { |
| 3968 | int status = 0; |
| 3969 | |
| 3970 | //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] | 3971 | //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] | 3972 | //it is observed that this is invalidating peer |
| 3973 | //key index whenever re-key is done. This is affecting data link. |
| 3974 | //It should be ok to ignore del_key. |
| 3975 | #if 0 |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3976 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
| 3977 | v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3978 | u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 3979 | tCsrRoamSetKey setKey; |
| 3980 | v_U32_t roamId= 0xFF; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3981 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3982 | ENTER(); |
| 3983 | |
| 3984 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n", |
| 3985 | __func__,pAdapter->device_mode); |
| 3986 | |
| 3987 | if (CSR_MAX_NUM_KEY <= key_index) |
| 3988 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 3989 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 3990 | key_index); |
| 3991 | |
| 3992 | return -EINVAL; |
| 3993 | } |
| 3994 | |
| 3995 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 3996 | setKey.keyId = key_index; |
| 3997 | |
| 3998 | if (mac_addr) |
| 3999 | vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN); |
| 4000 | else |
| 4001 | vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN); |
| 4002 | |
| 4003 | setKey.encType = eCSR_ENCRYPT_TYPE_NONE; |
| 4004 | |
| 4005 | if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4006 | || (pAdapter->device_mode == WLAN_HDD_P2P_GO) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4007 | ) |
| 4008 | { |
| 4009 | |
| 4010 | hdd_hostapd_state_t *pHostapdState = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4011 | WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 4012 | if( pHostapdState->bssState == BSS_START) |
| 4013 | { |
| 4014 | status = WLANSAP_SetKeySta( pVosContext, &setKey); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4015 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4016 | if ( status != eHAL_STATUS_SUCCESS ) |
| 4017 | { |
| 4018 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4019 | "[%4d] WLANSAP_SetKeySta returned ERROR status= %d", |
| 4020 | __LINE__, status ); |
| 4021 | } |
| 4022 | } |
| 4023 | } |
| 4024 | else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4025 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4026 | ) |
| 4027 | { |
| 4028 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4029 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4030 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY; |
| 4031 | |
| 4032 | hddLog(VOS_TRACE_LEVEL_INFO_MED, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4033 | "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4034 | __func__, setKey.peerMac[0], setKey.peerMac[1], |
| 4035 | setKey.peerMac[2], setKey.peerMac[3], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4036 | setKey.peerMac[4], setKey.peerMac[5]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4037 | if(pAdapter->sessionCtx.station.conn_info.connState == |
| 4038 | eConnectionState_Associated) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4039 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4040 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4041 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4042 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4043 | if ( 0 != status ) |
| 4044 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4045 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4046 | "%s: sme_RoamSetKey failure, returned %d", |
| 4047 | __func__, status); |
| 4048 | pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE; |
| 4049 | return -EINVAL; |
| 4050 | } |
| 4051 | } |
| 4052 | } |
| 4053 | #endif |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4054 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4055 | return status; |
| 4056 | } |
| 4057 | |
| 4058 | /* |
| 4059 | * FUNCTION: wlan_hdd_cfg80211_set_default_key |
| 4060 | * This function is used to set the default tx key index |
| 4061 | */ |
| 4062 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 4063 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 4064 | struct net_device *ndev, |
| 4065 | u8 key_index, |
| 4066 | bool unicast, bool multicast) |
| 4067 | #else |
| 4068 | static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy, |
| 4069 | struct net_device *ndev, |
| 4070 | u8 key_index) |
| 4071 | #endif |
| 4072 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4073 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4074 | int status; |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4075 | hdd_wext_state_t *pWextState; |
| 4076 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4077 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4078 | |
| 4079 | ENTER(); |
| 4080 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4081 | if ((NULL == pAdapter)) |
| 4082 | { |
| 4083 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4084 | "invalid adapter"); |
| 4085 | return -EINVAL; |
| 4086 | } |
| 4087 | |
| 4088 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 4089 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4090 | |
| 4091 | if ((NULL == pWextState) || (NULL == pHddStaCtx)) |
| 4092 | { |
| 4093 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4094 | "invalid Wext state or HDD context"); |
| 4095 | return -EINVAL; |
| 4096 | } |
| 4097 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4098 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4099 | __func__,pAdapter->device_mode, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4100 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4101 | if (CSR_MAX_NUM_KEY <= key_index) |
| 4102 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4103 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4104 | key_index); |
| 4105 | |
| 4106 | return -EINVAL; |
| 4107 | } |
| 4108 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4109 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4110 | status = wlan_hdd_validate_context(pHddCtx); |
| 4111 | |
| 4112 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4113 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4114 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4115 | "%s: HDD context is not valid", __func__); |
| 4116 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4117 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4118 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4119 | if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4120 | || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4121 | ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4122 | { |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4123 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
Arif Hussain | 6943f52 | 2013-11-04 20:10:10 -0800 | [diff] [blame] | 4124 | pHddStaCtx->conn_info.ucEncryptionType) && |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4125 | (eCSR_ENCRYPT_TYPE_AES != |
Arif Hussain | 6943f52 | 2013-11-04 20:10:10 -0800 | [diff] [blame] | 4126 | pHddStaCtx->conn_info.ucEncryptionType) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4127 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4128 | { |
| 4129 | /* if default key index is not same as previous one, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4130 | * then update the default key index */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4131 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4132 | tCsrRoamSetKey setKey; |
| 4133 | v_U32_t roamId= 0xFF; |
| 4134 | tCsrKeys *Keys = &pWextState->roamProfile.Keys; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4135 | |
| 4136 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4137 | __func__, key_index); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4138 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4139 | Keys->defaultIndex = (u8)key_index; |
| 4140 | vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey)); |
| 4141 | setKey.keyId = key_index; |
| 4142 | setKey.keyLength = Keys->KeyLength[key_index]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4143 | |
| 4144 | vos_mem_copy(&setKey.Key[0], |
| 4145 | &Keys->KeyMaterial[key_index][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4146 | Keys->KeyLength[key_index]); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4147 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4148 | setKey.keyDirection = eSIR_TX_RX; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4149 | |
| 4150 | vos_mem_copy(setKey.peerMac, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4151 | &pHddStaCtx->conn_info.bssId[0], |
| 4152 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4153 | |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 4154 | if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN && |
| 4155 | pWextState->roamProfile.EncryptionType.encryptionType[0] == |
| 4156 | eCSR_ENCRYPT_TYPE_WEP104) |
| 4157 | { |
| 4158 | /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104 |
| 4159 | even though ap is configured for WEP-40 encryption. In this canse the key length |
| 4160 | is 5 but the encryption type is 104 hence checking the key langht(5) and encryption |
| 4161 | type(104) and switching encryption type to 40*/ |
| 4162 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
| 4163 | eCSR_ENCRYPT_TYPE_WEP40; |
| 4164 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = |
| 4165 | eCSR_ENCRYPT_TYPE_WEP40; |
| 4166 | } |
| 4167 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4168 | setKey.encType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4169 | pWextState->roamProfile.EncryptionType.encryptionType[0]; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4170 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4171 | /* issue set key request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4172 | status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4173 | pAdapter->sessionId, &setKey, &roamId ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4174 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4175 | if ( 0 != status ) |
| 4176 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4177 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4178 | "%s: sme_RoamSetKey failed, returned %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4179 | status); |
| 4180 | return -EINVAL; |
| 4181 | } |
| 4182 | } |
| 4183 | } |
| 4184 | |
| 4185 | /* In SoftAp mode setting key direction for default mode */ |
| 4186 | else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode ) |
| 4187 | { |
| 4188 | if ( (eCSR_ENCRYPT_TYPE_TKIP != |
| 4189 | pWextState->roamProfile.EncryptionType.encryptionType[0]) && |
| 4190 | (eCSR_ENCRYPT_TYPE_AES != |
| 4191 | pWextState->roamProfile.EncryptionType.encryptionType[0]) |
| 4192 | ) |
| 4193 | { |
| 4194 | /* Saving key direction for default key index to TX default */ |
| 4195 | hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 4196 | pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT; |
| 4197 | } |
| 4198 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4199 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4200 | return status; |
| 4201 | } |
| 4202 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4203 | /* |
| 4204 | * FUNCTION: wlan_hdd_cfg80211_inform_bss |
| 4205 | * This function is used to inform the BSS details to nl80211 interface. |
| 4206 | */ |
| 4207 | static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss( |
| 4208 | hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile) |
| 4209 | { |
| 4210 | struct net_device *dev = pAdapter->dev; |
| 4211 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 4212 | struct wiphy *wiphy = wdev->wiphy; |
| 4213 | tSirBssDescription *pBssDesc = roamProfile->pBssDesc; |
| 4214 | int chan_no; |
| 4215 | int ie_length; |
| 4216 | const char *ie; |
| 4217 | unsigned int freq; |
| 4218 | struct ieee80211_channel *chan; |
| 4219 | int rssi = 0; |
| 4220 | struct cfg80211_bss *bss = NULL; |
| 4221 | |
| 4222 | ENTER(); |
| 4223 | |
| 4224 | if( NULL == pBssDesc ) |
| 4225 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4226 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4227 | return bss; |
| 4228 | } |
| 4229 | |
| 4230 | chan_no = pBssDesc->channelId; |
| 4231 | ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length ); |
| 4232 | ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL); |
| 4233 | |
| 4234 | if( NULL == ie ) |
| 4235 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4236 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4237 | return bss; |
| 4238 | } |
| 4239 | |
| 4240 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
| 4241 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ)) |
| 4242 | { |
| 4243 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 4244 | } |
| 4245 | else |
| 4246 | { |
| 4247 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 4248 | } |
| 4249 | #else |
| 4250 | freq = ieee80211_channel_to_frequency(chan_no); |
| 4251 | #endif |
| 4252 | |
| 4253 | chan = __ieee80211_get_channel(wiphy, freq); |
| 4254 | |
| 4255 | bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId, |
| 4256 | &roamProfile->SSID.ssId[0], roamProfile->SSID.length, |
| 4257 | WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); |
| 4258 | if (bss == NULL) |
| 4259 | { |
| 4260 | rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100; |
| 4261 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4262 | return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId, |
| 4263 | le64_to_cpu(*(__le64 *)pBssDesc->timeStamp), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4264 | pBssDesc->capabilityInfo, |
| 4265 | pBssDesc->beaconInterval, ie, ie_length, |
| 4266 | rssi, GFP_KERNEL )); |
| 4267 | } |
| 4268 | else |
| 4269 | { |
| 4270 | return bss; |
| 4271 | } |
| 4272 | } |
| 4273 | |
| 4274 | |
| 4275 | |
| 4276 | /* |
| 4277 | * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame |
| 4278 | * This function is used to inform the BSS details to nl80211 interface. |
| 4279 | */ |
| 4280 | struct cfg80211_bss* |
| 4281 | wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter, |
| 4282 | tSirBssDescription *bss_desc |
| 4283 | ) |
| 4284 | { |
| 4285 | /* |
| 4286 | cfg80211_inform_bss() is not updating ie field of bss entry, if entry |
| 4287 | already exists in bss data base of cfg80211 for that particular BSS ID. |
| 4288 | Using cfg80211_inform_bss_frame to update the bss entry instead of |
| 4289 | cfg80211_inform_bss, But this call expects mgmt packet as input. As of |
| 4290 | now there is no possibility to get the mgmt(probe response) frame from PE, |
| 4291 | converting bss_desc to ieee80211_mgmt(probe response) and passing to |
| 4292 | cfg80211_inform_bss_frame. |
| 4293 | */ |
| 4294 | struct net_device *dev = pAdapter->dev; |
| 4295 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 4296 | struct wiphy *wiphy = wdev->wiphy; |
| 4297 | int chan_no = bss_desc->channelId; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 4298 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 4299 | qcom_ie_age *qie_age = NULL; |
| 4300 | int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age); |
| 4301 | #else |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4302 | 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] | 4303 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4304 | const char *ie = |
| 4305 | ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL); |
| 4306 | unsigned int freq; |
| 4307 | struct ieee80211_channel *chan; |
Abhishek Singh | 1e2bfa3 | 2014-01-02 15:44:15 +0530 | [diff] [blame] | 4308 | struct ieee80211_mgmt *mgmt = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4309 | struct cfg80211_bss *bss_status = NULL; |
| 4310 | size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length; |
| 4311 | int rssi = 0; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4312 | hdd_context_t *pHddCtx; |
| 4313 | int status; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4314 | #ifdef WLAN_OPEN_SOURCE |
| 4315 | struct timespec ts; |
| 4316 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4317 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4318 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4319 | status = wlan_hdd_validate_context(pHddCtx); |
| 4320 | |
| 4321 | /*bss_update is not allowed during wlan driver loading or unloading*/ |
| 4322 | if (pHddCtx->isLoadUnloadInProgress) |
| 4323 | { |
| 4324 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4325 | "%s:Loading_unloading in Progress. Ignore!!!",__func__); |
| 4326 | return NULL; |
| 4327 | } |
| 4328 | |
| 4329 | |
| 4330 | if (0 != status) |
| 4331 | { |
| 4332 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4333 | "%s: HDD context is not valid", __func__); |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 4334 | return NULL; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4335 | } |
| 4336 | |
Abhishek Singh | 1e2bfa3 | 2014-01-02 15:44:15 +0530 | [diff] [blame] | 4337 | mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL); |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4338 | if (!mgmt) |
| 4339 | { |
| 4340 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4341 | "%s: memory allocation failed ", __func__); |
| 4342 | return NULL; |
| 4343 | } |
Madan Mohan Koyyalamudi | 2e5c914 | 2012-11-02 13:17:48 -0700 | [diff] [blame] | 4344 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4345 | memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4346 | |
| 4347 | #ifdef WLAN_OPEN_SOURCE |
| 4348 | /* Android does not want the timestamp from the frame. |
| 4349 | Instead it wants a monotonic increasing value */ |
| 4350 | get_monotonic_boottime(&ts); |
| 4351 | mgmt->u.probe_resp.timestamp = |
| 4352 | ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000); |
| 4353 | #else |
| 4354 | /* keep old behavior for non-open source (for now) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4355 | memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp, |
| 4356 | sizeof (bss_desc->timeStamp)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4357 | |
| 4358 | #endif |
| 4359 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4360 | mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval; |
| 4361 | mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo; |
Madan Mohan Koyyalamudi | 86f629e | 2012-11-09 16:27:29 -0800 | [diff] [blame] | 4362 | |
| 4363 | #ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS |
| 4364 | /* GPS Requirement: need age ie per entry. Using vendor specific. */ |
| 4365 | /* Assuming this is the last IE, copy at the end */ |
| 4366 | ie_length -=sizeof(qcom_ie_age); |
| 4367 | qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length); |
| 4368 | qie_age->element_id = QCOM_VENDOR_IE_ID; |
| 4369 | qie_age->len = QCOM_VENDOR_IE_AGE_LEN; |
| 4370 | qie_age->oui_1 = QCOM_OUI1; |
| 4371 | qie_age->oui_2 = QCOM_OUI2; |
| 4372 | qie_age->oui_3 = QCOM_OUI3; |
| 4373 | qie_age->type = QCOM_VENDOR_IE_AGE_TYPE; |
| 4374 | qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime; |
| 4375 | #endif |
| 4376 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4377 | memcpy(mgmt->u.probe_resp.variable, ie, ie_length); |
Gopichand Nakkala | d908ec8 | 2013-05-16 19:32:19 +0530 | [diff] [blame] | 4378 | if (bss_desc->fProbeRsp) |
| 4379 | { |
| 4380 | mgmt->frame_control |= |
| 4381 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); |
| 4382 | } |
| 4383 | else |
| 4384 | { |
| 4385 | mgmt->frame_control |= |
| 4386 | (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); |
| 4387 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4388 | |
| 4389 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4390 | if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4391 | (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL)) |
| 4392 | { |
| 4393 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ); |
| 4394 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4395 | else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) && |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4396 | (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL)) |
| 4397 | |
| 4398 | { |
| 4399 | freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ); |
| 4400 | } |
| 4401 | else |
| 4402 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 4403 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d", |
| 4404 | __func__, chan_no); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4405 | kfree(mgmt); |
| 4406 | return NULL; |
| 4407 | } |
| 4408 | #else |
| 4409 | freq = ieee80211_channel_to_frequency(chan_no); |
| 4410 | #endif |
| 4411 | chan = __ieee80211_get_channel(wiphy, freq); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 4412 | /*when the band is changed on the fly using the GUI, three things are done |
| 4413 | * 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) |
| 4414 | * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band. |
| 4415 | * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function. |
| 4416 | * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels |
| 4417 | * and discards the channels correponding to previous band and calls back with zero bss results. |
| 4418 | * 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 |
| 4419 | * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so |
| 4420 | * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed. |
| 4421 | * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark. |
| 4422 | * So drop the bss and continue to next bss. |
| 4423 | */ |
| 4424 | if(chan == NULL) |
| 4425 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 4426 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__); |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 4427 | kfree(mgmt); |
Leela V Kiran Kumar Reddy | 90032de | 2013-01-24 18:33:30 -0800 | [diff] [blame] | 4428 | return NULL; |
| 4429 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4430 | /*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] | 4431 | *and the rssi icon of the wireless networks in sync |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4432 | * */ |
| 4433 | if (( eConnectionState_Associated == |
| 4434 | pAdapter->sessionCtx.station.conn_info.connState ) && |
| 4435 | ( VOS_TRUE == vos_mem_compare(bss_desc->bssId, |
| 4436 | pAdapter->sessionCtx.station.conn_info.bssId, |
| 4437 | WNI_CFG_BSSID_LEN))) |
| 4438 | { |
| 4439 | /* supplicant takes the signal strength in terms of mBm(100*dBm) */ |
| 4440 | rssi = (pAdapter->rssi * 100); |
| 4441 | } |
| 4442 | else |
| 4443 | { |
| 4444 | rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100; |
| 4445 | } |
| 4446 | |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 4447 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d" |
| 4448 | "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid), |
| 4449 | chan->center_freq, (int)(rssi/100)); |
| 4450 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4451 | bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt, |
| 4452 | frame_len, rssi, GFP_KERNEL); |
| 4453 | kfree(mgmt); |
| 4454 | return bss_status; |
| 4455 | } |
| 4456 | |
| 4457 | /* |
| 4458 | * FUNCTION: wlan_hdd_cfg80211_update_bss_db |
| 4459 | * This function is used to update the BSS data base of CFG8011 |
| 4460 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4461 | 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] | 4462 | tCsrRoamInfo *pRoamInfo |
| 4463 | ) |
| 4464 | { |
| 4465 | tCsrRoamConnectedProfile roamProfile; |
| 4466 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4467 | struct cfg80211_bss *bss = NULL; |
| 4468 | |
| 4469 | ENTER(); |
| 4470 | |
| 4471 | memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile)); |
| 4472 | sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile); |
| 4473 | |
| 4474 | if (NULL != roamProfile.pBssDesc) |
| 4475 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4476 | bss = wlan_hdd_cfg80211_inform_bss(pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4477 | &roamProfile); |
| 4478 | |
| 4479 | if (NULL == bss) |
| 4480 | { |
| 4481 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL", |
| 4482 | __func__); |
| 4483 | } |
| 4484 | |
| 4485 | sme_RoamFreeConnectProfile(hHal, &roamProfile); |
| 4486 | } |
| 4487 | else |
| 4488 | { |
| 4489 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL", |
| 4490 | __func__); |
| 4491 | } |
| 4492 | return bss; |
| 4493 | } |
| 4494 | |
| 4495 | /* |
| 4496 | * FUNCTION: wlan_hdd_cfg80211_update_bss |
| 4497 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4498 | static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy, |
| 4499 | hdd_adapter_t *pAdapter |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4500 | ) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4501 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4502 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 4503 | tCsrScanResultInfo *pScanResult; |
| 4504 | eHalStatus status = 0; |
| 4505 | tScanResultHandle pResult; |
| 4506 | struct cfg80211_bss *bss_status = NULL; |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4507 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4508 | |
| 4509 | ENTER(); |
| 4510 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4511 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4512 | |
| 4513 | if (pHddCtx->isLogpInProgress) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4514 | { |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4515 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 4516 | "%s:LOGP in Progress. Ignore!!!",__func__); |
| 4517 | return -EAGAIN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4518 | } |
| 4519 | |
Wilson Yang | f80a054 | 2013-10-07 13:02:37 -0700 | [diff] [blame] | 4520 | |
| 4521 | /*bss_update is not allowed during wlan driver loading or unloading*/ |
| 4522 | if (pHddCtx->isLoadUnloadInProgress) |
| 4523 | { |
| 4524 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 4525 | "%s:Loading_unloading in Progress. Ignore!!!",__func__); |
| 4526 | return VOS_STATUS_E_PERM; |
| 4527 | } |
| 4528 | |
| 4529 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4530 | /* |
| 4531 | * start getting scan results and populate cgf80211 BSS database |
| 4532 | */ |
| 4533 | status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult); |
| 4534 | |
| 4535 | /* no scan results */ |
| 4536 | if (NULL == pResult) |
| 4537 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 4538 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d", |
| 4539 | __func__, status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4540 | return status; |
| 4541 | } |
| 4542 | |
| 4543 | pScanResult = sme_ScanResultGetFirst(hHal, pResult); |
| 4544 | |
| 4545 | while (pScanResult) |
| 4546 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4547 | /* |
| 4548 | * cfg80211_inform_bss() is not updating ie field of bss entry, if |
| 4549 | * entry already exists in bss data base of cfg80211 for that |
| 4550 | * particular BSS ID. Using cfg80211_inform_bss_frame to update the |
| 4551 | * bss entry instead of cfg80211_inform_bss, But this call expects |
| 4552 | * mgmt packet as input. As of now there is no possibility to get |
| 4553 | * the mgmt(probe response) frame from PE, converting bss_desc to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4554 | * ieee80211_mgmt(probe response) and passing to c |
| 4555 | * fg80211_inform_bss_frame. |
| 4556 | * */ |
| 4557 | |
| 4558 | bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter, |
| 4559 | &pScanResult->BssDescriptor); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4560 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4561 | |
| 4562 | if (NULL == bss_status) |
| 4563 | { |
| 4564 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4565 | "%s: NULL returned by cfg80211_inform_bss", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4566 | } |
| 4567 | else |
| 4568 | { |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 4569 | cfg80211_put_bss( |
| 4570 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
| 4571 | wiphy, |
| 4572 | #endif |
| 4573 | bss_status); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4574 | } |
| 4575 | |
| 4576 | pScanResult = sme_ScanResultGetNext(hHal, pResult); |
| 4577 | } |
| 4578 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4579 | sme_ScanResultPurge(hHal, pResult); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4580 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4581 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4582 | } |
| 4583 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4584 | void |
| 4585 | hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel) |
| 4586 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4587 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 4588 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4589 | } /****** end hddPrintMacAddr() ******/ |
| 4590 | |
| 4591 | void |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4592 | hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4593 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4594 | VOS_TRACE(VOS_MODULE_ID_HDD, logLevel, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4595 | "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 4596 | pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4], |
| 4597 | pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10], |
| 4598 | pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4599 | } /****** end hddPrintPmkId() ******/ |
| 4600 | |
| 4601 | //hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel); |
| 4602 | //hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL); |
| 4603 | |
| 4604 | //void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size); |
| 4605 | //sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16); |
| 4606 | |
| 4607 | #define dump_bssid(bssid) \ |
| 4608 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4609 | hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \ |
| 4610 | hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4611 | } |
| 4612 | |
| 4613 | #define dump_pmkid(pMac, pmkid) \ |
| 4614 | { \ |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4615 | hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \ |
| 4616 | hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\ |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4617 | } |
| 4618 | |
Madan Mohan Koyyalamudi | 1b4afb0 | 2012-10-22 15:25:16 -0700 | [diff] [blame] | 4619 | #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] | 4620 | /* |
| 4621 | * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify |
| 4622 | * This function is used to notify the supplicant of a new PMKSA candidate. |
| 4623 | */ |
| 4624 | int wlan_hdd_cfg80211_pmksa_candidate_notify( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4625 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4626 | int index, bool preauth ) |
| 4627 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4628 | #ifdef FEATURE_WLAN_OKC |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4629 | struct net_device *dev = pAdapter->dev; |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4630 | hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4631 | |
| 4632 | ENTER(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4633 | 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] | 4634 | |
| 4635 | if( NULL == pRoamInfo ) |
| 4636 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4637 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4638 | return -EINVAL; |
| 4639 | } |
| 4640 | |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4641 | if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx)) |
| 4642 | { |
| 4643 | dump_bssid(pRoamInfo->bssid); |
| 4644 | cfg80211_pmksa_candidate_notify(dev, index, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4645 | pRoamInfo->bssid, preauth, GFP_KERNEL); |
Srinivas Girigowda | bbd16eb | 2013-03-21 12:34:46 -0700 | [diff] [blame] | 4646 | } |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4647 | #endif /* FEATURE_WLAN_OKC */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4648 | return 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 4649 | } |
| 4650 | #endif //FEATURE_WLAN_LFR |
| 4651 | |
Yue Ma | ef60827 | 2013-04-08 23:09:17 -0700 | [diff] [blame] | 4652 | #ifdef FEATURE_WLAN_LFR_METRICS |
| 4653 | /* |
| 4654 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth |
| 4655 | * 802.11r/LFR metrics reporting function to report preauth initiation |
| 4656 | * |
| 4657 | */ |
| 4658 | #define MAX_LFR_METRICS_EVENT_LENGTH 100 |
| 4659 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter, |
| 4660 | tCsrRoamInfo *pRoamInfo) |
| 4661 | { |
| 4662 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 4663 | union iwreq_data wrqu; |
| 4664 | |
| 4665 | ENTER(); |
| 4666 | |
| 4667 | if (NULL == pAdapter) |
| 4668 | { |
| 4669 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 4670 | return VOS_STATUS_E_FAILURE; |
| 4671 | } |
| 4672 | |
| 4673 | /* create the event */ |
| 4674 | memset(&wrqu, 0, sizeof(wrqu)); |
| 4675 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 4676 | |
| 4677 | wrqu.data.pointer = metrics_notification; |
| 4678 | wrqu.data.length = scnprintf(metrics_notification, |
| 4679 | sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT " |
| 4680 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 4681 | |
| 4682 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 4683 | |
| 4684 | EXIT(); |
| 4685 | |
| 4686 | return VOS_STATUS_SUCCESS; |
| 4687 | } |
| 4688 | |
| 4689 | /* |
| 4690 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status |
| 4691 | * 802.11r/LFR metrics reporting function to report preauth completion |
| 4692 | * or failure |
| 4693 | */ |
| 4694 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status( |
| 4695 | hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status) |
| 4696 | { |
| 4697 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 4698 | union iwreq_data wrqu; |
| 4699 | |
| 4700 | ENTER(); |
| 4701 | |
| 4702 | if (NULL == pAdapter) |
| 4703 | { |
| 4704 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 4705 | return VOS_STATUS_E_FAILURE; |
| 4706 | } |
| 4707 | |
| 4708 | /* create the event */ |
| 4709 | memset(&wrqu, 0, sizeof(wrqu)); |
| 4710 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 4711 | |
| 4712 | scnprintf(metrics_notification, sizeof(metrics_notification), |
| 4713 | "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR, |
| 4714 | MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 4715 | |
| 4716 | if (1 == preauth_status) |
| 4717 | strncat(metrics_notification, " TRUE", 5); |
| 4718 | else |
| 4719 | strncat(metrics_notification, " FALSE", 6); |
| 4720 | |
| 4721 | wrqu.data.pointer = metrics_notification; |
| 4722 | wrqu.data.length = strlen(metrics_notification); |
| 4723 | |
| 4724 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 4725 | |
| 4726 | EXIT(); |
| 4727 | |
| 4728 | return VOS_STATUS_SUCCESS; |
| 4729 | } |
| 4730 | |
| 4731 | /* |
| 4732 | * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover |
| 4733 | * 802.11r/LFR metrics reporting function to report handover initiation |
| 4734 | * |
| 4735 | */ |
| 4736 | VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter, |
| 4737 | tCsrRoamInfo *pRoamInfo) |
| 4738 | { |
| 4739 | unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1]; |
| 4740 | union iwreq_data wrqu; |
| 4741 | |
| 4742 | ENTER(); |
| 4743 | |
| 4744 | if (NULL == pAdapter) |
| 4745 | { |
| 4746 | hddLog(LOGE, "%s: pAdapter is NULL!", __func__); |
| 4747 | return VOS_STATUS_E_FAILURE; |
| 4748 | } |
| 4749 | |
| 4750 | /* create the event */ |
| 4751 | memset(&wrqu, 0, sizeof(wrqu)); |
| 4752 | memset(metrics_notification, 0, sizeof(metrics_notification)); |
| 4753 | |
| 4754 | wrqu.data.pointer = metrics_notification; |
| 4755 | wrqu.data.length = scnprintf(metrics_notification, |
| 4756 | sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER " |
| 4757 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid)); |
| 4758 | |
| 4759 | wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification); |
| 4760 | |
| 4761 | EXIT(); |
| 4762 | |
| 4763 | return VOS_STATUS_SUCCESS; |
| 4764 | } |
| 4765 | #endif |
| 4766 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4767 | /* |
| 4768 | * FUNCTION: hdd_cfg80211_scan_done_callback |
| 4769 | * scanning callback function, called after finishing scan |
| 4770 | * |
| 4771 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4772 | static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4773 | void *pContext, tANI_U32 scanId, eCsrScanStatus status) |
| 4774 | { |
| 4775 | struct net_device *dev = (struct net_device *) pContext; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4776 | //struct wireless_dev *wdev = dev->ieee80211_ptr; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4777 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4778 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 4779 | hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4780 | struct cfg80211_scan_request *req = NULL; |
| 4781 | int ret = 0; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4782 | long waitRet = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4783 | |
| 4784 | ENTER(); |
| 4785 | |
| 4786 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4787 | "%s called with halHandle = %p, pContext = %p," |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4788 | "scanID = %d, returned status = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4789 | __func__, halHandle, pContext, (int) scanId, (int) status); |
| 4790 | |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 4791 | pScanInfo->mScanPendingCounter = 0; |
| 4792 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4793 | //Block on scan req completion variable. Can't wait forever though. |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4794 | waitRet = wait_for_completion_interruptible_timeout( |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4795 | &pScanInfo->scan_req_completion_event, |
| 4796 | msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4797 | if (waitRet <= 0) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4798 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 4799 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 4800 | "%s wait on scan_req_completion_event failed %ld",__func__, waitRet); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4801 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4802 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4803 | } |
| 4804 | |
Yue Ma | ef60827 | 2013-04-08 23:09:17 -0700 | [diff] [blame] | 4805 | if (pScanInfo->mScanPending != VOS_TRUE) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4806 | { |
| 4807 | VOS_ASSERT(pScanInfo->mScanPending); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4808 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4809 | } |
| 4810 | |
| 4811 | /* Check the scanId */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4812 | if (pScanInfo->scanId != scanId) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4813 | { |
| 4814 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4815 | "%s called with mismatched scanId pScanInfo->scanId = %d " |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4816 | "scanId = %d", __func__, (int) pScanInfo->scanId, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4817 | (int) scanId); |
| 4818 | } |
| 4819 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4820 | ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4821 | pAdapter); |
| 4822 | |
| 4823 | if (0 > ret) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4824 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4825 | |
| 4826 | |
| 4827 | /* If any client wait scan result through WEXT |
| 4828 | * send scan done event to client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4829 | if (pHddCtx->scan_info.waitScanResult) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4830 | { |
| 4831 | /* The other scan request waiting for current scan finish |
| 4832 | * Send event to notify current scan finished */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4833 | if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4834 | { |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4835 | vos_event_set(&pHddCtx->scan_info.scan_finished_event); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4836 | } |
| 4837 | /* Send notify to WEXT client */ |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4838 | else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4839 | { |
| 4840 | struct net_device *dev = pAdapter->dev; |
| 4841 | union iwreq_data wrqu; |
| 4842 | int we_event; |
| 4843 | char *msg; |
| 4844 | |
| 4845 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4846 | we_event = SIOCGIWSCAN; |
| 4847 | msg = NULL; |
| 4848 | wireless_send_event(dev, we_event, &wrqu, msg); |
| 4849 | } |
| 4850 | } |
Madan Mohan Koyyalamudi | 2a1ba77 | 2012-10-11 14:59:06 -0700 | [diff] [blame] | 4851 | pHddCtx->scan_info.waitScanResult = FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4852 | |
| 4853 | /* Get the Scan Req */ |
| 4854 | req = pAdapter->request; |
| 4855 | |
| 4856 | if (!req) |
| 4857 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 4858 | hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL"); |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4859 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4860 | goto allow_suspend; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4861 | } |
| 4862 | |
| 4863 | /* |
| 4864 | * setting up 0, just in case. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4865 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4866 | req->n_ssids = 0; |
| 4867 | req->n_channels = 0; |
| 4868 | req->ie = 0; |
| 4869 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4870 | pAdapter->request = NULL; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4871 | /* Scan is no longer pending */ |
| 4872 | pScanInfo->mScanPending = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4873 | |
Madan Mohan Koyyalamudi | b764bf8 | 2012-10-11 16:38:51 -0700 | [diff] [blame] | 4874 | /* |
| 4875 | * cfg80211_scan_done informing NL80211 about completion |
| 4876 | * of scanning |
| 4877 | */ |
| 4878 | cfg80211_scan_done(req, false); |
Madan Mohan Koyyalamudi | f4e8100 | 2012-11-13 10:46:38 -0800 | [diff] [blame] | 4879 | complete(&pScanInfo->abortscan_event_var); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4880 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4881 | allow_suspend: |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 4882 | /* release the wake lock at the end of the scan*/ |
| 4883 | hdd_allow_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 4884 | |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4885 | /* Acquire wakelock to handle the case where APP's tries to suspend |
| 4886 | * immediatly after the driver gets connect request(i.e after scan) |
| 4887 | * from supplicant, this result in app's is suspending and not able |
| 4888 | * to process the connect request to AP */ |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 4889 | hdd_prevent_suspend_timeout(1000); |
Madan Mohan Koyyalamudi | 10d83a9 | 2012-09-28 15:47:05 -0700 | [diff] [blame] | 4890 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 4891 | #ifdef FEATURE_WLAN_TDLS |
| 4892 | wlan_hdd_tdls_scan_done_callback(pAdapter); |
| 4893 | #endif |
| 4894 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4895 | EXIT(); |
| 4896 | return 0; |
| 4897 | } |
| 4898 | |
| 4899 | /* |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4900 | * FUNCTION: hdd_isScanAllowed |
| 4901 | * Go through each adapter and check if scan allowed |
| 4902 | * |
| 4903 | */ |
| 4904 | v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx ) |
| 4905 | { |
| 4906 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 4907 | hdd_station_ctx_t *pHddStaCtx = NULL; |
| 4908 | hdd_adapter_t *pAdapter = NULL; |
| 4909 | VOS_STATUS status = 0; |
| 4910 | v_U8_t staId = 0; |
| 4911 | v_U8_t *staMac = NULL; |
| 4912 | |
c_hpothu | 9b781ba | 2013-12-30 20:57:45 +0530 | [diff] [blame] | 4913 | if (TRUE == pHddCtx->btCoexModeSet) |
| 4914 | { |
| 4915 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 4916 | FL("BTCoex Mode operation in progress, Do not allow scan")); |
| 4917 | return VOS_FALSE; |
| 4918 | } |
| 4919 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4920 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 4921 | |
| 4922 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 4923 | { |
| 4924 | pAdapter = pAdapterNode->pAdapter; |
| 4925 | |
| 4926 | if( pAdapter ) |
| 4927 | { |
| 4928 | hddLog(VOS_TRACE_LEVEL_INFO, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4929 | "%s: Adapter with device mode %d exists", |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4930 | __func__, pAdapter->device_mode); |
| 4931 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 4932 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
| 4933 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
| 4934 | { |
| 4935 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 4936 | if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) && |
| 4937 | (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated)) |
| 4938 | { |
| 4939 | staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]); |
| 4940 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 4941 | "%s: client " MAC_ADDRESS_STR |
| 4942 | " is in the middle of WPS/EAPOL exchange.", __func__, |
| 4943 | MAC_ADDR_ARRAY(staMac)); |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4944 | return VOS_FALSE; |
| 4945 | } |
| 4946 | } |
| 4947 | else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) || |
| 4948 | (WLAN_HDD_P2P_GO == pAdapter->device_mode)) |
| 4949 | { |
| 4950 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) |
| 4951 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4952 | if ((pAdapter->aStaInfo[staId].isUsed) && |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4953 | (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState)) |
| 4954 | { |
| 4955 | staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]); |
| 4956 | |
| 4957 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 4958 | "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the " |
| 4959 | "middle of WPS/EAPOL exchange.", __func__, |
| 4960 | MAC_ADDR_ARRAY(staMac)); |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4961 | return VOS_FALSE; |
| 4962 | } |
| 4963 | } |
| 4964 | } |
| 4965 | } |
| 4966 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 4967 | pAdapterNode = pNext; |
| 4968 | } |
| 4969 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 4970 | "%s: Scan allowed", __func__); |
| 4971 | return VOS_TRUE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4972 | } |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 4973 | |
| 4974 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4975 | * FUNCTION: wlan_hdd_cfg80211_scan |
| 4976 | * this scan respond to scan trigger and update cfg80211 scan database |
| 4977 | * later, scan dump command can be used to recieve scan results |
| 4978 | */ |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 4979 | int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, |
| 4980 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 4981 | struct net_device *dev, |
| 4982 | #endif |
| 4983 | struct cfg80211_scan_request *request) |
| 4984 | { |
| 4985 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) |
| 4986 | struct net_device *dev = request->wdev->netdev; |
| 4987 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 4988 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4989 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter ); |
| 4990 | hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4991 | hdd_config_t *cfg_param = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4992 | tCsrScanRequest scanRequest; |
| 4993 | tANI_U8 *channelList = NULL, i; |
| 4994 | v_U32_t scanId = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 4995 | int status; |
| 4996 | hdd_scaninfo_t *pScanInfo = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4997 | v_U8_t* pP2pIe = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 4998 | |
| 4999 | ENTER(); |
| 5000 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5001 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5002 | __func__,pAdapter->device_mode); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 5003 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 5004 | status = wlan_hdd_validate_context(pHddCtx); |
| 5005 | |
| 5006 | if (0 != status) |
| 5007 | { |
| 5008 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 5009 | "%s: HDD context is not valid", __func__); |
| 5010 | return status; |
| 5011 | } |
| 5012 | |
| 5013 | cfg_param = pHddCtx->cfg_ini; |
| 5014 | pScanInfo = &pHddCtx->scan_info; |
| 5015 | |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 5016 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 5017 | (eConnectionState_Connecting == |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 5018 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 5019 | { |
| 5020 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5021 | "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \ |
| 5022 | WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId); |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 5023 | return -EBUSY; |
| 5024 | } |
| 5025 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5026 | #ifdef WLAN_BTAMP_FEATURE |
| 5027 | //Scan not supported when AMP traffic is on. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 5028 | if (VOS_TRUE == WLANBAP_AmpSessionOn()) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5029 | { |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 5030 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5031 | "%s: No scanning when AMP is on", __func__); |
| 5032 | return -EOPNOTSUPP; |
| 5033 | } |
| 5034 | #endif |
| 5035 | //Scan on any other interface is not supported. |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 5036 | if (pAdapter->device_mode == WLAN_HDD_SOFTAP) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5037 | { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 5038 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5039 | "%s: Not scanning on device_mode = %d", |
| 5040 | __func__, pAdapter->device_mode); |
| 5041 | return -EOPNOTSUPP; |
| 5042 | } |
| 5043 | |
| 5044 | if (TRUE == pScanInfo->mScanPending) |
| 5045 | { |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 5046 | if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ ) |
| 5047 | { |
| 5048 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__); |
| 5049 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 5050 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5051 | } |
| 5052 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5053 | //Don't Allow Scan and return busy if Remain On |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5054 | //Channel and action frame is pending |
| 5055 | //Otherwise Cancel Remain On Channel and allow Scan |
| 5056 | //If no action frame pending |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 5057 | if (0 != wlan_hdd_check_remain_on_channel(pAdapter)) |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5058 | { |
Kiet Lam | ac06e2c | 2013-10-23 16:25:07 +0530 | [diff] [blame] | 5059 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__); |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5060 | return -EBUSY; |
| 5061 | } |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 5062 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 5063 | /* if tdls disagree scan right now, return immediately. |
| 5064 | tdls will schedule the scan when scan is allowed. (return SUCCESS) |
| 5065 | or will reject the scan if any TDLS is in progress. (return -EBUSY) |
| 5066 | */ |
| 5067 | status = wlan_hdd_tdls_scan_callback (pAdapter, |
| 5068 | wiphy, |
| 5069 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
| 5070 | dev, |
Gopichand Nakkala | c3c42b9 | 2013-03-20 19:42:34 -0700 | [diff] [blame] | 5071 | #endif |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 5072 | request); |
| 5073 | if(status <= 0) |
| 5074 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5075 | if(!status) |
| 5076 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress." |
| 5077 | "scan rejected %d", __func__, status); |
| 5078 | else |
| 5079 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d", |
| 5080 | __func__, status); |
| 5081 | |
Gopichand Nakkala | 638ebc7 | 2013-03-21 18:04:02 -0700 | [diff] [blame] | 5082 | return status; |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 5083 | } |
| 5084 | #endif |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5085 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5086 | if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock)) |
| 5087 | { |
| 5088 | VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 1250df4 | 2012-12-10 14:31:52 -0800 | [diff] [blame] | 5089 | "%s: Acquire lock fail", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5090 | return -EAGAIN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5091 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5092 | if (TRUE == pHddCtx->tmInfo.tmAction.enterImps) |
| 5093 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5094 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5095 | "%s: MAX TM Level Scan not allowed", __func__); |
| 5096 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5097 | return -EBUSY; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5098 | } |
| 5099 | mutex_unlock(&pHddCtx->tmInfo.tmOperationLock); |
| 5100 | |
Madan Mohan Koyyalamudi | cfd5374 | 2013-01-11 15:29:03 -0800 | [diff] [blame] | 5101 | /* Check if scan is allowed at this point of time. |
| 5102 | */ |
| 5103 | if (!hdd_isScanAllowed(pHddCtx)) |
| 5104 | { |
| 5105 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__); |
| 5106 | return -EBUSY; |
| 5107 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5108 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5109 | vos_mem_zero( &scanRequest, sizeof(scanRequest)); |
| 5110 | |
| 5111 | if (NULL != request) |
| 5112 | { |
| 5113 | hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d", |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5114 | (int)request->n_ssids); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5115 | |
| 5116 | /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1. |
| 5117 | * Becasue of this, driver is assuming that this is not wildcard scan and so |
| 5118 | * is not aging out the scan results. |
| 5119 | */ |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5120 | if (request->ssids && '\0' == request->ssids->ssid[0]) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5121 | { |
| 5122 | request->n_ssids = 0; |
| 5123 | } |
| 5124 | |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 5125 | if ((request->ssids) && (0 < request->n_ssids)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5126 | { |
| 5127 | tCsrSSIDInfo *SsidInfo; |
| 5128 | int j; |
| 5129 | scanRequest.SSIDs.numOfSSIDs = request->n_ssids; |
| 5130 | /* Allocate num_ssid tCsrSSIDInfo structure */ |
| 5131 | SsidInfo = scanRequest.SSIDs.SSIDList = |
| 5132 | ( tCsrSSIDInfo *)vos_mem_malloc( |
| 5133 | request->n_ssids*sizeof(tCsrSSIDInfo)); |
| 5134 | |
| 5135 | if(NULL == scanRequest.SSIDs.SSIDList) |
| 5136 | { |
| 5137 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5138 | "%s: memory alloc failed SSIDInfo buffer", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5139 | return -ENOMEM; |
| 5140 | } |
| 5141 | |
| 5142 | /* copy all the ssid's and their length */ |
| 5143 | for(j = 0; j < request->n_ssids; j++, SsidInfo++) |
| 5144 | { |
| 5145 | /* get the ssid length */ |
| 5146 | SsidInfo->SSID.length = request->ssids[j].ssid_len; |
| 5147 | vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0], |
| 5148 | SsidInfo->SSID.length); |
| 5149 | SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0'; |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5150 | hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5151 | j, SsidInfo->SSID.ssId); |
| 5152 | } |
| 5153 | /* set the scan type to active */ |
| 5154 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 5155 | } |
| 5156 | else if(WLAN_HDD_P2P_GO == pAdapter->device_mode) |
| 5157 | { |
| 5158 | /* set the scan type to active */ |
| 5159 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 5160 | } |
| 5161 | else |
| 5162 | { |
| 5163 | /*Set the scan type to default type, in this case it is ACTIVE*/ |
| 5164 | scanRequest.scanType = pScanInfo->scan_mode; |
| 5165 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5166 | scanRequest.minChnTime = cfg_param->nActiveMinChnTime; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5167 | scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime; |
| 5168 | } |
| 5169 | else |
| 5170 | { |
| 5171 | /* set the scan type to active */ |
| 5172 | scanRequest.scanType = eSIR_ACTIVE_SCAN; |
| 5173 | vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff ); |
| 5174 | |
| 5175 | /* set min and max channel time to zero */ |
| 5176 | scanRequest.minChnTime = 0; |
| 5177 | scanRequest.maxChnTime = 0; |
| 5178 | } |
| 5179 | |
| 5180 | /* set BSSType to default type */ |
| 5181 | scanRequest.BSSType = eCSR_BSS_TYPE_ANY; |
| 5182 | |
| 5183 | /*TODO: scan the requested channels only*/ |
| 5184 | |
| 5185 | /*Right now scanning all the channels */ |
| 5186 | if( request ) |
| 5187 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5188 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5189 | "No of Scan Channels: %d", request->n_channels); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5190 | if( request->n_channels ) |
| 5191 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5192 | char chList [(request->n_channels*5)+1]; |
| 5193 | int len; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5194 | channelList = vos_mem_malloc( request->n_channels ); |
| 5195 | if( NULL == channelList ) |
| 5196 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 5197 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5198 | "%s: memory alloc failed channelList", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5199 | status = -ENOMEM; |
| 5200 | goto free_mem; |
| 5201 | } |
| 5202 | |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5203 | for( i = 0, len = 0; i < request->n_channels ; i++ ) |
| 5204 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5205 | channelList[i] = request->channels[i]->hw_value; |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5206 | len += snprintf(chList+len, 5, "%d ", channelList[i]); |
| 5207 | } |
| 5208 | |
| 5209 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5210 | "Channel-List: %s ", chList); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5211 | } |
| 5212 | |
| 5213 | scanRequest.ChannelInfo.numOfChannels = request->n_channels; |
| 5214 | scanRequest.ChannelInfo.ChannelList = channelList; |
| 5215 | |
| 5216 | /* set requestType to full scan */ |
| 5217 | scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5218 | |
| 5219 | /* 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] | 5220 | * 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] | 5221 | * 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] | 5222 | */ |
| 5223 | |
| 5224 | /* Supplicant does single channel scan after 8-way handshake |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5225 | * and in that case driver shoudnt flush scan results. If |
| 5226 | * driver flushes the scan results here and unfortunately if |
| 5227 | * the AP doesnt respond to our probe req then association |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 5228 | * fails which is not desired |
| 5229 | */ |
| 5230 | |
| 5231 | if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN ) |
| 5232 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5233 | hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results"); |
Madan Mohan Koyyalamudi | 8d50f31 | 2012-11-27 15:48:57 -0800 | [diff] [blame] | 5234 | sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5235 | pAdapter->sessionId ); |
| 5236 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5237 | |
| 5238 | if( request->ie_len ) |
| 5239 | { |
| 5240 | /* save this for future association (join requires this) */ |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5241 | /*TODO: Array needs to be converted to dynamic allocation, |
| 5242 | * as multiple ie.s can be sent in cfg80211_scan_request structure |
| 5243 | * CR 597966 |
| 5244 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5245 | memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) ); |
| 5246 | memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len); |
| 5247 | pScanInfo->scanAddIE.length = request->ie_len; |
| 5248 | |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5249 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5250 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) || |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5251 | (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5252 | { |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5253 | if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH) |
| 5254 | { |
| 5255 | pwextBuf->roamProfile.nAddIEScanLength = request->ie_len; |
| 5256 | memcpy( pwextBuf->roamProfile.addIEScan, |
| 5257 | request->ie, request->ie_len); |
| 5258 | } |
| 5259 | else |
| 5260 | { |
| 5261 | hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:" |
| 5262 | "%d", request->ie_len); |
| 5263 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5264 | |
Agarwal Ashish | 4f61613 | 2013-12-30 23:32:50 +0530 | [diff] [blame] | 5265 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5266 | scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length; |
| 5267 | scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata; |
| 5268 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5269 | pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie, |
| 5270 | request->ie_len); |
| 5271 | if (pP2pIe != NULL) |
| 5272 | { |
Madan Mohan Koyyalamudi | 26bd714 | 2012-10-30 18:14:19 -0700 | [diff] [blame] | 5273 | #ifdef WLAN_FEATURE_P2P_DEBUG |
| 5274 | if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) || |
| 5275 | (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) && |
| 5276 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 5277 | { |
| 5278 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1; |
| 5279 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 5280 | "Go nego completed to Connection is started"); |
| 5281 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 5282 | "for 8way Handshake"); |
| 5283 | } |
| 5284 | else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) && |
| 5285 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 5286 | { |
| 5287 | globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2; |
| 5288 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from " |
| 5289 | "Disconnected state to Connection is started"); |
| 5290 | hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started " |
| 5291 | "for 4way Handshake"); |
| 5292 | } |
| 5293 | #endif |
| 5294 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5295 | /* no_cck will be set during p2p find to disable 11b rates */ |
| 5296 | if(TRUE == request->no_cck) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5297 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5298 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5299 | "%s: This is a P2P Search", __func__); |
| 5300 | scanRequest.p2pSearch = 1; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5301 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5302 | if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS ) |
| 5303 | { |
Madan Mohan Koyyalamudi | 1b1d9e8 | 2012-10-21 11:38:33 -0700 | [diff] [blame] | 5304 | /* set requestType to P2P Discovery */ |
| 5305 | scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY; |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5306 | } |
| 5307 | |
| 5308 | /* |
| 5309 | Skip Dfs Channel in case of P2P Search |
| 5310 | if it is set in ini file |
| 5311 | */ |
| 5312 | if(cfg_param->skipDfsChnlInP2pSearch) |
| 5313 | { |
| 5314 | scanRequest.skipDfsChnlInP2pSearch = 1; |
| 5315 | } |
| 5316 | else |
| 5317 | { |
| 5318 | scanRequest.skipDfsChnlInP2pSearch = 0; |
| 5319 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5320 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5321 | } |
| 5322 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5323 | } |
| 5324 | } |
| 5325 | |
| 5326 | INIT_COMPLETION(pScanInfo->scan_req_completion_event); |
| 5327 | |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 5328 | /* acquire the wakelock to avoid the apps suspend during the scan. To |
| 5329 | * address the following issues. |
| 5330 | * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in |
| 5331 | * BMPS/IMPS this result in android trying to suspend aggressively and backing off |
| 5332 | * for long time, this result in apps running at full power for long time. |
| 5333 | * 2) Connected scenario: If we allow the suspend during the scan, RIVA will |
| 5334 | * be stuck in full power because of resume BMPS |
| 5335 | */ |
| 5336 | hdd_prevent_suspend(); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5337 | |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5338 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, |
| 5339 | "requestType %d, scanType %d, minChnTime %d, maxChnTime %d," |
| 5340 | "p2pSearch %d, skipDfsChnlInP2pSearch %d", scanRequest.requestType, |
| 5341 | scanRequest.scanType, scanRequest.minChnTime, scanRequest.maxChnTime, |
| 5342 | scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch); |
| 5343 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5344 | status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5345 | pAdapter->sessionId, &scanRequest, &scanId, |
| 5346 | &hdd_cfg80211_scan_done_callback, dev ); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5347 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5348 | if (eHAL_STATUS_SUCCESS != status) |
| 5349 | { |
| 5350 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5351 | "%s: sme_ScanRequest returned error %d", __func__, status); |
| 5352 | complete(&pScanInfo->scan_req_completion_event); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 5353 | if(eHAL_STATUS_RESOURCES == status) |
| 5354 | { |
Nirav Shah | 20ac06f | 2013-12-12 18:14:06 +0530 | [diff] [blame] | 5355 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress." |
| 5356 | "So defer the scan by informing busy",__func__); |
Madan Mohan Koyyalamudi | 3b230fe | 2012-10-18 14:46:32 -0700 | [diff] [blame] | 5357 | status = -EBUSY; |
| 5358 | } else { |
| 5359 | status = -EIO; |
| 5360 | } |
Madan Mohan Koyyalamudi | 9f5a10c | 2012-09-28 14:46:16 -0700 | [diff] [blame] | 5361 | hdd_allow_suspend(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5362 | goto free_mem; |
| 5363 | } |
| 5364 | |
| 5365 | pScanInfo->mScanPending = TRUE; |
| 5366 | pAdapter->request = request; |
| 5367 | pScanInfo->scanId = scanId; |
| 5368 | |
| 5369 | complete(&pScanInfo->scan_req_completion_event); |
| 5370 | |
| 5371 | free_mem: |
| 5372 | if( scanRequest.SSIDs.SSIDList ) |
| 5373 | { |
| 5374 | vos_mem_free(scanRequest.SSIDs.SSIDList); |
| 5375 | } |
| 5376 | |
| 5377 | if( channelList ) |
| 5378 | vos_mem_free( channelList ); |
| 5379 | |
| 5380 | EXIT(); |
| 5381 | |
| 5382 | return status; |
| 5383 | } |
| 5384 | |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5385 | |
| 5386 | void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel) |
| 5387 | { |
| 5388 | v_U8_t iniDot11Mode = |
| 5389 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode; |
| 5390 | eHddDot11Mode hddDot11Mode = iniDot11Mode; |
| 5391 | |
| 5392 | switch ( iniDot11Mode ) |
| 5393 | { |
| 5394 | case eHDD_DOT11_MODE_AUTO: |
| 5395 | case eHDD_DOT11_MODE_11ac: |
| 5396 | case eHDD_DOT11_MODE_11ac_ONLY: |
| 5397 | #ifdef WLAN_FEATURE_11AC |
| 5398 | hddDot11Mode = eHDD_DOT11_MODE_11ac; |
| 5399 | #else |
| 5400 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 5401 | #endif |
| 5402 | break; |
| 5403 | case eHDD_DOT11_MODE_11n: |
| 5404 | case eHDD_DOT11_MODE_11n_ONLY: |
| 5405 | hddDot11Mode = eHDD_DOT11_MODE_11n; |
| 5406 | break; |
| 5407 | default: |
| 5408 | hddDot11Mode = iniDot11Mode; |
| 5409 | break; |
| 5410 | } |
| 5411 | /* This call decides required channel bonding mode */ |
| 5412 | sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal), |
| 5413 | hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode), |
| 5414 | operationChannel); |
| 5415 | } |
| 5416 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5417 | /* |
| 5418 | * FUNCTION: wlan_hdd_cfg80211_connect_start |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5419 | * This function is used to start the association process |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5420 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5421 | int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter, |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5422 | const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5423 | { |
| 5424 | int status = 0; |
| 5425 | hdd_wext_state_t *pWextState; |
| 5426 | v_U32_t roamId; |
| 5427 | tCsrRoamProfile *pRoamProfile; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5428 | eCsrAuthType RSNAuthType; |
| 5429 | |
| 5430 | ENTER(); |
| 5431 | |
| 5432 | pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5433 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5434 | if (SIR_MAC_MAX_SSID_LENGTH < ssid_len) |
| 5435 | { |
| 5436 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__); |
| 5437 | return -EINVAL; |
| 5438 | } |
| 5439 | |
| 5440 | pRoamProfile = &pWextState->roamProfile; |
| 5441 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5442 | if (pRoamProfile) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5443 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 5444 | hdd_station_ctx_t *pHddStaCtx; |
| 5445 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5446 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5447 | if (HDD_WMM_USER_MODE_NO_QOS == |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5448 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode) |
| 5449 | { |
| 5450 | /*QoS not enabled in cfg file*/ |
| 5451 | pRoamProfile->uapsd_mask = 0; |
| 5452 | } |
| 5453 | else |
| 5454 | { |
| 5455 | /*QoS enabled, update uapsd mask from cfg file*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5456 | pRoamProfile->uapsd_mask = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5457 | (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask; |
| 5458 | } |
| 5459 | |
| 5460 | pRoamProfile->SSIDs.numOfSSIDs = 1; |
| 5461 | pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len; |
| 5462 | vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5463 | sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5464 | vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId), |
| 5465 | ssid, ssid_len); |
| 5466 | |
| 5467 | if (bssid) |
| 5468 | { |
| 5469 | pRoamProfile->BSSIDs.numOfBSSIDs = 1; |
| 5470 | vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid, |
| 5471 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5472 | /* Save BSSID in seperate variable as well, as RoamProfile |
| 5473 | BSSID is getting zeroed out in the association process. And in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5474 | case of join failure we should send valid BSSID to supplicant |
| 5475 | */ |
| 5476 | vos_mem_copy((void *)(pWextState->req_bssId), bssid, |
| 5477 | WNI_CFG_BSSID_LEN); |
| 5478 | } |
Dhanashri Atre | 51981c6 | 2013-06-13 11:47:57 -0700 | [diff] [blame] | 5479 | else |
| 5480 | { |
| 5481 | vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN); |
| 5482 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5483 | |
| 5484 | if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) || |
| 5485 | (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion)) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5486 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5487 | /*set gen ie*/ |
| 5488 | hdd_SetGENIEToCsr(pAdapter, &RSNAuthType); |
| 5489 | /*set auth*/ |
| 5490 | hdd_set_csr_auth_type(pAdapter, RSNAuthType); |
| 5491 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5492 | #ifdef FEATURE_WLAN_WAPI |
| 5493 | if (pAdapter->wapi_info.nWapiMode) |
| 5494 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5495 | hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5496 | switch (pAdapter->wapi_info.wapiAuthMode) |
| 5497 | { |
| 5498 | case WAPI_AUTH_MODE_PSK: |
| 5499 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5500 | hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5501 | pAdapter->wapi_info.wapiAuthMode); |
| 5502 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK; |
| 5503 | break; |
| 5504 | } |
| 5505 | case WAPI_AUTH_MODE_CERT: |
| 5506 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5507 | hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5508 | pAdapter->wapi_info.wapiAuthMode); |
| 5509 | pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE; |
| 5510 | break; |
| 5511 | } |
| 5512 | } // End of switch |
| 5513 | if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK || |
| 5514 | pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) |
| 5515 | { |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 5516 | hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5517 | pRoamProfile->AuthType.numEntries = 1; |
| 5518 | pRoamProfile->EncryptionType.numEntries = 1; |
| 5519 | pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 5520 | pRoamProfile->mcEncryptionType.numEntries = 1; |
| 5521 | pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI; |
| 5522 | } |
| 5523 | } |
| 5524 | #endif /* FEATURE_WLAN_WAPI */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5525 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 5526 | /* Initializing gtkOffloadReqParams */ |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5527 | if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) || |
| 5528 | (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
| 5529 | { |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 5530 | memset(&pHddStaCtx->gtkOffloadReqParams, 0, |
| 5531 | sizeof (tSirGtkOffloadParams)); |
| 5532 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 5533 | } |
| 5534 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5535 | pRoamProfile->csrPersona = pAdapter->device_mode; |
| 5536 | |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 5537 | if( operatingChannel ) |
| 5538 | { |
| 5539 | pRoamProfile->ChannelInfo.ChannelList = &operatingChannel; |
| 5540 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 5541 | } |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 5542 | else |
| 5543 | { |
| 5544 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 5545 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 5546 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 5547 | if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel) |
| 5548 | { |
| 5549 | hdd_select_cbmode(pAdapter,operatingChannel); |
| 5550 | } |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5551 | /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect() |
| 5552 | * 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] | 5553 | * 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] | 5554 | * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback() |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5555 | * if sme_RomConnect is to be queued, Connecting state will remain until it is completed. |
| 5556 | */ |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 5557 | if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 5558 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5559 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
| 5560 | eConnectionState_Connecting); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5561 | |
| 5562 | status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5563 | pAdapter->sessionId, pRoamProfile, &roamId); |
| 5564 | |
Gopichand Nakkala | a3c8fb6 | 2013-06-21 15:36:42 +0530 | [diff] [blame] | 5565 | if ((eHAL_STATUS_SUCCESS != status) && |
| 5566 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode || |
| 5567 | WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5568 | |
| 5569 | { |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5570 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with " |
| 5571 | "status %d. -> NotConnected", __func__, pAdapter->sessionId, status); |
| 5572 | /* change back to NotAssociated */ |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5573 | hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), |
Madan Mohan Koyyalamudi | 42dcd16 | 2012-12-03 16:34:04 -0800 | [diff] [blame] | 5574 | eConnectionState_NotConnected); |
Madan Mohan Koyyalamudi | d5acbf5 | 2012-11-28 01:45:08 +0530 | [diff] [blame] | 5575 | } |
Madan Mohan Koyyalamudi | df86c42 | 2012-12-04 17:03:44 -0800 | [diff] [blame] | 5576 | |
| 5577 | pRoamProfile->ChannelInfo.ChannelList = NULL; |
| 5578 | pRoamProfile->ChannelInfo.numOfChannels = 0; |
| 5579 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5580 | } |
| 5581 | else |
| 5582 | { |
| 5583 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__); |
| 5584 | return -EINVAL; |
| 5585 | } |
Madan Mohan Koyyalamudi | fd4e1da | 2012-11-09 17:50:19 -0800 | [diff] [blame] | 5586 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5587 | return status; |
| 5588 | } |
| 5589 | |
| 5590 | /* |
| 5591 | * FUNCTION: wlan_hdd_set_cfg80211_auth_type |
| 5592 | * This function is used to set the authentication type (OPEN/SHARED). |
| 5593 | * |
| 5594 | */ |
| 5595 | static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter, |
| 5596 | enum nl80211_auth_type auth_type) |
| 5597 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5598 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5599 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5600 | |
| 5601 | ENTER(); |
| 5602 | |
| 5603 | /*set authentication type*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5604 | switch (auth_type) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5605 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5606 | case NL80211_AUTHTYPE_AUTOMATIC: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5607 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 5608 | "%s: set authentication type to AUTOSWITCH", __func__); |
| 5609 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH; |
| 5610 | break; |
| 5611 | |
| 5612 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 5613 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5614 | case NL80211_AUTHTYPE_FT: |
| 5615 | #endif /* WLAN_FEATURE_VOWIFI_11R */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5616 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5617 | "%s: set authentication type to OPEN", __func__); |
| 5618 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 5619 | break; |
| 5620 | |
| 5621 | case NL80211_AUTHTYPE_SHARED_KEY: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5622 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5623 | "%s: set authentication type to SHARED", __func__); |
| 5624 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY; |
| 5625 | break; |
| 5626 | #ifdef FEATURE_WLAN_CCX |
| 5627 | case NL80211_AUTHTYPE_NETWORK_EAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5628 | hddLog(VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5629 | "%s: set authentication type to CCKM WPA", __func__); |
| 5630 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required. |
| 5631 | break; |
| 5632 | #endif |
| 5633 | |
| 5634 | |
| 5635 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5636 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 5637 | "%s: Unsupported authentication type %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5638 | auth_type); |
| 5639 | pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN; |
| 5640 | return -EINVAL; |
| 5641 | } |
| 5642 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5643 | pWextState->roamProfile.AuthType.authType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5644 | pHddStaCtx->conn_info.authType; |
| 5645 | return 0; |
| 5646 | } |
| 5647 | |
| 5648 | /* |
| 5649 | * FUNCTION: wlan_hdd_set_akm_suite |
| 5650 | * This function is used to set the key mgmt type(PSK/8021x). |
| 5651 | * |
| 5652 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5653 | static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5654 | u32 key_mgmt |
| 5655 | ) |
| 5656 | { |
| 5657 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5658 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5659 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5660 | /*set key mgmt type*/ |
| 5661 | switch(key_mgmt) |
| 5662 | { |
| 5663 | case WLAN_AKM_SUITE_PSK: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5664 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5665 | case WLAN_AKM_SUITE_FT_PSK: |
| 5666 | #endif |
| 5667 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5668 | __func__); |
| 5669 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK; |
| 5670 | break; |
| 5671 | |
| 5672 | case WLAN_AKM_SUITE_8021X: |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 5673 | #ifdef WLAN_FEATURE_VOWIFI_11R |
| 5674 | case WLAN_AKM_SUITE_FT_8021X: |
| 5675 | #endif |
| 5676 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5677 | __func__); |
| 5678 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X; |
| 5679 | break; |
| 5680 | #ifdef FEATURE_WLAN_CCX |
| 5681 | #define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */ |
| 5682 | #define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */ |
| 5683 | case WLAN_AKM_SUITE_CCKM: |
| 5684 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM", |
| 5685 | __func__); |
| 5686 | pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM; |
| 5687 | break; |
| 5688 | #endif |
| 5689 | |
| 5690 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5691 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5692 | __func__, key_mgmt); |
| 5693 | return -EINVAL; |
| 5694 | |
| 5695 | } |
| 5696 | return 0; |
| 5697 | } |
| 5698 | |
| 5699 | /* |
| 5700 | * FUNCTION: wlan_hdd_cfg80211_set_cipher |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5701 | * This function is used to set the encryption type |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5702 | * (NONE/WEP40/WEP104/TKIP/CCMP). |
| 5703 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5704 | static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter, |
| 5705 | u32 cipher, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5706 | bool ucast |
| 5707 | ) |
| 5708 | { |
| 5709 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5710 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5711 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 5712 | |
| 5713 | ENTER(); |
| 5714 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5715 | if (!cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5716 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5717 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5718 | __func__, cipher); |
| 5719 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5720 | } |
| 5721 | else |
| 5722 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5723 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5724 | /*set encryption method*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5725 | switch (cipher) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5726 | { |
| 5727 | case IW_AUTH_CIPHER_NONE: |
| 5728 | encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 5729 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5730 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5731 | case WLAN_CIPHER_SUITE_WEP40: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5732 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5733 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5734 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5735 | case WLAN_CIPHER_SUITE_WEP104: |
Gopichand Nakkala | 2914956 | 2013-05-10 21:43:41 +0530 | [diff] [blame] | 5736 | encryptionType = eCSR_ENCRYPT_TYPE_WEP104; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5737 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5738 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5739 | case WLAN_CIPHER_SUITE_TKIP: |
| 5740 | encryptionType = eCSR_ENCRYPT_TYPE_TKIP; |
| 5741 | break; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5742 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5743 | case WLAN_CIPHER_SUITE_CCMP: |
| 5744 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 5745 | break; |
| 5746 | #ifdef FEATURE_WLAN_WAPI |
| 5747 | case WLAN_CIPHER_SUITE_SMS4: |
| 5748 | encryptionType = eCSR_ENCRYPT_TYPE_WPI; |
| 5749 | break; |
| 5750 | #endif |
| 5751 | |
| 5752 | #ifdef FEATURE_WLAN_CCX |
| 5753 | case WLAN_CIPHER_SUITE_KRK: |
| 5754 | encryptionType = eCSR_ENCRYPT_TYPE_KRK; |
| 5755 | break; |
| 5756 | #endif |
| 5757 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5758 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5759 | __func__, cipher); |
| 5760 | return -EOPNOTSUPP; |
| 5761 | } |
| 5762 | } |
| 5763 | |
| 5764 | if (ucast) |
| 5765 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5766 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5767 | __func__, encryptionType); |
| 5768 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 5769 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5770 | pWextState->roamProfile.EncryptionType.encryptionType[0] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5771 | encryptionType; |
| 5772 | } |
| 5773 | else |
| 5774 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5775 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5776 | __func__, encryptionType); |
| 5777 | pHddStaCtx->conn_info.mcEncryptionType = encryptionType; |
| 5778 | pWextState->roamProfile.mcEncryptionType.numEntries = 1; |
| 5779 | pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType; |
| 5780 | } |
| 5781 | |
| 5782 | return 0; |
| 5783 | } |
| 5784 | |
| 5785 | |
| 5786 | /* |
| 5787 | * FUNCTION: wlan_hdd_cfg80211_set_ie |
| 5788 | * This function is used to parse WPA/RSN IE's. |
| 5789 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5790 | int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter, |
| 5791 | u8 *ie, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5792 | size_t ie_len |
| 5793 | ) |
| 5794 | { |
| 5795 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 5796 | u8 *genie = ie; |
| 5797 | v_U16_t remLen = ie_len; |
| 5798 | #ifdef FEATURE_WLAN_WAPI |
| 5799 | v_U32_t akmsuite[MAX_NUM_AKM_SUITES]; |
| 5800 | u16 *tmp; |
| 5801 | v_U16_t akmsuiteCount; |
| 5802 | int *akmlist; |
| 5803 | #endif |
| 5804 | ENTER(); |
| 5805 | |
| 5806 | /* clear previous assocAddIE */ |
| 5807 | pWextState->assocAddIE.length = 0; |
| 5808 | pWextState->roamProfile.bWPSAssociation = VOS_FALSE; |
| 5809 | |
| 5810 | while (remLen >= 2) |
| 5811 | { |
| 5812 | v_U16_t eLen = 0; |
| 5813 | v_U8_t elementId; |
| 5814 | elementId = *genie++; |
| 5815 | eLen = *genie++; |
| 5816 | remLen -= 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5817 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 5818 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5819 | __func__, elementId, eLen); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5820 | |
| 5821 | switch ( elementId ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5822 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5823 | case DOT11F_EID_WPA: |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5824 | 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] | 5825 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5826 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5827 | "%s: Invalid WPA IE", __func__); |
| 5828 | return -EINVAL; |
| 5829 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5830 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5831 | { |
| 5832 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5833 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5834 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5835 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5836 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5837 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5838 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. " |
| 5839 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5840 | VOS_ASSERT(0); |
| 5841 | return -ENOMEM; |
| 5842 | } |
| 5843 | // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5844 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5845 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5846 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5847 | pWextState->roamProfile.bWPSAssociation = VOS_TRUE; |
| 5848 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5849 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5850 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5851 | else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3)) |
| 5852 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5853 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2); |
| 5854 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 5855 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/); |
| 5856 | pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE; |
| 5857 | pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len; |
| 5858 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5859 | else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE, |
Kiet Lam | 8da9899 | 2013-11-21 15:59:07 +0530 | [diff] [blame] | 5860 | P2P_OUI_TYPE_SIZE))) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5861 | { |
| 5862 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5863 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5864 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5865 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5866 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5867 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5868 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5869 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5870 | VOS_ASSERT(0); |
| 5871 | return -ENOMEM; |
| 5872 | } |
| 5873 | // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE |
| 5874 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5875 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5876 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5877 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5878 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5879 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5880 | #ifdef WLAN_FEATURE_WFD |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5881 | else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE, |
| 5882 | WFD_OUI_TYPE_SIZE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5883 | /*Consider WFD IE, only for P2P Client */ |
| 5884 | && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ) |
| 5885 | { |
| 5886 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5887 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5888 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5889 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5890 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5891 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5892 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5893 | "Need bigger buffer space"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5894 | VOS_ASSERT(0); |
| 5895 | return -ENOMEM; |
| 5896 | } |
| 5897 | // WFD IE is saved to Additional IE ; it should be accumulated to handle |
| 5898 | // WPS IE + P2P IE + WFD IE |
| 5899 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5900 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5901 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 5902 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5903 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5904 | } |
| 5905 | #endif |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5906 | /* Appending HS 2.0 Indication Element in Assiciation Request */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5907 | else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE, |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5908 | HS20_OUI_TYPE_SIZE)) ) |
| 5909 | { |
| 5910 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 5911 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)", |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5912 | __func__, eLen + 2); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5913 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5914 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 5915 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 5916 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 5917 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5918 | VOS_ASSERT(0); |
| 5919 | return -ENOMEM; |
| 5920 | } |
| 5921 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 5922 | pWextState->assocAddIE.length += eLen + 2; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5923 | |
Madan Mohan Koyyalamudi | 1bed598 | 2012-10-22 14:38:06 -0700 | [diff] [blame] | 5924 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 5925 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 5926 | } |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 5927 | |
Praveen Kumar Sirisilla | 7d68b7b | 2013-09-22 14:01:42 -0700 | [diff] [blame] | 5928 | if (WLAN_HDD_IBSS == pAdapter->device_mode) { |
| 5929 | |
| 5930 | /* populating as ADDIE in beacon frames */ |
| 5931 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5932 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2, |
| 5933 | NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS) |
| 5934 | { |
| 5935 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5936 | WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL, |
| 5937 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 5938 | { |
| 5939 | hddLog(LOGE, |
| 5940 | "Coldn't pass " |
| 5941 | "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM"); |
| 5942 | } |
| 5943 | }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/ |
| 5944 | else |
| 5945 | hddLog(LOGE, |
| 5946 | "Could not pass on " |
| 5947 | "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM"); |
| 5948 | |
| 5949 | /* IBSS mode doesn't contain params->proberesp_ies still |
| 5950 | beaconIE's need to be populated in probe response frames */ |
| 5951 | if ( (NULL != (genie - 2)) && (0 != eLen + 2) ) |
| 5952 | { |
| 5953 | u16 rem_probe_resp_ie_len = eLen + 2; |
| 5954 | u8 probe_rsp_ie_len[3] = {0}; |
| 5955 | u8 counter = 0; |
| 5956 | |
| 5957 | /* Check Probe Resp Length if it is greater then 255 then |
| 5958 | Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 |
| 5959 | & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are |
| 5960 | not able Store More then 255 bytes into One Variable */ |
| 5961 | |
| 5962 | while ((rem_probe_resp_ie_len > 0) && (counter < 3)) |
| 5963 | { |
| 5964 | if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN) |
| 5965 | { |
| 5966 | probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN; |
| 5967 | rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN; |
| 5968 | } |
| 5969 | else |
| 5970 | { |
| 5971 | probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len; |
| 5972 | rem_probe_resp_ie_len = 0; |
| 5973 | } |
| 5974 | } |
| 5975 | |
| 5976 | rem_probe_resp_ie_len = 0; |
| 5977 | |
| 5978 | if (probe_rsp_ie_len[0] > 0) |
| 5979 | { |
| 5980 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5981 | WNI_CFG_PROBE_RSP_ADDNIE_DATA1, |
| 5982 | (tANI_U8*)(genie - 2), |
| 5983 | probe_rsp_ie_len[0], NULL, |
| 5984 | eANI_BOOLEAN_FALSE) |
| 5985 | == eHAL_STATUS_FAILURE) |
| 5986 | { |
| 5987 | hddLog(LOGE, |
| 5988 | "Could not pass" |
| 5989 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM"); |
| 5990 | } |
| 5991 | rem_probe_resp_ie_len += probe_rsp_ie_len[0]; |
| 5992 | } |
| 5993 | |
| 5994 | if (probe_rsp_ie_len[1] > 0) |
| 5995 | { |
| 5996 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 5997 | WNI_CFG_PROBE_RSP_ADDNIE_DATA2, |
| 5998 | (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)), |
| 5999 | probe_rsp_ie_len[1], NULL, |
| 6000 | eANI_BOOLEAN_FALSE) |
| 6001 | == eHAL_STATUS_FAILURE) |
| 6002 | { |
| 6003 | hddLog(LOGE, |
| 6004 | "Could not pass" |
| 6005 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM"); |
| 6006 | } |
| 6007 | rem_probe_resp_ie_len += probe_rsp_ie_len[1]; |
| 6008 | } |
| 6009 | |
| 6010 | if (probe_rsp_ie_len[2] > 0) |
| 6011 | { |
| 6012 | if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6013 | WNI_CFG_PROBE_RSP_ADDNIE_DATA3, |
| 6014 | (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)), |
| 6015 | probe_rsp_ie_len[2], NULL, |
| 6016 | eANI_BOOLEAN_FALSE) |
| 6017 | == eHAL_STATUS_FAILURE) |
| 6018 | { |
| 6019 | hddLog(LOGE, |
| 6020 | "Could not pass" |
| 6021 | "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM"); |
| 6022 | } |
| 6023 | rem_probe_resp_ie_len += probe_rsp_ie_len[2]; |
| 6024 | } |
| 6025 | |
| 6026 | if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6027 | WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL, |
| 6028 | eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE) |
| 6029 | { |
| 6030 | hddLog(LOGE, |
| 6031 | "Could not pass" |
| 6032 | "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM"); |
| 6033 | } |
| 6034 | } |
| 6035 | else |
| 6036 | { |
| 6037 | // Reset WNI_CFG_PROBE_RSP Flags |
| 6038 | wlan_hdd_reset_prob_rspies(pAdapter); |
| 6039 | |
| 6040 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6041 | "%s: No Probe Response IE received in set beacon", |
| 6042 | __func__); |
| 6043 | } |
| 6044 | } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6045 | break; |
| 6046 | case DOT11F_EID_RSN: |
| 6047 | hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2); |
| 6048 | memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN ); |
| 6049 | memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/); |
| 6050 | pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE; |
| 6051 | pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len; |
| 6052 | break; |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 6053 | /* Appending Extended Capabilities with Interworking bit set in Assoc Req */ |
| 6054 | case DOT11F_EID_EXTCAP: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6055 | { |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 6056 | v_U16_t curAddIELen = pWextState->assocAddIE.length; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6057 | 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] | 6058 | __func__, eLen + 2); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6059 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 6060 | if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) ) |
| 6061 | { |
Jeff Johnson | 902c983 | 2012-12-10 14:28:09 -0800 | [diff] [blame] | 6062 | hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE " |
| 6063 | "Need bigger buffer space"); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 6064 | VOS_ASSERT(0); |
| 6065 | return -ENOMEM; |
| 6066 | } |
| 6067 | memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2); |
| 6068 | pWextState->assocAddIE.length += eLen + 2; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6069 | |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 6070 | pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata; |
| 6071 | pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length; |
| 6072 | break; |
| 6073 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6074 | #ifdef FEATURE_WLAN_WAPI |
| 6075 | case WLAN_EID_WAPI: |
| 6076 | pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1 |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 6077 | hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6078 | pAdapter->wapi_info.nWapiMode); |
| 6079 | tmp = (u16 *)ie; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6080 | tmp = tmp + 2; // Skip element Id and Len, Version |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6081 | akmsuiteCount = WPA_GET_LE16(tmp); |
| 6082 | tmp = tmp + 1; |
| 6083 | akmlist = (int *)(tmp); |
| 6084 | if(akmsuiteCount <= MAX_NUM_AKM_SUITES) |
| 6085 | { |
| 6086 | memcpy(akmsuite, akmlist, (4*akmsuiteCount)); |
| 6087 | } |
| 6088 | else |
| 6089 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6090 | hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6091 | VOS_ASSERT(0); |
| 6092 | return -EINVAL; |
| 6093 | } |
| 6094 | |
| 6095 | if (WAPI_PSK_AKM_SUITE == akmsuite[0]) |
| 6096 | { |
| 6097 | 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] | 6098 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6099 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6100 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6101 | if (WAPI_CERT_AKM_SUITE == akmsuite[0]) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6102 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6103 | 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] | 6104 | __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6105 | pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT; |
| 6106 | } |
| 6107 | break; |
| 6108 | #endif |
| 6109 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6110 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6111 | "%s Set UNKNOWN IE %X", __func__, elementId); |
Madan Mohan Koyyalamudi | ef3b66e | 2012-10-11 14:29:42 -0700 | [diff] [blame] | 6112 | /* when Unknown IE is received we should break and continue |
| 6113 | * to the next IE in the buffer instead we were returning |
| 6114 | * so changing this to break */ |
| 6115 | break; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6116 | } |
| 6117 | genie += eLen; |
| 6118 | remLen -= eLen; |
| 6119 | } |
| 6120 | EXIT(); |
| 6121 | return 0; |
| 6122 | } |
| 6123 | |
| 6124 | /* |
Gopichand Nakkala | 18f0c26 | 2013-05-07 23:25:08 +0530 | [diff] [blame] | 6125 | * FUNCTION: hdd_isWPAIEPresent |
| 6126 | * Parse the received IE to find the WPA IE |
| 6127 | * |
| 6128 | */ |
| 6129 | static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len) |
| 6130 | { |
| 6131 | v_U8_t eLen = 0; |
| 6132 | v_U16_t remLen = ie_len; |
| 6133 | v_U8_t elementId = 0; |
| 6134 | |
| 6135 | while (remLen >= 2) |
| 6136 | { |
| 6137 | elementId = *ie++; |
| 6138 | eLen = *ie++; |
| 6139 | remLen -= 2; |
| 6140 | if (eLen > remLen) |
| 6141 | { |
| 6142 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6143 | "%s: IE length is wrong %d", __func__, eLen); |
| 6144 | return FALSE; |
| 6145 | } |
| 6146 | if ((elementId == DOT11F_EID_WPA) && (remLen > 5)) |
| 6147 | { |
| 6148 | /* OUI - 0x00 0X50 0XF2 |
| 6149 | WPA Information Element - 0x01 |
| 6150 | WPA version - 0x01*/ |
| 6151 | if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5)) |
| 6152 | return TRUE; |
| 6153 | } |
| 6154 | ie += eLen; |
| 6155 | remLen -= eLen; |
| 6156 | } |
| 6157 | return FALSE; |
| 6158 | } |
| 6159 | |
| 6160 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6161 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6162 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6163 | * parameters during connect operation. |
| 6164 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6165 | int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6166 | struct cfg80211_connect_params *req |
| 6167 | ) |
| 6168 | { |
| 6169 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6170 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6171 | ENTER(); |
| 6172 | |
| 6173 | /*set wpa version*/ |
| 6174 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
| 6175 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6176 | if (req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6177 | { |
Gopichand Nakkala | 781ded4 | 2013-06-28 12:10:45 +0530 | [diff] [blame] | 6178 | if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6179 | { |
| 6180 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 6181 | } |
| 6182 | else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions) |
| 6183 | { |
| 6184 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 6185 | } |
| 6186 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6187 | |
| 6188 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6189 | pWextState->wpaVersion); |
| 6190 | |
| 6191 | /*set authentication type*/ |
| 6192 | status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type); |
| 6193 | |
| 6194 | if (0 > status) |
| 6195 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6196 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6197 | "%s: failed to set authentication type ", __func__); |
| 6198 | return status; |
| 6199 | } |
| 6200 | |
| 6201 | /*set key mgmt type*/ |
| 6202 | if (req->crypto.n_akm_suites) |
| 6203 | { |
| 6204 | status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]); |
| 6205 | if (0 > status) |
| 6206 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6207 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6208 | __func__); |
| 6209 | return status; |
| 6210 | } |
| 6211 | } |
| 6212 | |
| 6213 | /*set pairwise cipher type*/ |
| 6214 | if (req->crypto.n_ciphers_pairwise) |
| 6215 | { |
| 6216 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, |
| 6217 | req->crypto.ciphers_pairwise[0], true); |
| 6218 | if (0 > status) |
| 6219 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6220 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6221 | "%s: failed to set unicast cipher type", __func__); |
| 6222 | return status; |
| 6223 | } |
| 6224 | } |
| 6225 | else |
| 6226 | { |
| 6227 | /*Reset previous cipher suite to none*/ |
| 6228 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true); |
| 6229 | if (0 > status) |
| 6230 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6231 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6232 | "%s: failed to set unicast cipher type", __func__); |
| 6233 | return status; |
| 6234 | } |
| 6235 | } |
| 6236 | |
| 6237 | /*set group cipher type*/ |
| 6238 | status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group, |
| 6239 | false); |
| 6240 | |
| 6241 | if (0 > status) |
| 6242 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6243 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6244 | __func__); |
| 6245 | return status; |
| 6246 | } |
| 6247 | |
Chet Lanctot | 186b573 | 2013-03-18 10:26:30 -0700 | [diff] [blame] | 6248 | #ifdef WLAN_FEATURE_11W |
| 6249 | pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED); |
| 6250 | #endif |
| 6251 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6252 | /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/ |
| 6253 | if (req->ie_len) |
| 6254 | { |
| 6255 | status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len); |
| 6256 | if ( 0 > status) |
| 6257 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6258 | 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] | 6259 | __func__); |
| 6260 | return status; |
| 6261 | } |
| 6262 | } |
| 6263 | |
| 6264 | /*incase of WEP set default key information*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6265 | if (req->key && req->key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6266 | { |
| 6267 | if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0]) |
| 6268 | || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0]) |
| 6269 | ) |
| 6270 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6271 | if ( IW_AUTH_KEY_MGMT_802_1X |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6272 | == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X )) |
| 6273 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6274 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6275 | __func__); |
| 6276 | return -EOPNOTSUPP; |
| 6277 | } |
| 6278 | else |
| 6279 | { |
| 6280 | u8 key_len = req->key_len; |
| 6281 | u8 key_idx = req->key_idx; |
| 6282 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6283 | if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6284 | && (CSR_MAX_NUM_KEY > key_idx) |
| 6285 | ) |
| 6286 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6287 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 6288 | "%s: setting default wep key, key_idx = %hu key_len %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6289 | __func__, key_idx, key_len); |
| 6290 | vos_mem_copy( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6291 | &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0], |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6292 | req->key, key_len); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6293 | pWextState->roamProfile.Keys.KeyLength[key_idx] = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6294 | (u8)key_len; |
| 6295 | pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx; |
| 6296 | } |
| 6297 | } |
| 6298 | } |
| 6299 | } |
| 6300 | |
| 6301 | return status; |
| 6302 | } |
| 6303 | |
| 6304 | /* |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 6305 | * FUNCTION: wlan_hdd_try_disconnect |
| 6306 | * This function is used to disconnect from previous |
| 6307 | * connection |
| 6308 | */ |
| 6309 | static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter ) |
| 6310 | { |
| 6311 | long ret = 0; |
| 6312 | hdd_station_ctx_t *pHddStaCtx; |
| 6313 | eMib_dot11DesiredBssType connectedBssType; |
| 6314 | |
| 6315 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 6316 | |
| 6317 | hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType ); |
| 6318 | |
| 6319 | if((eMib_dot11DesiredBssType_independent == connectedBssType) || |
| 6320 | (eConnectionState_Associated == pHddStaCtx->conn_info.connState) || |
| 6321 | (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)) |
| 6322 | { |
| 6323 | /* Issue disconnect to CSR */ |
| 6324 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 6325 | if( eHAL_STATUS_SUCCESS == |
| 6326 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6327 | pAdapter->sessionId, |
| 6328 | eCSR_DISCONNECT_REASON_UNSPECIFIED ) ) |
| 6329 | { |
| 6330 | ret = wait_for_completion_interruptible_timeout( |
| 6331 | &pAdapter->disconnect_comp_var, |
| 6332 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6333 | if (0 >= ret) |
| 6334 | { |
| 6335 | hddLog(LOGE, FL("Failed to receive disconnect event")); |
| 6336 | return -EALREADY; |
| 6337 | } |
| 6338 | } |
| 6339 | } |
| 6340 | else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) |
| 6341 | { |
| 6342 | ret = wait_for_completion_interruptible_timeout( |
| 6343 | &pAdapter->disconnect_comp_var, |
| 6344 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
| 6345 | if (0 >= ret) |
| 6346 | { |
| 6347 | hddLog(LOGE, FL("Failed to receive disconnect event")); |
| 6348 | return -EALREADY; |
| 6349 | } |
| 6350 | } |
| 6351 | |
| 6352 | return 0; |
| 6353 | } |
| 6354 | |
| 6355 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6356 | * FUNCTION: wlan_hdd_cfg80211_set_privacy |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6357 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6358 | * parameters during connect operation. |
| 6359 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6360 | static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6361 | struct net_device *ndev, |
| 6362 | struct cfg80211_connect_params *req |
| 6363 | ) |
| 6364 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6365 | int status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6366 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6367 | VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL; |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 6368 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6369 | |
| 6370 | ENTER(); |
| 6371 | |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 6372 | if (!pAdapter) |
| 6373 | { |
| 6374 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6375 | "%s: Adapter context is null", __func__); |
| 6376 | return VOS_STATUS_E_FAILURE; |
| 6377 | } |
| 6378 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6379 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6380 | "%s: device_mode = %d",__func__,pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6381 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6382 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Rajesh Chauhan | a0516c6 | 2014-01-30 16:11:18 -0800 | [diff] [blame] | 6383 | if (!pHddCtx) |
| 6384 | { |
| 6385 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6386 | "%s: HDD context is null", __func__); |
| 6387 | return VOS_STATUS_E_FAILURE; |
| 6388 | } |
| 6389 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6390 | status = wlan_hdd_validate_context(pHddCtx); |
| 6391 | |
| 6392 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6393 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6394 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6395 | "%s: HDD context is not valid", __func__); |
| 6396 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6397 | } |
| 6398 | |
| 6399 | #ifdef WLAN_BTAMP_FEATURE |
| 6400 | //Infra connect not supported when AMP traffic is on. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6401 | if( VOS_TRUE == WLANBAP_AmpSessionOn() ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6402 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6403 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6404 | "%s: No connection when AMP is on", __func__); |
Madan Mohan Koyyalamudi | cae253a | 2012-11-06 19:10:35 -0800 | [diff] [blame] | 6405 | return -ECONNREFUSED; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6406 | } |
| 6407 | #endif |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 6408 | |
| 6409 | //If Device Mode is Station Concurrent Sessions Exit BMps |
| 6410 | //P2P Mode will be taken care in Open/close adapter |
| 6411 | if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) && |
| 6412 | (vos_concurrent_sessions_running())) |
| 6413 | { |
| 6414 | exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 6415 | } |
| 6416 | |
| 6417 | /*Try disconnecting if already in connected state*/ |
| 6418 | status = wlan_hdd_try_disconnect(pAdapter); |
| 6419 | if ( 0 > status) |
| 6420 | { |
| 6421 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing" |
| 6422 | " connection")); |
| 6423 | return -EALREADY; |
| 6424 | } |
| 6425 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6426 | /*initialise security parameters*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6427 | status = wlan_hdd_cfg80211_set_privacy(pAdapter, req); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6428 | |
| 6429 | if ( 0 > status) |
| 6430 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6431 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6432 | __func__); |
| 6433 | return status; |
| 6434 | } |
| 6435 | |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 6436 | if ( req->channel ) |
| 6437 | { |
| 6438 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
| 6439 | req->ssid_len, req->bssid, |
| 6440 | req->channel->hw_value); |
| 6441 | } |
| 6442 | else |
| 6443 | { |
| 6444 | status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid, |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6445 | req->ssid_len, req->bssid, 0); |
Mohit Khanna | 765234a | 2012-09-11 15:08:35 -0700 | [diff] [blame] | 6446 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6447 | |
| 6448 | if (0 > status) |
| 6449 | { |
| 6450 | //ReEnable BMPS if disabled |
| 6451 | if((VOS_STATUS_SUCCESS == exitbmpsStatus) && |
| 6452 | (NULL != pHddCtx)) |
| 6453 | { |
Gopichand Nakkala | a2fe5b0 | 2013-06-06 16:32:28 +0530 | [diff] [blame] | 6454 | if (pHddCtx->hdd_wlan_suspended) |
| 6455 | { |
| 6456 | hdd_set_pwrparams(pHddCtx); |
| 6457 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6458 | //ReEnable Bmps and Imps back |
| 6459 | hdd_enable_bmps_imps(pHddCtx); |
| 6460 | } |
| 6461 | |
| 6462 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 6463 | return status; |
| 6464 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6465 | pHddCtx->isAmpAllowed = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6466 | EXIT(); |
| 6467 | return status; |
| 6468 | } |
| 6469 | |
| 6470 | |
| 6471 | /* |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6472 | * FUNCTION: wlan_hdd_disconnect |
| 6473 | * This function is used to issue a disconnect request to SME |
| 6474 | */ |
| 6475 | int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason ) |
| 6476 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6477 | int status; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6478 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6479 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6480 | long ret; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6481 | |
| 6482 | status = wlan_hdd_validate_context(pHddCtx); |
| 6483 | |
| 6484 | if (0 != status) |
| 6485 | { |
| 6486 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6487 | "%s: HDD context is not valid", __func__); |
| 6488 | return status; |
| 6489 | } |
| 6490 | |
| 6491 | pHddCtx->isAmpAllowed = VOS_TRUE; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6492 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6493 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6494 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6495 | /*issue disconnect*/ |
| 6496 | status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 6497 | pAdapter->sessionId, reason); |
| 6498 | |
| 6499 | if ( 0 != status ) |
| 6500 | { |
| 6501 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6502 | "%s csrRoamDisconnect failure, returned %d", |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6503 | __func__, (int)status ); |
| 6504 | return -EINVAL; |
| 6505 | } |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6506 | ret = wait_for_completion_interruptible_timeout( |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6507 | &pAdapter->disconnect_comp_var, |
| 6508 | msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT)); |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 6509 | if (ret <= 0) |
| 6510 | { |
| 6511 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6512 | FL("wait on disconnect_comp_var failed %ld"), ret); |
| 6513 | } |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6514 | /*stop tx queues*/ |
| 6515 | netif_tx_disable(pAdapter->dev); |
| 6516 | netif_carrier_off(pAdapter->dev); |
| 6517 | return status; |
| 6518 | } |
| 6519 | |
| 6520 | |
| 6521 | /* |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6522 | * FUNCTION: wlan_hdd_cfg80211_disconnect |
| 6523 | * This function is used to issue a disconnect request to SME |
| 6524 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6525 | static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6526 | struct net_device *dev, |
| 6527 | u16 reason |
| 6528 | ) |
| 6529 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6530 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 6531 | tCsrRoamProfile *pRoamProfile = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6532 | &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6533 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6534 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6535 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6536 | #ifdef FEATURE_WLAN_TDLS |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6537 | tANI_U8 staIdx; |
| 6538 | #endif |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6539 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6540 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6541 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6542 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6543 | __func__,pAdapter->device_mode); |
| 6544 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6545 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d", |
| 6546 | __func__, reason); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6547 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6548 | status = wlan_hdd_validate_context(pHddCtx); |
| 6549 | |
| 6550 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6551 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6552 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6553 | "%s: HDD context is not valid", __func__); |
| 6554 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6555 | } |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6556 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6557 | if (NULL != pRoamProfile) |
| 6558 | { |
| 6559 | /*issue disconnect request to SME, if station is in connected state*/ |
Mahesh A Saptasagar | 280fd5a | 2013-12-05 15:38:31 +0530 | [diff] [blame] | 6560 | if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) || |
| 6561 | (pHddStaCtx->conn_info.connState == eConnectionState_Connecting)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6562 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6563 | eCsrRoamDisconnectReason reasonCode = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6564 | eCSR_DISCONNECT_REASON_UNSPECIFIED; |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6565 | hdd_scaninfo_t *pScanInfo; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6566 | switch(reason) |
| 6567 | { |
| 6568 | case WLAN_REASON_MIC_FAILURE: |
| 6569 | reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR; |
| 6570 | break; |
| 6571 | |
| 6572 | case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY: |
| 6573 | case WLAN_REASON_DISASSOC_AP_BUSY: |
| 6574 | case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA: |
| 6575 | reasonCode = eCSR_DISCONNECT_REASON_DISASSOC; |
| 6576 | break; |
| 6577 | |
| 6578 | case WLAN_REASON_PREV_AUTH_NOT_VALID: |
| 6579 | case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA: |
| 6580 | reasonCode = eCSR_DISCONNECT_REASON_DEAUTH; |
| 6581 | break; |
| 6582 | |
| 6583 | case WLAN_REASON_DEAUTH_LEAVING: |
| 6584 | default: |
| 6585 | reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED; |
| 6586 | break; |
| 6587 | } |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6588 | pHddStaCtx->conn_info.connState = eConnectionState_NotConnected; |
| 6589 | pScanInfo = &pHddCtx->scan_info; |
| 6590 | if (pScanInfo->mScanPending) |
| 6591 | { |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 6592 | hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, " |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6593 | "Aborting Scan"); |
Srinivas, Dasari | 138af4f | 2014-02-07 11:13:45 +0530 | [diff] [blame] | 6594 | hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId, |
| 6595 | eCSR_SCAN_ABORT_DEFAULT); |
Gopichand Nakkala | aa35378 | 2013-05-17 20:36:22 +0530 | [diff] [blame] | 6596 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6597 | |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6598 | #ifdef FEATURE_WLAN_TDLS |
| 6599 | /* First clean up the tdls peers if any */ |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6600 | for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6601 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6602 | if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) && |
| 6603 | (pHddCtx->tdlsConnInfo[staIdx].staId)) |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6604 | { |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6605 | uint8 *mac; |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6606 | mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 6607 | VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6608 | "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR, |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6609 | __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 6610 | MAC_ADDR_ARRAY(mac)); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6611 | sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter), |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 6612 | pAdapter->sessionId, |
| 6613 | mac); |
Gopichand Nakkala | 2a0a157 | 2013-02-10 21:39:16 -0800 | [diff] [blame] | 6614 | } |
| 6615 | } |
| 6616 | #endif |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6617 | status = wlan_hdd_disconnect(pAdapter, reasonCode); |
| 6618 | if ( 0 != status ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6619 | { |
| 6620 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6621 | "%s wlan_hdd_disconnect failure, returned %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6622 | __func__, (int)status ); |
| 6623 | return -EINVAL; |
| 6624 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6625 | } |
Mahesh A Saptasagar | 280fd5a | 2013-12-05 15:38:31 +0530 | [diff] [blame] | 6626 | else |
| 6627 | { |
| 6628 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API" |
| 6629 | "called while in %d state", __func__, |
| 6630 | pHddStaCtx->conn_info.connState); |
| 6631 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6632 | } |
| 6633 | else |
| 6634 | { |
| 6635 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__); |
| 6636 | } |
| 6637 | |
| 6638 | return status; |
| 6639 | } |
| 6640 | |
Gopichand Nakkala | 78a6c81 | 2013-05-13 16:39:49 +0530 | [diff] [blame] | 6641 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6642 | /* |
| 6643 | * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6644 | * This function is used to initialize the security |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6645 | * settings in IBSS mode. |
| 6646 | */ |
| 6647 | static int wlan_hdd_cfg80211_set_privacy_ibss( |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6648 | hdd_adapter_t *pAdapter, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6649 | struct cfg80211_ibss_params *params |
| 6650 | ) |
| 6651 | { |
| 6652 | int status = 0; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6653 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6654 | eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE; |
| 6655 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6656 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6657 | ENTER(); |
| 6658 | |
| 6659 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED; |
Ravi Joshi | b58ca0d | 2013-10-29 09:50:23 -0700 | [diff] [blame] | 6660 | vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6661 | |
| 6662 | if (params->ie_len && ( NULL != params->ie) ) |
| 6663 | { |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6664 | if (wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 6665 | params->ie_len, WLAN_EID_RSN )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6666 | { |
| 6667 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2; |
| 6668 | encryptionType = eCSR_ENCRYPT_TYPE_AES; |
| 6669 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6670 | else if ( hdd_isWPAIEPresent (params->ie, params->ie_len )) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6671 | { |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 6672 | tDot11fIEWPA dot11WPAIE; |
| 6673 | tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6674 | u8 *ie; |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 6675 | |
Wilson Yang | 0025634 | 2013-10-10 23:13:38 -0700 | [diff] [blame] | 6676 | memset(&dot11WPAIE, 0, sizeof(dot11WPAIE)); |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6677 | ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie, |
| 6678 | params->ie_len, DOT11F_EID_WPA); |
| 6679 | if ( NULL != ie ) |
| 6680 | { |
| 6681 | pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA; |
| 6682 | // Unpack the WPA IE |
| 6683 | //Skip past the EID byte and length byte - and four byte WiFi OUI |
| 6684 | dot11fUnpackIeWPA((tpAniSirGlobal) halHandle, |
| 6685 | &ie[2+4], |
| 6686 | ie[1] - 4, |
| 6687 | &dot11WPAIE); |
| 6688 | /*Extract the multicast cipher, the encType for unicast |
| 6689 | cipher for wpa-none is none*/ |
| 6690 | encryptionType = |
| 6691 | hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher); |
| 6692 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6693 | } |
Shailender Karmuchi | 67edd31 | 2013-06-18 16:30:48 -0700 | [diff] [blame] | 6694 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6695 | status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len); |
| 6696 | |
| 6697 | if (0 > status) |
| 6698 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6699 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6700 | __func__); |
| 6701 | return status; |
| 6702 | } |
| 6703 | } |
| 6704 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6705 | pWextState->roamProfile.AuthType.authType[0] = |
| 6706 | pHddStaCtx->conn_info.authType = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6707 | eCSR_AUTH_TYPE_OPEN_SYSTEM; |
| 6708 | |
| 6709 | if (params->privacy) |
| 6710 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6711 | /* Security enabled IBSS, At this time there is no information available |
| 6712 | * about the security paramters, so initialise the encryption type to |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6713 | * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY. |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6714 | * The correct security parameters will be updated later in |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6715 | * wlan_hdd_cfg80211_add_key */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6716 | /* Hal expects encryption type to be set inorder |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6717 | *enable privacy bit in beacons */ |
| 6718 | |
| 6719 | encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY; |
| 6720 | } |
Shailender Karmuchi | 642e981 | 2013-05-30 14:34:49 -0700 | [diff] [blame] | 6721 | VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, |
| 6722 | "encryptionType=%d", encryptionType); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6723 | pHddStaCtx->conn_info.ucEncryptionType = encryptionType; |
| 6724 | pWextState->roamProfile.EncryptionType.numEntries = 1; |
| 6725 | pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6726 | return status; |
| 6727 | } |
| 6728 | |
| 6729 | /* |
| 6730 | * FUNCTION: wlan_hdd_cfg80211_join_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6731 | * This function is used to create/join an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6732 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6733 | static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6734 | struct net_device *dev, |
| 6735 | struct cfg80211_ibss_params *params |
| 6736 | ) |
| 6737 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6738 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6739 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6740 | tCsrRoamProfile *pRoamProfile; |
| 6741 | int status; |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 6742 | bool alloc_bssid = VOS_FALSE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6743 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6744 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6745 | |
| 6746 | ENTER(); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6747 | |
| 6748 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6749 | "%s: device_mode = %d",__func__,pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6750 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6751 | status = wlan_hdd_validate_context(pHddCtx); |
| 6752 | |
| 6753 | if (0 != status) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6754 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6755 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6756 | "%s: HDD context is not valid", __func__); |
| 6757 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6758 | } |
| 6759 | |
| 6760 | if (NULL == pWextState) |
| 6761 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6762 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6763 | __func__); |
| 6764 | return -EIO; |
| 6765 | } |
| 6766 | |
Vinay Krishna Eranna | 2104232 | 2014-01-08 19:21:39 +0530 | [diff] [blame] | 6767 | /*Try disconnecting if already in connected state*/ |
| 6768 | status = wlan_hdd_try_disconnect(pAdapter); |
| 6769 | if ( 0 > status) |
| 6770 | { |
| 6771 | hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing" |
| 6772 | " IBSS connection")); |
| 6773 | return -EALREADY; |
| 6774 | } |
| 6775 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6776 | pRoamProfile = &pWextState->roamProfile; |
| 6777 | |
| 6778 | if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType ) |
| 6779 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6780 | hddLog (VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6781 | "%s Interface type is not set to IBSS", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6782 | return -EINVAL; |
| 6783 | } |
| 6784 | |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 6785 | /* BSSID is provided by upper layers hence no need to AUTO generate */ |
| 6786 | if (NULL != params->bssid) { |
| 6787 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0, |
| 6788 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) { |
| 6789 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 6790 | "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__); |
| 6791 | return -EIO; |
| 6792 | } |
| 6793 | } |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 6794 | else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0) |
| 6795 | { |
| 6796 | if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0, |
| 6797 | NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) |
| 6798 | { |
| 6799 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 6800 | "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__); |
| 6801 | return -EIO; |
| 6802 | } |
| 6803 | params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE)); |
| 6804 | if (!params->bssid) |
| 6805 | { |
| 6806 | hddLog (VOS_TRACE_LEVEL_ERROR, |
| 6807 | "%s:Failed memory allocation", __func__); |
| 6808 | return -EIO; |
| 6809 | } |
| 6810 | vos_mem_copy((v_U8_t *)params->bssid, |
| 6811 | (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0], |
| 6812 | VOS_MAC_ADDR_SIZE); |
| 6813 | alloc_bssid = VOS_TRUE; |
| 6814 | } |
Praveen Kumar Sirisilla | d123d14 | 2013-09-24 16:50:13 -0700 | [diff] [blame] | 6815 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6816 | /* Set Channel */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6817 | if (NULL != |
| 6818 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 6819 | params->chandef.chan) |
| 6820 | #else |
| 6821 | params->channel) |
| 6822 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6823 | { |
| 6824 | u8 channelNum; |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6825 | v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 6826 | v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 6827 | tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 6828 | int indx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6829 | |
| 6830 | /* Get channel number */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6831 | channelNum = |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 6832 | ieee80211_frequency_to_channel( |
| 6833 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) |
| 6834 | params->chandef.chan->center_freq); |
| 6835 | #else |
| 6836 | params->channel->center_freq); |
| 6837 | #endif |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6838 | |
| 6839 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 6840 | validChan, &numChans)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6841 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6842 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list", |
| 6843 | __func__); |
| 6844 | return -EOPNOTSUPP; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6845 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6846 | |
| 6847 | for (indx = 0; indx < numChans; indx++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6848 | { |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6849 | if (channelNum == validChan[indx]) |
| 6850 | { |
| 6851 | break; |
| 6852 | } |
| 6853 | } |
| 6854 | if (indx >= numChans) |
| 6855 | { |
| 6856 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6857 | __func__, channelNum); |
| 6858 | return -EINVAL; |
| 6859 | } |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6860 | /* Set the Operational Channel */ |
| 6861 | hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__, |
| 6862 | channelNum); |
| 6863 | pRoamProfile->ChannelInfo.numOfChannels = 1; |
| 6864 | pHddStaCtx->conn_info.operationChannel = channelNum; |
| 6865 | pRoamProfile->ChannelInfo.ChannelList = |
| 6866 | &pHddStaCtx->conn_info.operationChannel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6867 | } |
| 6868 | |
| 6869 | /* Initialize security parameters */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6870 | status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6871 | if (status < 0) |
| 6872 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6873 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6874 | __func__); |
| 6875 | return status; |
| 6876 | } |
| 6877 | |
| 6878 | /* Issue connect start */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6879 | status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid, |
Shailender Karmuchi | 15cd067 | 2013-05-15 19:50:04 -0700 | [diff] [blame] | 6880 | params->ssid_len, params->bssid, |
| 6881 | pHddStaCtx->conn_info.operationChannel); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6882 | |
| 6883 | if (0 > status) |
| 6884 | { |
| 6885 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__); |
| 6886 | return status; |
| 6887 | } |
| 6888 | |
krunal soni | e9002db | 2013-11-25 14:24:17 -0800 | [diff] [blame] | 6889 | if (NULL != params->bssid && |
| 6890 | pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 && |
| 6891 | alloc_bssid == VOS_TRUE) |
| 6892 | { |
| 6893 | vos_mem_free(params->bssid); |
| 6894 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6895 | return 0; |
| 6896 | } |
| 6897 | |
| 6898 | /* |
| 6899 | * FUNCTION: wlan_hdd_cfg80211_leave_ibss |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6900 | * This function is used to leave an IBSS |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6901 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6902 | static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6903 | struct net_device *dev |
| 6904 | ) |
| 6905 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6906 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6907 | hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter); |
| 6908 | tCsrRoamProfile *pRoamProfile; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6909 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 6910 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6911 | |
| 6912 | ENTER(); |
| 6913 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6914 | status = wlan_hdd_validate_context(pHddCtx); |
| 6915 | |
| 6916 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6917 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6918 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6919 | "%s: HDD context is not valid", __func__); |
| 6920 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6921 | } |
| 6922 | |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6923 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",__func__,pAdapter->device_mode); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6924 | if (NULL == pWextState) |
| 6925 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 6926 | hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6927 | __func__); |
| 6928 | return -EIO; |
| 6929 | } |
| 6930 | |
| 6931 | pRoamProfile = &pWextState->roamProfile; |
| 6932 | |
| 6933 | /* Issue disconnect only if interface type is set to IBSS */ |
| 6934 | if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType) |
| 6935 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6936 | 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] | 6937 | __func__); |
| 6938 | return -EINVAL; |
| 6939 | } |
| 6940 | |
| 6941 | /* Issue Disconnect request */ |
| 6942 | INIT_COMPLETION(pAdapter->disconnect_comp_var); |
| 6943 | sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 6944 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
| 6945 | |
| 6946 | return 0; |
| 6947 | } |
| 6948 | |
| 6949 | /* |
| 6950 | * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params |
| 6951 | * This function is used to set the phy parameters |
| 6952 | * (RTS Threshold/FRAG Threshold/Retry Count etc ...) |
| 6953 | */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6954 | static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6955 | u32 changed) |
| 6956 | { |
| 6957 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 6958 | tHalHandle hHal = pHddCtx->hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6959 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6960 | |
| 6961 | ENTER(); |
| 6962 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6963 | status = wlan_hdd_validate_context(pHddCtx); |
| 6964 | |
| 6965 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6966 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 6967 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 6968 | "%s: HDD context is not valid", __func__); |
| 6969 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 6970 | } |
| 6971 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6972 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 6973 | { |
| 6974 | u16 rts_threshold = (wiphy->rts_threshold == -1) ? |
| 6975 | WNI_CFG_RTS_THRESHOLD_STAMAX : |
| 6976 | wiphy->rts_threshold; |
| 6977 | |
| 6978 | if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) || |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6979 | (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6980 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6981 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6982 | "%s: Invalid RTS Threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6983 | __func__, rts_threshold); |
| 6984 | return -EINVAL; |
| 6985 | } |
| 6986 | |
| 6987 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD, |
| 6988 | rts_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6989 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6990 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6991 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 6992 | "%s: ccmCfgSetInt failed for rts_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6993 | __func__, rts_threshold); |
| 6994 | return -EIO; |
| 6995 | } |
| 6996 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 6997 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6998 | rts_threshold); |
| 6999 | } |
| 7000 | |
| 7001 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 7002 | { |
| 7003 | u16 frag_threshold = (wiphy->frag_threshold == -1) ? |
| 7004 | WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX : |
| 7005 | wiphy->frag_threshold; |
| 7006 | |
| 7007 | if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)|| |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7008 | (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7009 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7010 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7011 | "%s: Invalid frag_threshold value %hu", __func__, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7012 | frag_threshold); |
| 7013 | return -EINVAL; |
| 7014 | } |
| 7015 | |
| 7016 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD, |
| 7017 | frag_threshold, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7018 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7019 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7020 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7021 | "%s: ccmCfgSetInt failed for frag_threshold value %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7022 | __func__, frag_threshold); |
| 7023 | return -EIO; |
| 7024 | } |
| 7025 | |
| 7026 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__, |
| 7027 | frag_threshold); |
| 7028 | } |
| 7029 | |
| 7030 | if ((changed & WIPHY_PARAM_RETRY_SHORT) |
| 7031 | || (changed & WIPHY_PARAM_RETRY_LONG)) |
| 7032 | { |
| 7033 | u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ? |
| 7034 | wiphy->retry_short : |
| 7035 | wiphy->retry_long; |
| 7036 | |
| 7037 | if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) || |
| 7038 | (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value)) |
| 7039 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7040 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7041 | __func__, retry_value); |
| 7042 | return -EINVAL; |
| 7043 | } |
| 7044 | |
| 7045 | if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 7046 | { |
| 7047 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT, |
| 7048 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7049 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7050 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7051 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7052 | "%s: ccmCfgSetInt failed for long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7053 | __func__, retry_value); |
| 7054 | return -EIO; |
| 7055 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7056 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7057 | __func__, retry_value); |
| 7058 | } |
| 7059 | else if (changed & WIPHY_PARAM_RETRY_SHORT) |
| 7060 | { |
| 7061 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT, |
| 7062 | retry_value, ccmCfgSetCallback, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7063 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7064 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7065 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7066 | "%s: ccmCfgSetInt failed for short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7067 | __func__, retry_value); |
| 7068 | return -EIO; |
| 7069 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7070 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7071 | __func__, retry_value); |
| 7072 | } |
| 7073 | } |
| 7074 | |
| 7075 | return 0; |
| 7076 | } |
| 7077 | |
| 7078 | /* |
| 7079 | * FUNCTION: wlan_hdd_cfg80211_set_txpower |
| 7080 | * This function is used to set the txpower |
| 7081 | */ |
| 7082 | static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy, |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 7083 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 7084 | struct wireless_dev *wdev, |
| 7085 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7086 | #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7087 | enum tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7088 | #else |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7089 | enum nl80211_tx_power_setting type, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7090 | #endif |
| 7091 | int dbm) |
| 7092 | { |
| 7093 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7094 | tHalHandle hHal = NULL; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7095 | tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
| 7096 | tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7097 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7098 | |
| 7099 | ENTER(); |
| 7100 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7101 | status = wlan_hdd_validate_context(pHddCtx); |
| 7102 | |
| 7103 | if (0 != status) |
| 7104 | { |
| 7105 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7106 | "%s: HDD context is not valid", __func__); |
| 7107 | return status; |
| 7108 | } |
| 7109 | |
| 7110 | hHal = pHddCtx->hHal; |
| 7111 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7112 | if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL, |
| 7113 | dbm, ccmCfgSetCallback, |
| 7114 | eANI_BOOLEAN_TRUE)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7115 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7116 | hddLog(VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7117 | "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm); |
| 7118 | return -EIO; |
| 7119 | } |
| 7120 | |
| 7121 | hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__, |
| 7122 | dbm); |
| 7123 | |
| 7124 | switch(type) |
| 7125 | { |
| 7126 | case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/ |
| 7127 | /* Fall through */ |
| 7128 | case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/ |
| 7129 | if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS ) |
| 7130 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7131 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed", |
| 7132 | __func__); |
| 7133 | return -EIO; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7134 | } |
| 7135 | break; |
| 7136 | case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7137 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported", |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7138 | __func__); |
| 7139 | return -EOPNOTSUPP; |
| 7140 | break; |
| 7141 | default: |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7142 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d", |
| 7143 | __func__, type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7144 | return -EIO; |
| 7145 | } |
| 7146 | |
| 7147 | return 0; |
| 7148 | } |
| 7149 | |
| 7150 | /* |
| 7151 | * FUNCTION: wlan_hdd_cfg80211_get_txpower |
| 7152 | * This function is used to read the txpower |
| 7153 | */ |
Yue Ma | f49ba87 | 2013-08-19 12:04:25 -0700 | [diff] [blame] | 7154 | static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, |
| 7155 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 7156 | struct wireless_dev *wdev, |
| 7157 | #endif |
| 7158 | int *dbm) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7159 | { |
| 7160 | |
| 7161 | hdd_adapter_t *pAdapter; |
| 7162 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7163 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7164 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7165 | ENTER(); |
| 7166 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7167 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7168 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7169 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7170 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7171 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7172 | "%s: HDD context is not valid", __func__); |
| 7173 | *dbm = 0; |
| 7174 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7175 | } |
| 7176 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7177 | pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 7178 | if (NULL == pAdapter) |
| 7179 | { |
| 7180 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__); |
| 7181 | return -ENOENT; |
| 7182 | } |
| 7183 | |
| 7184 | wlan_hdd_get_classAstats(pAdapter); |
| 7185 | *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr; |
| 7186 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7187 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7188 | return 0; |
| 7189 | } |
| 7190 | |
| 7191 | static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 7192 | u8* mac, struct station_info *sinfo) |
| 7193 | { |
| 7194 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev ); |
| 7195 | hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 7196 | int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length; |
| 7197 | tANI_U8 rate_flags; |
| 7198 | |
| 7199 | hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy); |
| 7200 | hdd_config_t *pCfg = pHddCtx->cfg_ini; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7201 | |
| 7202 | tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; |
| 7203 | tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX; |
| 7204 | tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; |
| 7205 | tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX; |
| 7206 | tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET]; |
| 7207 | tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET; |
| 7208 | tANI_U16 maxRate = 0; |
| 7209 | tANI_U16 myRate; |
| 7210 | tANI_U16 currentRate = 0; |
| 7211 | tANI_U8 maxSpeedMCS = 0; |
| 7212 | tANI_U8 maxMCSIdx = 0; |
| 7213 | tANI_U8 rateFlag = 1; |
| 7214 | tANI_U8 i, j, rssidx; |
Madan Mohan Koyyalamudi | c75be96 | 2012-10-18 19:19:03 -0700 | [diff] [blame] | 7215 | tANI_U16 temp; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7216 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7217 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7218 | #ifdef WLAN_FEATURE_11AC |
| 7219 | tANI_U32 vht_mcs_map; |
| 7220 | eDataRate11ACMaxMcs vhtMaxMcs; |
| 7221 | #endif /* WLAN_FEATURE_11AC */ |
| 7222 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7223 | ENTER(); |
| 7224 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7225 | if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) || |
| 7226 | (0 == ssidlen)) |
| 7227 | { |
| 7228 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or" |
| 7229 | " Invalid ssidlen, %d", __func__, ssidlen); |
| 7230 | /*To keep GUI happy*/ |
| 7231 | return 0; |
| 7232 | } |
| 7233 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7234 | status = wlan_hdd_validate_context(pHddCtx); |
| 7235 | |
| 7236 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7237 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7238 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7239 | "%s: HDD context is not valid", __func__); |
| 7240 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7241 | } |
| 7242 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 7243 | wlan_hdd_get_station_stats(pAdapter); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7244 | rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags; |
| 7245 | |
Kiet Lam | 3b17fc8 | 2013-09-27 05:24:08 +0530 | [diff] [blame] | 7246 | wlan_hdd_get_rssi(pAdapter, &sinfo->signal); |
| 7247 | sinfo->filled |= STATION_INFO_SIGNAL; |
| 7248 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7249 | //convert to the UI units of 100kbps |
| 7250 | myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5; |
| 7251 | |
| 7252 | #ifdef LINKSPEED_DEBUG_ENABLED |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7253 | 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] | 7254 | sinfo->signal, |
| 7255 | pCfg->reportMaxLinkSpeed, |
| 7256 | myRate, |
| 7257 | (int) pCfg->linkSpeedRssiHigh, |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 7258 | (int) pCfg->linkSpeedRssiMid, |
| 7259 | (int) pCfg->linkSpeedRssiLow, |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7260 | (int) rate_flags, |
| 7261 | (int) pAdapter->hdd_stats.ClassA_stat.mcs_index); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7262 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7263 | |
| 7264 | if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed) |
| 7265 | { |
| 7266 | // we do not want to necessarily report the current speed |
| 7267 | if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) |
| 7268 | { |
| 7269 | // report the max possible speed |
| 7270 | rssidx = 0; |
| 7271 | } |
| 7272 | else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed) |
| 7273 | { |
| 7274 | // report the max possible speed with RSSI scaling |
| 7275 | if (sinfo->signal >= pCfg->linkSpeedRssiHigh) |
| 7276 | { |
| 7277 | // report the max possible speed |
| 7278 | rssidx = 0; |
| 7279 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 7280 | else if (sinfo->signal >= pCfg->linkSpeedRssiMid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7281 | { |
| 7282 | // report middle speed |
| 7283 | rssidx = 1; |
| 7284 | } |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 7285 | else if (sinfo->signal >= pCfg->linkSpeedRssiLow) |
| 7286 | { |
| 7287 | // report middle speed |
| 7288 | rssidx = 2; |
| 7289 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7290 | else |
| 7291 | { |
| 7292 | // report actual speed |
Madan Mohan Koyyalamudi | 8df78d5 | 2012-11-02 12:30:06 -0700 | [diff] [blame] | 7293 | rssidx = 3; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7294 | } |
| 7295 | } |
| 7296 | else |
| 7297 | { |
| 7298 | // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX |
| 7299 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 7300 | "%s: Invalid value for reportMaxLinkSpeed: %u", |
| 7301 | __func__, pCfg->reportMaxLinkSpeed); |
| 7302 | rssidx = 0; |
| 7303 | } |
| 7304 | |
| 7305 | maxRate = 0; |
| 7306 | |
| 7307 | /* Get Basic Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 7308 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET, |
| 7309 | OperationalRates, &ORLeng)) |
| 7310 | { |
| 7311 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 7312 | /*To keep GUI happy*/ |
| 7313 | return 0; |
| 7314 | } |
| 7315 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7316 | for (i = 0; i < ORLeng; i++) |
| 7317 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7318 | 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] | 7319 | { |
| 7320 | /* Validate Rate Set */ |
| 7321 | if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F)) |
| 7322 | { |
| 7323 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 7324 | break; |
| 7325 | } |
| 7326 | } |
| 7327 | /* Update MAX rate */ |
| 7328 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 7329 | } |
| 7330 | |
| 7331 | /* Get Extended Rate Set */ |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 7332 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, |
| 7333 | ExtendedRates, &ERLeng)) |
| 7334 | { |
| 7335 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 7336 | /*To keep GUI happy*/ |
| 7337 | return 0; |
| 7338 | } |
| 7339 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7340 | for (i = 0; i < ERLeng; i++) |
| 7341 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7342 | 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] | 7343 | { |
| 7344 | if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F)) |
| 7345 | { |
| 7346 | currentRate = supported_data_rate[j].supported_rate[rssidx]; |
| 7347 | break; |
| 7348 | } |
| 7349 | } |
| 7350 | /* Update MAX rate */ |
| 7351 | maxRate = (currentRate > maxRate)?currentRate:maxRate; |
| 7352 | } |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 7353 | /* Get MCS Rate Set -- |
Kaushik, Sushant | dc304d8 | 2014-01-22 10:58:37 +0530 | [diff] [blame] | 7354 | Only if we are always reporting max speed (or) |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 7355 | if we have good rssi */ |
Kaushik, Sushant | dc304d8 | 2014-01-22 10:58:37 +0530 | [diff] [blame] | 7356 | if ((0 == rssidx) || |
Kiet Lam | b69f8dc | 2013-11-15 15:34:27 +0530 | [diff] [blame] | 7357 | (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7358 | { |
Gopichand Nakkala | 05ab132 | 2013-02-15 11:28:38 +0530 | [diff] [blame] | 7359 | if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET, |
| 7360 | MCSRates, &MCSLeng)) |
| 7361 | { |
| 7362 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__); |
| 7363 | /*To keep GUI happy*/ |
| 7364 | return 0; |
| 7365 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7366 | rateFlag = 0; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7367 | #ifdef WLAN_FEATURE_11AC |
| 7368 | /* VHT80 rate has seperate rate table */ |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7369 | 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] | 7370 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7371 | 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] | 7372 | vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK ); |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7373 | if (rate_flags & eHAL_TX_RATE_SGI) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7374 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7375 | rateFlag |= 1; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7376 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7377 | if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7378 | { |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7379 | maxMCSIdx = 7; |
| 7380 | } |
| 7381 | else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs) |
| 7382 | { |
| 7383 | maxMCSIdx = 8; |
| 7384 | } |
| 7385 | else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs) |
| 7386 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7387 | //VHT20 is supporting 0~8 |
| 7388 | if (rate_flags & eHAL_TX_RATE_VHT20) |
| 7389 | maxMCSIdx = 8; |
| 7390 | else |
| 7391 | maxMCSIdx = 9; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7392 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7393 | |
| 7394 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 7395 | { |
| 7396 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag]; |
| 7397 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag]; |
| 7398 | } |
| 7399 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
| 7400 | { |
| 7401 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag]; |
| 7402 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag]; |
| 7403 | } |
| 7404 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 7405 | { |
| 7406 | currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag]; |
| 7407 | maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag]; |
| 7408 | } |
| 7409 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7410 | maxSpeedMCS = 1; |
| 7411 | if (currentRate > maxRate) |
| 7412 | { |
| 7413 | maxRate = currentRate; |
| 7414 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7415 | |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7416 | } |
| 7417 | else |
| 7418 | #endif /* WLAN_FEATURE_11AC */ |
| 7419 | { |
| 7420 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 7421 | { |
| 7422 | rateFlag |= 1; |
| 7423 | } |
| 7424 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 7425 | { |
| 7426 | rateFlag |= 2; |
| 7427 | } |
| 7428 | |
| 7429 | for (i = 0; i < MCSLeng; i++) |
| 7430 | { |
| 7431 | temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]); |
| 7432 | for (j = 0; j < temp; j++) |
| 7433 | { |
| 7434 | if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i]) |
| 7435 | { |
| 7436 | currentRate = supported_mcs_rate[j].supported_rate[rateFlag]; |
| 7437 | break; |
| 7438 | } |
| 7439 | } |
| 7440 | if ((j < temp) && (currentRate > maxRate)) |
| 7441 | { |
| 7442 | maxRate = currentRate; |
| 7443 | maxSpeedMCS = 1; |
| 7444 | maxMCSIdx = supported_mcs_rate[j].beacon_rate_index; |
| 7445 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7446 | } |
| 7447 | } |
| 7448 | } |
| 7449 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7450 | else if (!(rate_flags & eHAL_TX_RATE_LEGACY)) |
| 7451 | { |
| 7452 | maxRate = myRate; |
| 7453 | maxSpeedMCS = 1; |
| 7454 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 7455 | } |
| 7456 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7457 | // 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] | 7458 | if (((maxRate < myRate) && (0 == rssidx)) || |
| 7459 | (0 == maxRate)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7460 | { |
| 7461 | maxRate = myRate; |
| 7462 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 7463 | { |
| 7464 | maxSpeedMCS = 0; |
| 7465 | } |
| 7466 | else |
| 7467 | { |
| 7468 | maxSpeedMCS = 1; |
| 7469 | maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
| 7470 | } |
| 7471 | } |
| 7472 | |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7473 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7474 | { |
| 7475 | sinfo->txrate.legacy = maxRate; |
| 7476 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 7477 | pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy); |
| 7478 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7479 | } |
| 7480 | else |
| 7481 | { |
| 7482 | sinfo->txrate.mcs = maxMCSIdx; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7483 | #ifdef WLAN_FEATURE_11AC |
| 7484 | sinfo->txrate.nss = 1; |
| 7485 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 7486 | { |
| 7487 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7488 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7489 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7490 | else if (rate_flags & eHAL_TX_RATE_VHT40) |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7491 | { |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7492 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 7493 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 7494 | } |
| 7495 | else if (rate_flags & eHAL_TX_RATE_VHT20) |
| 7496 | { |
| 7497 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 7498 | } |
| 7499 | #endif /* WLAN_FEATURE_11AC */ |
| 7500 | if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40)) |
| 7501 | { |
| 7502 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 7503 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 7504 | { |
| 7505 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 7506 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7507 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7508 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 7509 | { |
| 7510 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 7511 | } |
Gopichand Nakkala | 4c70537 | 2013-04-24 13:20:33 +0530 | [diff] [blame] | 7512 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7513 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 7514 | pr_info("Reporting MCS rate %d flags %x\n", |
| 7515 | sinfo->txrate.mcs, |
| 7516 | sinfo->txrate.flags ); |
| 7517 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7518 | } |
| 7519 | } |
| 7520 | else |
| 7521 | { |
| 7522 | // report current rate instead of max rate |
| 7523 | |
| 7524 | if (rate_flags & eHAL_TX_RATE_LEGACY) |
| 7525 | { |
| 7526 | //provide to the UI in units of 100kbps |
| 7527 | sinfo->txrate.legacy = myRate; |
| 7528 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 7529 | pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy); |
| 7530 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7531 | } |
| 7532 | else |
| 7533 | { |
| 7534 | //must be MCS |
| 7535 | sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index; |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7536 | #ifdef WLAN_FEATURE_11AC |
| 7537 | sinfo->txrate.nss = 1; |
| 7538 | if (rate_flags & eHAL_TX_RATE_VHT80) |
| 7539 | { |
| 7540 | sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS; |
| 7541 | } |
| 7542 | else |
| 7543 | #endif /* WLAN_FEATURE_11AC */ |
| 7544 | { |
| 7545 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 7546 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7547 | if (rate_flags & eHAL_TX_RATE_SGI) |
| 7548 | { |
| 7549 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 7550 | } |
| 7551 | if (rate_flags & eHAL_TX_RATE_HT40) |
| 7552 | { |
| 7553 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 7554 | } |
Leo Chang | 6f8870f | 2013-03-26 18:11:36 -0700 | [diff] [blame] | 7555 | #ifdef WLAN_FEATURE_11AC |
| 7556 | else if (rate_flags & eHAL_TX_RATE_VHT80) |
| 7557 | { |
| 7558 | sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
| 7559 | } |
| 7560 | #endif /* WLAN_FEATURE_11AC */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7561 | #ifdef LINKSPEED_DEBUG_ENABLED |
| 7562 | pr_info("Reporting actual MCS rate %d flags %x\n", |
| 7563 | sinfo->txrate.mcs, |
| 7564 | sinfo->txrate.flags ); |
| 7565 | #endif //LINKSPEED_DEBUG_ENABLED |
| 7566 | } |
| 7567 | } |
| 7568 | sinfo->filled |= STATION_INFO_TX_BITRATE; |
| 7569 | |
Madan Mohan Koyyalamudi | 4d4d281 | 2012-09-24 14:08:29 -0700 | [diff] [blame] | 7570 | sinfo->tx_packets = |
| 7571 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] + |
| 7572 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] + |
| 7573 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] + |
| 7574 | pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3]; |
| 7575 | |
| 7576 | sinfo->tx_retries = |
| 7577 | pAdapter->hdd_stats.summary_stat.retry_cnt[0] + |
| 7578 | pAdapter->hdd_stats.summary_stat.retry_cnt[1] + |
| 7579 | pAdapter->hdd_stats.summary_stat.retry_cnt[2] + |
| 7580 | pAdapter->hdd_stats.summary_stat.retry_cnt[3]; |
| 7581 | |
| 7582 | sinfo->tx_failed = |
| 7583 | pAdapter->hdd_stats.summary_stat.fail_cnt[0] + |
| 7584 | pAdapter->hdd_stats.summary_stat.fail_cnt[1] + |
| 7585 | pAdapter->hdd_stats.summary_stat.fail_cnt[2] + |
| 7586 | pAdapter->hdd_stats.summary_stat.fail_cnt[3]; |
| 7587 | |
| 7588 | sinfo->filled |= |
| 7589 | STATION_INFO_TX_PACKETS | |
| 7590 | STATION_INFO_TX_RETRIES | |
| 7591 | STATION_INFO_TX_FAILED; |
| 7592 | |
| 7593 | EXIT(); |
| 7594 | return 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7595 | } |
| 7596 | |
| 7597 | static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
Sameer Thalappil | c9f26e9 | 2013-06-07 10:11:06 -0700 | [diff] [blame] | 7598 | struct net_device *dev, bool mode, int timeout) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7599 | { |
| 7600 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7601 | hdd_context_t *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7602 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7603 | int status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7604 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7605 | ENTER(); |
| 7606 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7607 | if (NULL == pAdapter) |
| 7608 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7609 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7610 | return -ENODEV; |
| 7611 | } |
| 7612 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7613 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7614 | status = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7615 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7616 | if (0 != status) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7617 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7618 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7619 | "%s: HDD context is not valid", __func__); |
| 7620 | return status; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7621 | } |
| 7622 | |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7623 | if ((DRIVER_POWER_MODE_AUTO == !mode) && |
| 7624 | (TRUE == pHddCtx->hdd_wlan_suspended) && |
| 7625 | (pHddCtx->cfg_ini->fhostArpOffload) && |
| 7626 | (eConnectionState_Associated == |
| 7627 | (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState)) |
| 7628 | { |
Amar Singhal | d53568e | 2013-09-26 11:03:45 -0700 | [diff] [blame] | 7629 | |
| 7630 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7631 | "offload: in cfg80211_set_power_mgmt, calling arp offload"); |
Gopichand Nakkala | b03e808 | 2013-05-30 18:09:25 +0530 | [diff] [blame] | 7632 | vos_status = hdd_conf_arp_offload(pAdapter, TRUE); |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7633 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7634 | { |
| 7635 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 7636 | "%s:Failed to enable ARPOFFLOAD Feature %d", |
Gopichand Nakkala | 20c4c04 | 2013-04-19 22:08:55 +0530 | [diff] [blame] | 7637 | __func__, vos_status); |
| 7638 | } |
| 7639 | } |
| 7640 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7641 | /**The get power cmd from the supplicant gets updated by the nl only |
| 7642 | *on successful execution of the function call |
| 7643 | *we are oppositely mapped w.r.t mode in the driver |
| 7644 | **/ |
| 7645 | vos_status = wlan_hdd_enter_bmps(pAdapter, !mode); |
| 7646 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7647 | EXIT(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7648 | if (VOS_STATUS_E_FAILURE == vos_status) |
| 7649 | { |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 7650 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7651 | "%s: failed to enter bmps mode", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7652 | return -EINVAL; |
| 7653 | } |
| 7654 | return 0; |
| 7655 | } |
| 7656 | |
| 7657 | |
| 7658 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7659 | static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy, |
| 7660 | struct net_device *netdev, |
| 7661 | u8 key_index) |
| 7662 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7663 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7664 | return 0; |
| 7665 | } |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7666 | #endif //LINUX_VERSION_CODE |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7667 | |
| 7668 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
| 7669 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 7670 | struct net_device *dev, |
| 7671 | struct ieee80211_txq_params *params) |
| 7672 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7673 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7674 | return 0; |
| 7675 | } |
| 7676 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 7677 | static int wlan_hdd_set_txq_params(struct wiphy *wiphy, |
| 7678 | struct ieee80211_txq_params *params) |
| 7679 | { |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7680 | ENTER(); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7681 | return 0; |
| 7682 | } |
| 7683 | #endif //LINUX_VERSION_CODE |
| 7684 | |
| 7685 | static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy, |
| 7686 | struct net_device *dev, u8 *mac) |
| 7687 | { |
| 7688 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7689 | hdd_context_t *pHddCtx; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7690 | VOS_STATUS vos_status; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7691 | int status; |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7692 | v_U8_t staId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7693 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7694 | ENTER(); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7695 | if ( NULL == pAdapter ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7696 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7697 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7698 | return -EINVAL; |
| 7699 | } |
| 7700 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7701 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7702 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7703 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7704 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7705 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7706 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7707 | "%s: HDD context is not valid", __func__); |
| 7708 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7709 | } |
| 7710 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7711 | if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7712 | || (WLAN_HDD_P2P_GO == pAdapter->device_mode) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7713 | ) |
| 7714 | { |
| 7715 | if( NULL == mac ) |
| 7716 | { |
| 7717 | v_U16_t i; |
| 7718 | for(i = 0; i < WLAN_MAX_STA_COUNT; i++) |
| 7719 | { |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 7720 | if ((pAdapter->aStaInfo[i].isUsed) && |
| 7721 | (!pAdapter->aStaInfo[i].isDeauthInProgress)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7722 | { |
| 7723 | u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes; |
| 7724 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7725 | "%s: Delete STA with MAC::" |
| 7726 | MAC_ADDRESS_STR, |
| 7727 | __func__, MAC_ADDR_ARRAY(macAddr)); |
Rajesh Chauhan | 18488fc | 2013-08-22 10:15:03 -0700 | [diff] [blame] | 7728 | vos_status = hdd_softap_sta_deauth(pAdapter, macAddr); |
| 7729 | if (VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7730 | pAdapter->aStaInfo[i].isDeauthInProgress = TRUE; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7731 | } |
| 7732 | } |
| 7733 | } |
| 7734 | else |
| 7735 | { |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7736 | |
| 7737 | vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId); |
| 7738 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7739 | { |
| 7740 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7741 | "%s: Skip this DEL STA as this is not used::" |
| 7742 | MAC_ADDRESS_STR, |
| 7743 | __func__, MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7744 | return -ENOENT; |
| 7745 | } |
| 7746 | |
| 7747 | if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE) |
| 7748 | { |
| 7749 | hddLog(VOS_TRACE_LEVEL_INFO, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7750 | "%s: Skip this DEL STA as deauth is in progress::" |
| 7751 | MAC_ADDRESS_STR, |
| 7752 | __func__, MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7753 | return -ENOENT; |
| 7754 | } |
| 7755 | |
| 7756 | pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE; |
| 7757 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7758 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7759 | "%s: Delete STA with MAC::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7760 | MAC_ADDRESS_STR, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7761 | __func__, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7762 | MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7763 | |
| 7764 | vos_status = hdd_softap_sta_deauth(pAdapter, mac); |
| 7765 | if (!VOS_IS_STATUS_SUCCESS(vos_status)) |
| 7766 | { |
| 7767 | pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE; |
| 7768 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 7769 | "%s: STA removal failed for ::" |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7770 | MAC_ADDRESS_STR, |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7771 | __func__, |
Arif Hussain | 24bafea | 2013-11-15 15:10:03 -0800 | [diff] [blame] | 7772 | MAC_ADDR_ARRAY(mac)); |
Madan Mohan Koyyalamudi | cd78499 | 2013-01-11 15:30:36 -0800 | [diff] [blame] | 7773 | return -ENOENT; |
| 7774 | } |
| 7775 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7776 | } |
| 7777 | } |
| 7778 | |
| 7779 | EXIT(); |
| 7780 | |
| 7781 | return 0; |
| 7782 | } |
| 7783 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7784 | static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy, |
| 7785 | struct net_device *dev, u8 *mac, struct station_parameters *params) |
| 7786 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7787 | int status = -EPERM; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7788 | #ifdef FEATURE_WLAN_TDLS |
| 7789 | u32 mask, set; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 7790 | ENTER(); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7791 | mask = params->sta_flags_mask; |
| 7792 | |
| 7793 | set = params->sta_flags_set; |
| 7794 | |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 7795 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 7796 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7797 | "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR, |
| 7798 | __func__, mask, set, MAC_ADDR_ARRAY(mac)); |
| 7799 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7800 | |
| 7801 | if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
| 7802 | if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) { |
Gopichand Nakkala | 681989c | 2013-03-06 22:27:48 -0800 | [diff] [blame] | 7803 | status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 7804 | } |
| 7805 | } |
| 7806 | #endif |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 7807 | return status; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 7808 | } |
| 7809 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7810 | |
| 7811 | #ifdef FEATURE_WLAN_LFR |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7812 | #define MAX_PMKSAIDS_IN_CACHE 8 |
| 7813 | |
| 7814 | static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache |
| 7815 | static tANI_U32 PMKIDCacheIndex; // HDD local Cache index |
| 7816 | |
| 7817 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7818 | 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] | 7819 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7820 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7821 | tANI_U32 j=0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7822 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7823 | tHalHandle halHandle; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7824 | eHalStatus result; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7825 | int status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7826 | tANI_U8 BSSIDMatched = 0; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7827 | hdd_context_t *pHddCtx; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7828 | |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7829 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR, |
| 7830 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 7831 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7832 | // Validate pAdapter |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7833 | if ( NULL == pAdapter ) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7834 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7835 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7836 | return -EINVAL; |
| 7837 | } |
| 7838 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7839 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7840 | status = wlan_hdd_validate_context(pHddCtx); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7841 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7842 | if (0 != status) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7843 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 7844 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7845 | "%s: HDD context is not valid", __func__); |
| 7846 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7847 | } |
| 7848 | |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7849 | // Retrieve halHandle |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7850 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7851 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7852 | for (j = 0; j < PMKIDCacheIndex; j++) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7853 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7854 | if(vos_mem_compare(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7855 | pmksa->bssid, WNI_CFG_BSSID_LEN)) |
| 7856 | { |
| 7857 | /* BSSID matched previous entry. Overwrite it. */ |
| 7858 | BSSIDMatched = 1; |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7859 | vos_mem_copy(PMKIDCache[j].BSSID, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7860 | pmksa->bssid, WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7861 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 7862 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7863 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7864 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.", |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7865 | __func__, j ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7866 | dump_bssid(pmksa->bssid); |
| 7867 | dump_pmkid(halHandle, pmksa->pmkid); |
| 7868 | break; |
| 7869 | } |
| 7870 | } |
| 7871 | |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 7872 | /* Check we compared all entries,if then take the first slot now */ |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7873 | if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0; |
Madan Mohan Koyyalamudi | c4b317d | 2012-10-18 19:43:08 -0700 | [diff] [blame] | 7874 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7875 | if (!BSSIDMatched) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7876 | { |
| 7877 | // Now, we DON'T have a BSSID match, so take a new entry in the cache. |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7878 | vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7879 | pmksa->bssid, ETHER_ADDR_LEN); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7880 | vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID, |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7881 | pmksa->pmkid, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7882 | CSR_RSN_PMKID_SIZE); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7883 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.", |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7884 | __func__, PMKIDCacheIndex ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7885 | dump_bssid(pmksa->bssid); |
| 7886 | dump_pmkid(halHandle, pmksa->pmkid); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7887 | // Increment the HDD Local Cache index |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7888 | // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7889 | if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7890 | } |
| 7891 | |
| 7892 | |
| 7893 | // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7894 | //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."), |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 7895 | // __func__, i ); |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7896 | hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.", |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7897 | __func__, PMKIDCacheIndex ); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7898 | // Finally set the PMKSA ID Cache in CSR |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 7899 | result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId, |
| 7900 | PMKIDCache, |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7901 | PMKIDCacheIndex); |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7902 | return 0; |
| 7903 | } |
| 7904 | |
| 7905 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7906 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7907 | static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev, |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7908 | struct cfg80211_pmksa *pmksa) |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 7909 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7910 | tANI_U32 j=0; |
| 7911 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 7912 | tHalHandle halHandle; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7913 | tANI_U8 BSSIDMatched = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7914 | hdd_context_t *pHddCtx; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7915 | int status = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7916 | |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7917 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR, |
| 7918 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7919 | |
| 7920 | /* Validate pAdapter */ |
| 7921 | if (NULL == pAdapter) |
| 7922 | { |
| 7923 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__); |
| 7924 | return -EINVAL; |
| 7925 | } |
| 7926 | |
| 7927 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 7928 | status = wlan_hdd_validate_context(pHddCtx); |
| 7929 | |
| 7930 | if (0 != status) |
| 7931 | { |
| 7932 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 7933 | "%s: HDD context is not valid", __func__); |
| 7934 | return status; |
| 7935 | } |
| 7936 | |
| 7937 | /*Retrieve halHandle*/ |
| 7938 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 7939 | |
| 7940 | /*in case index is 0,no entry to delete*/ |
| 7941 | if (0 == PMKIDCacheIndex) |
| 7942 | { |
| 7943 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" , |
| 7944 | __func__); |
| 7945 | return -EINVAL; |
| 7946 | } |
| 7947 | |
| 7948 | /*find the matching PMKSA entry from j=0 to (index-1), |
| 7949 | * and delete the matched one |
| 7950 | */ |
| 7951 | for (j = 0; j<PMKIDCacheIndex; j++) |
| 7952 | { |
| 7953 | if (vos_mem_compare(PMKIDCache[j].BSSID, |
| 7954 | pmksa->bssid, |
| 7955 | WNI_CFG_BSSID_LEN)) |
| 7956 | { |
| 7957 | /* BSSID matched entry */ |
| 7958 | BSSIDMatched = 1; |
| 7959 | |
| 7960 | if (j<PMKIDCacheIndex-1) |
| 7961 | { |
| 7962 | /*replace the matching entry with the last entry in HDD local cache*/ |
| 7963 | vos_mem_copy(PMKIDCache[j].BSSID, |
| 7964 | PMKIDCache[PMKIDCacheIndex-1].BSSID, |
| 7965 | WNI_CFG_BSSID_LEN); |
| 7966 | vos_mem_copy(PMKIDCache[j].PMKID, |
| 7967 | PMKIDCache[PMKIDCacheIndex-1].PMKID, |
| 7968 | CSR_RSN_PMKID_SIZE); |
| 7969 | } |
| 7970 | |
| 7971 | /*clear the last entry in HDD cache ---[index-1]*/ |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7972 | vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN); |
| 7973 | vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE); |
| 7974 | |
| 7975 | /*reduce the PMKID array index*/ |
| 7976 | PMKIDCacheIndex--; |
| 7977 | |
| 7978 | /*delete the last PMKID cache in CSR*/ |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7979 | if (eHAL_STATUS_SUCCESS != |
| 7980 | sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid)) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7981 | { |
| 7982 | hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.", |
| 7983 | __func__,PMKIDCacheIndex); |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 7984 | status = -EINVAL; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 7985 | } |
| 7986 | |
| 7987 | dump_bssid(pmksa->bssid); |
| 7988 | dump_pmkid(halHandle,pmksa->pmkid); |
| 7989 | |
| 7990 | break; |
| 7991 | } |
| 7992 | } |
| 7993 | |
| 7994 | /* we compare all entries,but cannot find matching entry */ |
| 7995 | if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched) |
| 7996 | { |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 7997 | hddLog(VOS_TRACE_LEVEL_FATAL, |
| 7998 | "%s: No such PMKSA entry existed " MAC_ADDRESS_STR, |
| 7999 | __func__, MAC_ADDR_ARRAY(pmksa->bssid)); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 8000 | dump_bssid(pmksa->bssid); |
| 8001 | dump_pmkid(halHandle, pmksa->pmkid); |
| 8002 | return -EINVAL; |
| 8003 | } |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 8004 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8005 | } |
| 8006 | |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 8007 | |
| 8008 | |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8009 | static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev) |
| 8010 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 8011 | tANI_U32 j=0; |
| 8012 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8013 | tHalHandle halHandle; |
| 8014 | hdd_context_t *pHddCtx; |
| 8015 | tANI_U8 *pBSSId; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 8016 | int status = 0; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 8017 | |
| 8018 | hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__); |
| 8019 | |
| 8020 | /* Validate pAdapter */ |
| 8021 | if (NULL == pAdapter) |
| 8022 | { |
| 8023 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8024 | "%s: Invalid Adapter" ,__func__); |
| 8025 | return -EINVAL; |
| 8026 | } |
| 8027 | |
| 8028 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8029 | status = wlan_hdd_validate_context(pHddCtx); |
| 8030 | |
| 8031 | if (0 != status) |
| 8032 | { |
| 8033 | hddLog(VOS_TRACE_LEVEL_ERROR, |
| 8034 | "%s: HDD context is not valid", __func__); |
| 8035 | return status; |
| 8036 | } |
| 8037 | |
| 8038 | /*Retrieve halHandle*/ |
| 8039 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8040 | |
| 8041 | /*in case index is 0,no entry to delete*/ |
| 8042 | if (0 == PMKIDCacheIndex) |
| 8043 | { |
| 8044 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" , |
| 8045 | __func__); |
| 8046 | return -EINVAL; |
| 8047 | } |
| 8048 | |
| 8049 | /*delete all the PMKSA one by one */ |
| 8050 | for (j = 0; j<PMKIDCacheIndex; j++) |
| 8051 | { |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 8052 | pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 8053 | |
| 8054 | /*delete the PMKID in CSR*/ |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 8055 | if (eHAL_STATUS_SUCCESS != |
| 8056 | sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId)) |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 8057 | { |
| 8058 | hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.", |
| 8059 | __func__,j); |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 8060 | status = -EINVAL; |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 8061 | } |
Kiet Lam | 8d21d5b | 2013-10-31 17:18:29 +0530 | [diff] [blame] | 8062 | /*clear the entry in HDD cache 0--index-1 */ |
| 8063 | vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN); |
| 8064 | vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE); |
Wilson Yang | 6507c4e | 2013-10-01 20:11:19 -0700 | [diff] [blame] | 8065 | } |
| 8066 | |
| 8067 | PMKIDCacheIndex = 0; |
Wilson Yang | ef657d3 | 2014-01-15 19:19:23 -0800 | [diff] [blame] | 8068 | return status; |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8069 | } |
| 8070 | #endif |
| 8071 | |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 8072 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8073 | static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 8074 | struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie) |
| 8075 | { |
| 8076 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8077 | hdd_station_ctx_t *pHddStaCtx; |
| 8078 | |
| 8079 | if (NULL == pAdapter) |
| 8080 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8081 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 8082 | return -ENODEV; |
| 8083 | } |
| 8084 | |
| 8085 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 8086 | |
| 8087 | // Added for debug on reception of Re-assoc Req. |
| 8088 | if (eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
| 8089 | { |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8090 | hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"), |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 8091 | ftie->ie_len); |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8092 | hddLog(LOGE, FL("Should be Re-assoc Req IEs")); |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 8093 | } |
| 8094 | |
| 8095 | #ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8096 | hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 8097 | ftie->ie_len); |
| 8098 | #endif |
| 8099 | |
| 8100 | // Pass the received FT IEs to SME |
Gopichand Nakkala | 356fb10 | 2013-03-06 12:34:04 +0530 | [diff] [blame] | 8101 | sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
| 8102 | (const u8 *)ftie->ie, |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 8103 | ftie->ie_len); |
| 8104 | return 0; |
| 8105 | } |
| 8106 | #endif |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 8107 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8108 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 8109 | |
| 8110 | void hdd_cfg80211_sched_scan_done_callback(void *callbackContext, |
| 8111 | tSirPrefNetworkFoundInd *pPrefNetworkFoundInd) |
| 8112 | { |
| 8113 | int ret; |
| 8114 | hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext; |
| 8115 | hdd_context_t *pHddCtx; |
| 8116 | |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 8117 | ENTER(); |
| 8118 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8119 | if (NULL == pAdapter) |
| 8120 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 8121 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8122 | "%s: HDD adapter is Null", __func__); |
| 8123 | return ; |
| 8124 | } |
| 8125 | |
| 8126 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8127 | if (NULL == pHddCtx) |
| 8128 | { |
| 8129 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8130 | "%s: HDD context is Null!!!", __func__); |
| 8131 | return ; |
| 8132 | } |
| 8133 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8134 | spin_lock(&pHddCtx->schedScan_lock); |
| 8135 | if (TRUE == pHddCtx->isWiphySuspended) |
| 8136 | { |
| 8137 | pHddCtx->isSchedScanUpdatePending = TRUE; |
| 8138 | spin_unlock(&pHddCtx->schedScan_lock); |
| 8139 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8140 | "%s: Update cfg80211 scan database after it resume", __func__); |
| 8141 | return ; |
| 8142 | } |
| 8143 | spin_unlock(&pHddCtx->schedScan_lock); |
| 8144 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8145 | ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter); |
| 8146 | |
| 8147 | if (0 > ret) |
| 8148 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__); |
| 8149 | |
| 8150 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8151 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8152 | "%s: cfg80211 scan result database updated", __func__); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8153 | } |
| 8154 | |
| 8155 | /* |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 8156 | * FUNCTION: wlan_hdd_is_pno_allowed |
| 8157 | * To check is there any P2P GO/SAP or P2P Client/STA |
| 8158 | * session is active |
| 8159 | */ |
| 8160 | static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter) |
| 8161 | { |
| 8162 | hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL; |
| 8163 | hdd_adapter_t *pTempAdapter = NULL; |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 8164 | hdd_station_ctx_t *pStaCtx; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 8165 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 8166 | int status = 0; |
| 8167 | status = hdd_get_front_adapter(pHddCtx, &pAdapterNode); |
| 8168 | |
| 8169 | while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status)) |
| 8170 | { |
| 8171 | pTempAdapter = pAdapterNode->pAdapter; |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 8172 | pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter); |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 8173 | |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 8174 | if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode) |
| 8175 | && (eConnectionState_NotConnected != pStaCtx->conn_info.connState)) |
| 8176 | || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode) |
| 8177 | || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode) |
| 8178 | || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode) |
| 8179 | ) |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 8180 | { |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 8181 | return eHAL_STATUS_FAILURE; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 8182 | } |
| 8183 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 8184 | pAdapterNode = pNext; |
| 8185 | } |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 8186 | return eHAL_STATUS_SUCCESS; |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 8187 | } |
| 8188 | |
| 8189 | /* |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8190 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_start |
| 8191 | * NL interface to enable PNO |
| 8192 | */ |
| 8193 | static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy, |
| 8194 | struct net_device *dev, struct cfg80211_sched_scan_request *request) |
| 8195 | { |
| 8196 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8197 | tpSirPNOScanReq pPnoRequest = NULL; |
| 8198 | hdd_context_t *pHddCtx; |
| 8199 | tHalHandle hHal; |
Madan Mohan Koyyalamudi | 1d16f46 | 2013-08-27 16:25:34 +0530 | [diff] [blame] | 8200 | v_U32_t i, indx, num_ch, tempInterval; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8201 | u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 8202 | u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 8203 | v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN; |
| 8204 | eHalStatus status = eHAL_STATUS_FAILURE; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8205 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8206 | |
| 8207 | if (NULL == pAdapter) |
| 8208 | { |
| 8209 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8210 | "%s: HDD adapter is Null", __func__); |
| 8211 | return -ENODEV; |
| 8212 | } |
| 8213 | |
| 8214 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8215 | ret = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8216 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8217 | if (0 != ret) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8218 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8219 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8220 | "%s: HDD context is not valid", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8221 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8222 | } |
| 8223 | |
| 8224 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8225 | if (NULL == hHal) |
| 8226 | { |
| 8227 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8228 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8229 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8230 | } |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 8231 | |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 8232 | /* The current firmware design for PNO does not consider concurrent |
| 8233 | * active sessions.Hence , determine the concurrent active sessions |
| 8234 | * and return a failure to the framework on a request for schedule |
| 8235 | * scan. |
| 8236 | */ |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 8237 | if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter)) |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 8238 | { |
| 8239 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Vinay Krishna Eranna | 23ffd18 | 2013-12-26 19:16:55 +0530 | [diff] [blame] | 8240 | FL("Cannot handle sched_scan")); |
Mahesh A Saptasagar | 0f7b037 | 2013-11-28 23:23:07 +0530 | [diff] [blame] | 8241 | return -EBUSY; |
| 8242 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8243 | |
| 8244 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 8245 | if (NULL == pPnoRequest) |
| 8246 | { |
| 8247 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8248 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8249 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8250 | } |
| 8251 | |
Madan Mohan Koyyalamudi | c3f0435 | 2013-09-26 19:21:48 +0530 | [diff] [blame] | 8252 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8253 | pPnoRequest->enable = 1; /*Enable PNO */ |
| 8254 | pPnoRequest->ucNetworksCount = request->n_match_sets; |
| 8255 | |
| 8256 | if (( !pPnoRequest->ucNetworksCount ) || |
| 8257 | ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS )) |
| 8258 | { |
| 8259 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 8260 | "%s: Network input is not correct %d", |
| 8261 | __func__, pPnoRequest->ucNetworksCount); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8262 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8263 | goto error; |
| 8264 | } |
| 8265 | |
| 8266 | if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels ) |
| 8267 | { |
| 8268 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 8269 | "%s: Incorrect number of channels %d", |
| 8270 | __func__, request->n_channels); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8271 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8272 | goto error; |
| 8273 | } |
| 8274 | |
| 8275 | /* Framework provides one set of channels(all) |
| 8276 | * common for all saved profile */ |
| 8277 | if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST, |
| 8278 | channels_allowed, &num_channels_allowed)) |
| 8279 | { |
| 8280 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8281 | "%s: failed to get valid channel list", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8282 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8283 | goto error; |
| 8284 | } |
| 8285 | /* Checking each channel against allowed channel list */ |
| 8286 | num_ch = 0; |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 8287 | if (request->n_channels) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8288 | { |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 8289 | char chList [(request->n_channels*5)+1]; |
| 8290 | int len; |
| 8291 | for (i = 0, len = 0; i < request->n_channels; i++) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8292 | { |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 8293 | for (indx = 0; indx < num_channels_allowed; indx++) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8294 | { |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 8295 | if (request->channels[i]->hw_value == channels_allowed[indx]) |
| 8296 | { |
| 8297 | valid_ch[num_ch++] = request->channels[i]->hw_value; |
| 8298 | len += snprintf(chList+len, 5, "%d ", |
| 8299 | request->channels[i]->hw_value); |
| 8300 | break ; |
| 8301 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8302 | } |
| 8303 | } |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 8304 | hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList); |
| 8305 | } |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8306 | |
| 8307 | /* Filling per profile params */ |
| 8308 | for (i = 0; i < pPnoRequest->ucNetworksCount; i++) |
| 8309 | { |
| 8310 | pPnoRequest->aNetworks[i].ssId.length = |
| 8311 | request->match_sets[i].ssid.ssid_len; |
| 8312 | |
| 8313 | if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) || |
| 8314 | ( pPnoRequest->aNetworks[i].ssId.length > 32 ) ) |
| 8315 | { |
| 8316 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 8317 | "%s: SSID Len %d is not correct for network %d", |
| 8318 | __func__, pPnoRequest->aNetworks[i].ssId.length, i); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8319 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8320 | goto error; |
| 8321 | } |
| 8322 | |
| 8323 | memcpy(pPnoRequest->aNetworks[i].ssId.ssId, |
| 8324 | request->match_sets[i].ssid.ssid, |
| 8325 | request->match_sets[i].ssid.ssid_len); |
| 8326 | pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/ |
| 8327 | pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/ |
| 8328 | pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/ |
| 8329 | |
| 8330 | /*Copying list of valid channel into request */ |
| 8331 | memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch); |
| 8332 | pPnoRequest->aNetworks[i].ucChannelCount = num_ch; |
| 8333 | |
| 8334 | pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value |
| 8335 | } |
| 8336 | |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 8337 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
Jeff Johnson | 59a121e | 2013-11-30 09:46:08 -0800 | [diff] [blame] | 8338 | "request->ie_len = %zu", request->ie_len); |
Madan Mohan Koyyalamudi | a7765d5 | 2013-09-18 16:49:56 +0530 | [diff] [blame] | 8339 | if ((0 < request->ie_len) && (NULL != request->ie)) |
| 8340 | { |
| 8341 | pPnoRequest->us24GProbeTemplateLen = request->ie_len; |
| 8342 | memcpy(&pPnoRequest->p24GProbeTemplate, request->ie, |
| 8343 | pPnoRequest->us24GProbeTemplateLen); |
| 8344 | |
| 8345 | pPnoRequest->us5GProbeTemplateLen = request->ie_len; |
| 8346 | memcpy(&pPnoRequest->p5GProbeTemplate, request->ie, |
| 8347 | pPnoRequest->us5GProbeTemplateLen); |
| 8348 | } |
| 8349 | |
Madan Mohan Koyyalamudi | 1d16f46 | 2013-08-27 16:25:34 +0530 | [diff] [blame] | 8350 | /* Driver gets only one time interval which is hardcoded in |
| 8351 | * supplicant for 10000ms. Taking power consumption into account 6 timers |
| 8352 | * will be used, Timervalue is increased exponentially i.e 10,20,40, |
| 8353 | * 80,160,320 secs. And number of scan cycle for each timer |
| 8354 | * is configurable through INI param gPNOScanTimerRepeatValue. |
| 8355 | * If it is set to 0 only one timer will be used and PNO scan cycle |
| 8356 | * will be repeated after each interval specified by supplicant |
| 8357 | * till PNO is disabled. |
| 8358 | */ |
| 8359 | if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue) |
| 8360 | pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE; |
| 8361 | else |
| 8362 | pPnoRequest->scanTimers.ucScanTimersCount = |
| 8363 | HDD_PNO_SCAN_TIMERS_SET_MULTIPLE; |
| 8364 | |
| 8365 | tempInterval = (request->interval)/1000; |
| 8366 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8367 | "Base scan interval = %d PNOScanTimerRepeatValue = %d", |
| 8368 | tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue); |
| 8369 | for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++) |
| 8370 | { |
| 8371 | pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat = |
| 8372 | pHddCtx->cfg_ini->configPNOScanTimerRepeatValue; |
| 8373 | pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval; |
| 8374 | tempInterval *= 2; |
| 8375 | } |
| 8376 | //Repeat last timer until pno disabled. |
| 8377 | pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0; |
| 8378 | |
Madan Mohan Koyyalamudi | d206c7b | 2013-09-26 22:54:51 +0530 | [diff] [blame] | 8379 | pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8380 | |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 8381 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8382 | "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d", |
| 8383 | pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO, |
| 8384 | pPnoRequest->scanTimers.ucScanTimersCount); |
| 8385 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8386 | status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 8387 | pPnoRequest, pAdapter->sessionId, |
| 8388 | hdd_cfg80211_sched_scan_done_callback, pAdapter); |
| 8389 | if (eHAL_STATUS_SUCCESS != status) |
| 8390 | { |
| 8391 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Nirav Shah | 80830bf | 2013-12-31 16:35:12 +0530 | [diff] [blame] | 8392 | "%s: Failed to enable PNO", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8393 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8394 | goto error; |
| 8395 | } |
| 8396 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8397 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8398 | "PNO scanRequest offloaded"); |
| 8399 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8400 | error: |
| 8401 | vos_mem_free(pPnoRequest); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8402 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8403 | } |
| 8404 | |
| 8405 | /* |
| 8406 | * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop |
| 8407 | * NL interface to disable PNO |
| 8408 | */ |
| 8409 | static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy, |
| 8410 | struct net_device *dev) |
| 8411 | { |
| 8412 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 8413 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8414 | hdd_context_t *pHddCtx; |
| 8415 | tHalHandle hHal; |
| 8416 | tpSirPNOScanReq pPnoRequest = NULL; |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8417 | int ret = 0; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8418 | |
| 8419 | ENTER(); |
| 8420 | |
| 8421 | if (NULL == pAdapter) |
| 8422 | { |
| 8423 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8424 | "%s: HDD adapter is Null", __func__); |
| 8425 | return -ENODEV; |
| 8426 | } |
| 8427 | |
| 8428 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8429 | |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8430 | if (NULL == pHddCtx) |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8431 | { |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 8432 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8433 | "%s: HDD context is Null", __func__); |
| 8434 | return -ENODEV; |
| 8435 | } |
| 8436 | |
| 8437 | /* The return 0 is intentional when isLogpInProgress and |
| 8438 | * isLoadUnloadInProgress. We did observe a crash due to a return of |
| 8439 | * failure in sched_scan_stop , especially for a case where the unload |
| 8440 | * of the happens at the same time. The function __cfg80211_stop_sched_scan |
| 8441 | * was clearing rdev->sched_scan_req only when the sched_scan_stop returns |
| 8442 | * success. If it returns a failure , then its next invocation due to the |
| 8443 | * clean up of the second interface will have the dev pointer corresponding |
| 8444 | * to the first one leading to a crash. |
| 8445 | */ |
| 8446 | if (pHddCtx->isLogpInProgress) |
| 8447 | { |
| 8448 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8449 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 8450 | return ret; |
| 8451 | } |
| 8452 | |
| 8453 | if (pHddCtx->isLoadUnloadInProgress) |
| 8454 | { |
| 8455 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8456 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 8457 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8458 | } |
| 8459 | |
| 8460 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 8461 | if (NULL == hHal) |
| 8462 | { |
| 8463 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8464 | "%s: HAL context is Null!!!", __func__); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8465 | return -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8466 | } |
| 8467 | |
| 8468 | pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq)); |
| 8469 | if (NULL == pPnoRequest) |
| 8470 | { |
| 8471 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 8472 | "%s: vos_mem_malloc failed", __func__); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8473 | return -ENOMEM; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8474 | } |
| 8475 | |
| 8476 | memset(pPnoRequest, 0, sizeof (tSirPNOScanReq)); |
| 8477 | pPnoRequest->enable = 0; /* Disable PNO */ |
| 8478 | pPnoRequest->ucNetworksCount = 0; |
| 8479 | |
| 8480 | status = sme_SetPreferredNetworkList(hHal, pPnoRequest, |
| 8481 | pAdapter->sessionId, |
| 8482 | NULL, pAdapter); |
| 8483 | if (eHAL_STATUS_SUCCESS != status) |
| 8484 | { |
| 8485 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8486 | "Failed to disabled PNO"); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8487 | ret = -EINVAL; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8488 | } |
| 8489 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 8490 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8491 | "%s: PNO scan disabled", __func__); |
| 8492 | |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8493 | vos_mem_free(pPnoRequest); |
| 8494 | |
| 8495 | EXIT(); |
Kamath Vinayak | ba5313f | 2013-08-22 15:52:39 +0530 | [diff] [blame] | 8496 | return ret; |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 8497 | } |
| 8498 | |
| 8499 | #endif /*FEATURE_WLAN_SCAN_PNO*/ |
| 8500 | |
| 8501 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8502 | #ifdef FEATURE_WLAN_TDLS |
| 8503 | static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 8504 | u8 *peer, u8 action_code, u8 dialog_token, |
| 8505 | u16 status_code, const u8 *buf, size_t len) |
| 8506 | { |
| 8507 | |
| 8508 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8509 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8510 | u8 peerMac[6]; |
| 8511 | VOS_STATUS status; |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8512 | int max_sta_failed = 0; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8513 | int responder; |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8514 | long rc; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8515 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8516 | if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8517 | { |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 8518 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8519 | "Invalid arguments"); |
| 8520 | return -EINVAL; |
| 8521 | } |
| 8522 | |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 8523 | if (pHddCtx->isLogpInProgress) |
| 8524 | { |
| 8525 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8526 | "%s:LOGP in Progress. Ignore!!!", __func__); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8527 | wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE); |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 8528 | return -EBUSY; |
| 8529 | } |
| 8530 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 8531 | if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8532 | { |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 8533 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 8534 | "%s: TDLS mode is disabled OR not enabled in FW." |
| 8535 | MAC_ADDRESS_STR " action %d declined.", |
| 8536 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8537 | return -ENOTSUPP; |
| 8538 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8539 | |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 8540 | /* other than teardown frame, other mgmt frames are not sent if disabled */ |
| 8541 | if (SIR_MAC_TDLS_TEARDOWN != action_code) |
| 8542 | { |
| 8543 | /* if tdls_mode is disabled to respond to peer's request */ |
| 8544 | if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode) |
| 8545 | { |
| 8546 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
| 8547 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 8548 | " TDLS mode is disabled. action %d declined.", |
| 8549 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 2751190 | 2013-03-14 18:19:06 -0700 | [diff] [blame] | 8550 | |
| 8551 | return -ENOTSUPP; |
| 8552 | } |
| 8553 | } |
| 8554 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8555 | if (WLAN_IS_TDLS_SETUP_ACTION(action_code)) |
| 8556 | { |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8557 | if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8558 | { |
| 8559 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8560 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 8561 | " TDLS setup is ongoing. action %d declined.", |
| 8562 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 8563 | return -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8564 | } |
| 8565 | } |
| 8566 | |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8567 | if (SIR_MAC_TDLS_SETUP_REQ == action_code || |
| 8568 | SIR_MAC_TDLS_SETUP_RSP == action_code ) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8569 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8570 | if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8571 | { |
| 8572 | /* supplicant still sends tdls_mgmt(SETUP_REQ) even after |
| 8573 | we return error code at 'add_station()'. Hence we have this |
| 8574 | check again in addtion to add_station(). |
| 8575 | Anyway, there is no hard to double-check. */ |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8576 | if (SIR_MAC_TDLS_SETUP_REQ == action_code) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8577 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8578 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8579 | "%s: " MAC_ADDRESS_STR |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 8580 | " TDLS Max peer already connected. action %d declined.", |
| 8581 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 8582 | return -EINVAL; |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8583 | } |
| 8584 | else |
| 8585 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8586 | /* maximum reached. tweak to send error code to peer and return |
| 8587 | error code to supplicant */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8588 | status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS; |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8589 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8590 | "%s: " MAC_ADDRESS_STR |
| 8591 | " TDLS Max peer already connected send response status %d", |
| 8592 | __func__, MAC_ADDR_ARRAY(peer), status_code); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8593 | max_sta_failed = -EPERM; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8594 | /* fall through to send setup resp with failure status |
| 8595 | code */ |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8596 | } |
| 8597 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8598 | else |
| 8599 | { |
| 8600 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8601 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 8602 | if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8603 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8604 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 34d1b06 | 2013-03-19 15:28:33 -0700 | [diff] [blame] | 8605 | "%s:" MAC_ADDRESS_STR " already connected. action %d declined.", |
| 8606 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8607 | return -EPERM; |
| 8608 | } |
| 8609 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8610 | } |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8611 | vos_mem_copy(peerMac, peer, 6); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8612 | |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8613 | #ifdef WLAN_FEATURE_TDLS_DEBUG |
| 8614 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8615 | "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d", |
| 8616 | "tdls_mgmt", MAC_ADDR_ARRAY(peer), |
| 8617 | action_code, dialog_token, status_code, len); |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8618 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8619 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8620 | /*Except teardown responder will not be used so just make 0*/ |
| 8621 | responder = 0; |
Hoonki Lee | 11f7dda | 2013-02-14 16:55:44 -0800 | [diff] [blame] | 8622 | if (SIR_MAC_TDLS_TEARDOWN == action_code) |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8623 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 8624 | |
| 8625 | hddTdlsPeer_t *pTdlsPeer; |
Madan Mohan Koyyalamudi | 9679744 | 2013-10-08 16:04:42 +0530 | [diff] [blame] | 8626 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE); |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 8627 | |
| 8628 | if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer)) |
| 8629 | responder = pTdlsPeer->is_responder; |
| 8630 | else |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8631 | { |
Gopichand Nakkala | 97a65fd | 2013-04-16 16:59:38 -0700 | [diff] [blame] | 8632 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8633 | "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d", |
| 8634 | __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status, |
| 8635 | dialog_token, status_code, len); |
| 8636 | return -EPERM; |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8637 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8638 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8639 | |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 8640 | /* For explicit trigger of DIS_REQ come out of BMPS for |
| 8641 | successfully receiving DIS_RSP from peer. */ |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8642 | if ((SIR_MAC_TDLS_SETUP_RSP == action_code) || |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 8643 | (SIR_MAC_TDLS_DIS_RSP == action_code) || |
| 8644 | (SIR_MAC_TDLS_DIS_REQ == action_code)) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8645 | { |
| 8646 | if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter))) |
| 8647 | { |
| 8648 | VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL, |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 8649 | "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8650 | hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION); |
| 8651 | } |
Gopichand Nakkala | 2f1ff15 | 2013-07-01 11:27:43 +0530 | [diff] [blame] | 8652 | if (SIR_MAC_TDLS_DIS_REQ != action_code) |
| 8653 | wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED); |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8654 | } |
| 8655 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8656 | /* make sure doesn't call send_mgmt() while it is pending */ |
| 8657 | if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus) |
| 8658 | { |
| 8659 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 6d2a332 | 2013-11-17 19:50:10 -0800 | [diff] [blame] | 8660 | "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY", |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8661 | __func__, MAC_ADDR_ARRAY(peer), action_code); |
| 8662 | return -EBUSY; |
| 8663 | } |
| 8664 | |
| 8665 | pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8666 | INIT_COMPLETION(pAdapter->tdls_mgmt_comp); |
| 8667 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8668 | status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8669 | peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8670 | |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8671 | if (VOS_STATUS_SUCCESS != status) |
| 8672 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8673 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8674 | "%s: sme_SendTdlsMgmtFrame failed!", __func__); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8675 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8676 | wlan_hdd_tdls_check_bmps(pAdapter); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 8677 | return -EINVAL; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8678 | } |
| 8679 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8680 | rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp, |
| 8681 | msecs_to_jiffies(WAIT_TIME_TDLS_MGMT)); |
| 8682 | |
| 8683 | if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus)) |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8684 | { |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8685 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Jeff Johnson | 0299d0a | 2013-10-30 12:37:43 -0700 | [diff] [blame] | 8686 | "%s: Mgmt Tx Completion failed status %ld TxCompletion %u", |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8687 | __func__, rc, pAdapter->mgmtTxCompletionStatus); |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8688 | pAdapter->mgmtTxCompletionStatus = FALSE; |
Yue Ma | 4f55ef3 | 2014-01-23 16:45:33 -0800 | [diff] [blame] | 8689 | |
| 8690 | if (pHddCtx->isLogpInProgress) |
| 8691 | { |
| 8692 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8693 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 8694 | return -EAGAIN; |
| 8695 | } |
| 8696 | |
Hoonki Lee | d37cbb3 | 2013-04-20 00:31:14 -0700 | [diff] [blame] | 8697 | wlan_hdd_tdls_check_bmps(pAdapter); |
Sunil Dutt | 388ac8f | 2013-11-28 18:06:52 +0530 | [diff] [blame] | 8698 | return -EINVAL; |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8699 | } |
| 8700 | |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8701 | if (max_sta_failed) |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8702 | { |
| 8703 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 0592280 | 2013-03-14 12:23:19 -0700 | [diff] [blame] | 8704 | return max_sta_failed; |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8705 | } |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8706 | |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8707 | if (SIR_MAC_TDLS_SETUP_RSP == action_code) |
| 8708 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8709 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8710 | } |
| 8711 | else if (SIR_MAC_TDLS_SETUP_CNF == action_code) |
| 8712 | { |
Gopichand Nakkala | 4327a15 | 2013-03-04 23:22:42 -0800 | [diff] [blame] | 8713 | wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE); |
Hoonki Lee | a34dd89 | 2013-02-05 22:56:02 -0800 | [diff] [blame] | 8714 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8715 | |
| 8716 | return 0; |
| 8717 | } |
| 8718 | |
| 8719 | static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, |
| 8720 | u8 *peer, enum nl80211_tdls_operation oper) |
| 8721 | { |
| 8722 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 8723 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8724 | int status; |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8725 | hddTdlsPeer_t *pTdlsPeer; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8726 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8727 | if ( NULL == peer ) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8728 | { |
Gopichand Nakkala | b977a97 | 2013-02-18 19:15:09 -0800 | [diff] [blame] | 8729 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 8730 | "%s: Invalid arguments", __func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8731 | return -EINVAL; |
| 8732 | } |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8733 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8734 | status = wlan_hdd_validate_context(pHddCtx); |
| 8735 | |
| 8736 | if (0 != status) |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 8737 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 8738 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8739 | "%s: HDD context is not valid", __func__); |
| 8740 | return status; |
Sameer Thalappil | 75ea31a | 2013-02-21 19:38:16 -0800 | [diff] [blame] | 8741 | } |
| 8742 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8743 | |
| 8744 | if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport || |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8745 | FALSE == sme_IsFeatureSupportedByFW(TDLS)) |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8746 | { |
Hoonki Lee | 1090c6a | 2013-01-16 17:40:54 -0800 | [diff] [blame] | 8747 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Chilam Ng | c4244af | 2013-04-01 15:37:32 -0700 | [diff] [blame] | 8748 | "TDLS Disabled in INI OR not enabled in FW. " |
| 8749 | "Cannot process TDLS commands"); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8750 | return -ENOTSUPP; |
| 8751 | } |
| 8752 | |
| 8753 | switch (oper) { |
| 8754 | case NL80211_TDLS_ENABLE_LINK: |
| 8755 | { |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8756 | VOS_STATUS status; |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8757 | long ret; |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8758 | tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8759 | |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8760 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 8761 | |
| 8762 | if ( NULL == pTdlsPeer ) { |
| 8763 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 8764 | " (oper %d) not exsting. ignored", |
| 8765 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 8766 | return -EINVAL; |
| 8767 | } |
| 8768 | |
| 8769 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8770 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 8771 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
| 8772 | "NL80211_TDLS_ENABLE_LINK"); |
| 8773 | |
Gopichand Nakkala | 2f4a282 | 2013-04-17 11:22:01 -0700 | [diff] [blame] | 8774 | if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
| 8775 | { |
| 8776 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u " |
| 8777 | MAC_ADDRESS_STR " failed", |
| 8778 | __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer)); |
| 8779 | return -EINVAL; |
| 8780 | } |
| 8781 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8782 | if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status) |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8783 | { |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 8784 | if (IS_ADVANCE_TDLS_ENABLE) { |
Gopichand Nakkala | 24be531 | 2013-07-02 16:47:12 +0530 | [diff] [blame] | 8785 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 8786 | if (0 != wlan_hdd_tdls_get_link_establish_params( |
| 8787 | pAdapter, peer,&tdlsLinkEstablishParams)) { |
| 8788 | return -EINVAL; |
| 8789 | } |
| 8790 | INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8791 | |
Madan Mohan Koyyalamudi | ce41987 | 2013-09-13 19:36:52 +0530 | [diff] [blame] | 8792 | sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 8793 | pAdapter->sessionId, peer, &tdlsLinkEstablishParams); |
| 8794 | /* Send TDLS peer UAPSD capabilities to the firmware and |
| 8795 | * register with the TL on after the response for this operation |
| 8796 | * is received . |
| 8797 | */ |
| 8798 | ret = wait_for_completion_interruptible_timeout( |
| 8799 | &pAdapter->tdls_link_establish_req_comp, |
| 8800 | msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ)); |
| 8801 | if (ret <= 0) |
| 8802 | { |
| 8803 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8804 | "%s: Link Establish Request Faled Status %ld", |
| 8805 | __func__, ret); |
| 8806 | return -EINVAL; |
| 8807 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8808 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 8809 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED); |
Gopichand Nakkala | 471708b | 2013-06-04 20:03:01 +0530 | [diff] [blame] | 8810 | /* Mark TDLS client Authenticated .*/ |
| 8811 | status = WLANTL_ChangeSTAState( pHddCtx->pvosContext, |
| 8812 | pTdlsPeer->staId, |
| 8813 | WLANTL_STA_AUTHENTICATED); |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 8814 | if (VOS_STATUS_SUCCESS == status) |
| 8815 | { |
Hoonki Lee | 1462135 | 2013-04-16 17:51:19 -0700 | [diff] [blame] | 8816 | if (pTdlsPeer->is_responder == 0) |
| 8817 | { |
| 8818 | v_U8_t staId = (v_U8_t)pTdlsPeer->staId; |
| 8819 | |
| 8820 | wlan_hdd_tdls_timer_restart(pAdapter, |
| 8821 | &pTdlsPeer->initiatorWaitTimeoutTimer, |
| 8822 | WAIT_TIME_TDLS_INITIATOR); |
| 8823 | /* suspend initiator TX until it receives direct packet from the |
| 8824 | reponder or WAIT_TIME_TDLS_INITIATOR timer expires */ |
| 8825 | WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 8826 | &staId, NULL); |
| 8827 | } |
Gopichand Nakkala | ccd3a38 | 2013-03-19 13:56:10 -0700 | [diff] [blame] | 8828 | wlan_hdd_tdls_increment_peer_count(pAdapter); |
| 8829 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8830 | wlan_hdd_tdls_check_bmps(pAdapter); |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8831 | |
| 8832 | /* Update TL about the UAPSD masks , to route the packets to firmware */ |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 8833 | if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta) |
| 8834 | || pHddCtx->cfg_ini->fTDLSUapsdMask ) |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8835 | { |
Gopichand Nakkala | 574f6d1 | 2013-06-27 19:38:43 +0530 | [diff] [blame] | 8836 | int ac; |
| 8837 | uint8 ucAc[4] = { WLANTL_AC_VO, |
| 8838 | WLANTL_AC_VI, |
| 8839 | WLANTL_AC_BK, |
| 8840 | WLANTL_AC_BE }; |
| 8841 | uint8 tlTid[4] = { 7, 5, 2, 3 } ; |
| 8842 | for(ac=0; ac < 4; ac++) |
| 8843 | { |
| 8844 | status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, |
| 8845 | pTdlsPeer->staId, ucAc[ac], |
| 8846 | tlTid[ac], tlTid[ac], 0, 0, |
| 8847 | WLANTL_BI_DIR ); |
| 8848 | } |
Gopichand Nakkala | 79ff85d | 2013-05-27 17:05:29 +0530 | [diff] [blame] | 8849 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8850 | } |
| 8851 | |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8852 | } |
| 8853 | break; |
| 8854 | case NL80211_TDLS_DISABLE_LINK: |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8855 | { |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8856 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 8857 | |
| 8858 | if ( NULL == pTdlsPeer ) { |
| 8859 | hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR |
| 8860 | " (oper %d) not exsting. ignored", |
| 8861 | __func__, MAC_ADDR_ARRAY(peer), (int)oper); |
| 8862 | return -EINVAL; |
| 8863 | } |
| 8864 | |
| 8865 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8866 | "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper", |
| 8867 | MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status, |
| 8868 | "NL80211_TDLS_DISABLE_LINK"); |
| 8869 | |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8870 | if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8871 | { |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 8872 | long status; |
| 8873 | |
| 8874 | INIT_COMPLETION(pAdapter->tdls_del_station_comp); |
| 8875 | |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8876 | sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter), |
| 8877 | pAdapter->sessionId, peer ); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 8878 | |
| 8879 | status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp, |
| 8880 | msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA)); |
| 8881 | if (status <= 0) |
| 8882 | { |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8883 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Gopichand Nakkala | e7cbc5d | 2013-03-27 21:09:23 -0700 | [diff] [blame] | 8884 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8885 | "%s: Del station failed status %ld", |
| 8886 | __func__, status); |
| 8887 | return -EPERM; |
| 8888 | } |
Hoonki Lee | 5305c3a | 2013-04-29 23:28:59 -0700 | [diff] [blame] | 8889 | wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8890 | } |
| 8891 | else |
| 8892 | { |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8893 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8894 | "%s: TDLS Peer Station doesn't exist.", __func__); |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8895 | } |
Lee Hoonki | c1262f2 | 2013-01-24 21:59:00 -0800 | [diff] [blame] | 8896 | } |
Gopichand Nakkala | c87400e | 2013-03-13 18:51:00 -0700 | [diff] [blame] | 8897 | break; |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8898 | case NL80211_TDLS_TEARDOWN: |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8899 | { |
| 8900 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8901 | " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR, |
| 8902 | __func__, MAC_ADDR_ARRAY(peer)); |
| 8903 | |
| 8904 | if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) || |
| 8905 | (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) { |
| 8906 | |
| 8907 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8908 | " %s TDLS External control and Implicit Trigger not enabled ", |
| 8909 | __func__); |
| 8910 | return -ENOTSUPP; |
| 8911 | } |
| 8912 | |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8913 | |
| 8914 | pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE); |
| 8915 | |
| 8916 | if ( NULL == pTdlsPeer ) { |
| 8917 | hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR |
| 8918 | " peer not exsting", |
| 8919 | __func__, MAC_ADDR_ARRAY(peer)); |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 8920 | return -EINVAL; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8921 | } |
| 8922 | else { |
| 8923 | wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer, |
| 8924 | eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON); |
| 8925 | } |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 8926 | |
| 8927 | if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) |
| 8928 | return -EINVAL; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8929 | break; |
| 8930 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8931 | case NL80211_TDLS_SETUP: |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8932 | { |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 8933 | hddTdlsPeer_t *pTdlsPeer; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8934 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8935 | " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR, |
| 8936 | __func__, MAC_ADDR_ARRAY(peer)); |
| 8937 | |
| 8938 | if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) || |
| 8939 | (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) { |
| 8940 | |
| 8941 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 8942 | " %s TDLS External control and Implicit Trigger not enabled ", |
| 8943 | __func__); |
| 8944 | return -ENOTSUPP; |
| 8945 | } |
| 8946 | |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 8947 | /* To cater the requirement of establishing the TDLS link |
| 8948 | * irrespective of the data traffic , get an entry of TDLS peer. |
| 8949 | */ |
| 8950 | pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer); |
| 8951 | if (pTdlsPeer == NULL) { |
| 8952 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8953 | "%s: peer " MAC_ADDRESS_STR " not existing", |
| 8954 | __func__, MAC_ADDR_ARRAY(peer)); |
| 8955 | return -EINVAL; |
| 8956 | } |
Naresh Jayaram | 937abdf | 2013-11-26 19:50:25 +0530 | [diff] [blame] | 8957 | |
| 8958 | if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) { |
| 8959 | |
| 8960 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8961 | " %s TDLS Add Force Peer Failed", |
| 8962 | __func__); |
| 8963 | return -EINVAL; |
| 8964 | } |
Naresh Jayaram | db4514b | 2013-11-25 18:08:10 +0530 | [diff] [blame] | 8965 | break; |
Sunil Dutt | 41de4e2 | 2013-11-14 18:09:02 +0530 | [diff] [blame] | 8966 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8967 | case NL80211_TDLS_DISCOVERY_REQ: |
| 8968 | /* We don't support in-driver setup/teardown/discovery */ |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8969 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 8970 | "%s: We don't support in-driver setup/teardown/discovery " |
| 8971 | ,__func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8972 | return -ENOTSUPP; |
| 8973 | default: |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 8974 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 8975 | "%s: unsupported event",__func__); |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8976 | return -ENOTSUPP; |
| 8977 | } |
| 8978 | return 0; |
| 8979 | } |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 8980 | |
| 8981 | int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy, |
| 8982 | struct net_device *dev, u8 *peer) |
| 8983 | { |
Arif Hussain | a7c8e41 | 2013-11-20 11:06:42 -0800 | [diff] [blame] | 8984 | hddLog(VOS_TRACE_LEVEL_INFO, |
| 8985 | "tdls send discover req: "MAC_ADDRESS_STR, |
| 8986 | MAC_ADDR_ARRAY(peer)); |
Chilam NG | 571c65a | 2013-01-19 12:27:36 +0530 | [diff] [blame] | 8987 | |
| 8988 | return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, |
| 8989 | WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0); |
| 8990 | } |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 8991 | #endif |
| 8992 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 8993 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 8994 | /* |
| 8995 | * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback |
| 8996 | * Callback rountine called upon receiving response for |
| 8997 | * get offload info |
| 8998 | */ |
| 8999 | void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext, |
| 9000 | tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp) |
| 9001 | { |
| 9002 | |
| 9003 | hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 9004 | tANI_U8 tempReplayCounter[8]; |
| 9005 | hdd_station_ctx_t *pHddStaCtx; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9006 | |
| 9007 | ENTER(); |
| 9008 | |
| 9009 | if (NULL == pAdapter) |
| 9010 | { |
Agarwal Ashish | 971c288 | 2013-10-30 20:11:12 +0530 | [diff] [blame] | 9011 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9012 | "%s: HDD adapter is Null", __func__); |
| 9013 | return ; |
| 9014 | } |
| 9015 | |
| 9016 | if (NULL == pGtkOffloadGetInfoRsp) |
| 9017 | { |
| 9018 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9019 | "%s: pGtkOffloadGetInfoRsp is Null", __func__); |
| 9020 | return ; |
| 9021 | } |
| 9022 | |
| 9023 | if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus) |
| 9024 | { |
| 9025 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9026 | "%s: wlan Failed to get replay counter value", |
| 9027 | __func__); |
| 9028 | return ; |
| 9029 | } |
| 9030 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 9031 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9032 | /* Update replay counter */ |
| 9033 | pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter = |
| 9034 | pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 9035 | |
| 9036 | { |
| 9037 | /* changing from little to big endian since supplicant |
| 9038 | * works on big endian format |
| 9039 | */ |
| 9040 | int i; |
| 9041 | tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter; |
| 9042 | |
| 9043 | for (i = 0; i < 8; i++) |
| 9044 | { |
| 9045 | tempReplayCounter[7-i] = (tANI_U8)p[i]; |
| 9046 | } |
| 9047 | } |
| 9048 | |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9049 | /* Update replay counter to NL */ |
| 9050 | cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId, |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 9051 | tempReplayCounter, GFP_KERNEL); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9052 | } |
| 9053 | |
| 9054 | /* |
| 9055 | * FUNCTION: wlan_hdd_cfg80211_set_rekey_data |
| 9056 | * This function is used to offload GTK rekeying job to the firmware. |
| 9057 | */ |
| 9058 | int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev, |
| 9059 | struct cfg80211_gtk_rekey_data *data) |
| 9060 | { |
| 9061 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9062 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 9063 | hdd_station_ctx_t *pHddStaCtx; |
| 9064 | tHalHandle hHal; |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9065 | int result; |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 9066 | tSirGtkOffloadParams hddGtkOffloadReqParams; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9067 | eHalStatus status = eHAL_STATUS_FAILURE; |
| 9068 | |
| 9069 | ENTER(); |
| 9070 | |
| 9071 | if (NULL == pAdapter) |
| 9072 | { |
| 9073 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9074 | "%s: HDD adapter is Null", __func__); |
| 9075 | return -ENODEV; |
| 9076 | } |
| 9077 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9078 | result = wlan_hdd_validate_context(pHddCtx); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9079 | |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9080 | if (0 != result) |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9081 | { |
Gopichand Nakkala | f502e2b | 2013-05-24 18:34:25 +0530 | [diff] [blame] | 9082 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9083 | "%s: HDD context is not valid", __func__); |
| 9084 | return result; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9085 | } |
| 9086 | |
| 9087 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9088 | hHal = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 9089 | if (NULL == hHal) |
| 9090 | { |
| 9091 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9092 | "%s: HAL context is Null!!!", __func__); |
| 9093 | return -EAGAIN; |
| 9094 | } |
| 9095 | |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 9096 | pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE; |
| 9097 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN); |
| 9098 | memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN); |
| 9099 | memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9100 | WNI_CFG_BSSID_LEN); |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 9101 | { |
| 9102 | /* changing from big to little endian since driver |
| 9103 | * works on little endian format |
| 9104 | */ |
| 9105 | tANI_U8 *p = |
| 9106 | (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter; |
| 9107 | int i; |
| 9108 | |
| 9109 | for (i = 0; i < 8; i++) |
| 9110 | { |
| 9111 | p[7-i] = data->replay_ctr[i]; |
| 9112 | } |
| 9113 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9114 | |
| 9115 | if (TRUE == pHddCtx->hdd_wlan_suspended) |
| 9116 | { |
| 9117 | /* if wlan is suspended, enable GTK offload directly from here */ |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 9118 | memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams, |
| 9119 | sizeof (tSirGtkOffloadParams)); |
| 9120 | status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams, |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9121 | pAdapter->sessionId); |
| 9122 | |
| 9123 | if (eHAL_STATUS_SUCCESS != status) |
| 9124 | { |
| 9125 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9126 | "%s: sme_SetGTKOffload failed, returned %d", |
| 9127 | __func__, status); |
| 9128 | return status; |
| 9129 | } |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9130 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9131 | "%s: sme_SetGTKOffload successfull", __func__); |
| 9132 | } |
| 9133 | else |
| 9134 | { |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9135 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9136 | "%s: wlan not suspended GTKOffload request is stored", |
| 9137 | __func__); |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9138 | } |
Gopichand Nakkala | d36ee62 | 2013-05-07 14:13:27 +0530 | [diff] [blame] | 9139 | |
| 9140 | return eHAL_STATUS_SUCCESS; |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9141 | } |
| 9142 | #endif /*WLAN_FEATURE_GTK_OFFLOAD*/ |
| 9143 | |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 9144 | /* |
| 9145 | * FUNCTION: wlan_hdd_cfg80211_set_mac_acl |
| 9146 | * This function is used to set access control policy |
| 9147 | */ |
| 9148 | static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy, |
| 9149 | struct net_device *dev, const struct cfg80211_acl_data *params) |
| 9150 | { |
| 9151 | int i; |
| 9152 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9153 | hdd_hostapd_state_t *pHostapdState; |
| 9154 | tsap_Config_t *pConfig; |
| 9155 | v_CONTEXT_t pVosContext = NULL; |
| 9156 | hdd_context_t *pHddCtx; |
| 9157 | int status; |
| 9158 | |
| 9159 | ENTER(); |
| 9160 | |
| 9161 | if (NULL == pAdapter) |
| 9162 | { |
| 9163 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9164 | "%s: HDD adapter is Null", __func__); |
| 9165 | return -ENODEV; |
| 9166 | } |
| 9167 | |
| 9168 | if (NULL == params) |
| 9169 | { |
| 9170 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9171 | "%s: params is Null", __func__); |
| 9172 | return -EINVAL; |
| 9173 | } |
| 9174 | |
| 9175 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9176 | status = wlan_hdd_validate_context(pHddCtx); |
| 9177 | |
| 9178 | if (0 != status) |
| 9179 | { |
| 9180 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9181 | "%s: HDD context is not valid", __func__); |
| 9182 | return status; |
| 9183 | } |
| 9184 | |
| 9185 | pVosContext = pHddCtx->pvosContext; |
| 9186 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 9187 | |
| 9188 | if (NULL == pHostapdState) |
| 9189 | { |
| 9190 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9191 | "%s: pHostapdState is Null", __func__); |
| 9192 | return -EINVAL; |
| 9193 | } |
| 9194 | |
| 9195 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d" |
| 9196 | "no acl entries = %d", params->acl_policy, params->n_acl_entries); |
| 9197 | |
| 9198 | if (WLAN_HDD_SOFTAP == pAdapter->device_mode) |
| 9199 | { |
| 9200 | pConfig = &pAdapter->sessionCtx.ap.sapConfig; |
| 9201 | |
| 9202 | /* default value */ |
| 9203 | pConfig->num_accept_mac = 0; |
| 9204 | pConfig->num_deny_mac = 0; |
| 9205 | |
| 9206 | /** |
| 9207 | * access control policy |
| 9208 | * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are |
| 9209 | * listed in hostapd.deny file. |
| 9210 | * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are |
| 9211 | * listed in hostapd.accept file. |
| 9212 | */ |
| 9213 | if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy) |
| 9214 | { |
| 9215 | pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED; |
| 9216 | } |
| 9217 | else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy) |
| 9218 | { |
| 9219 | pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED; |
| 9220 | } |
| 9221 | else |
| 9222 | { |
| 9223 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9224 | "%s:Acl Policy : %d is not supported", |
| 9225 | __func__, params->acl_policy); |
| 9226 | return -ENOTSUPP; |
| 9227 | } |
| 9228 | |
| 9229 | if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl) |
| 9230 | { |
| 9231 | pConfig->num_accept_mac = params->n_acl_entries; |
| 9232 | for (i = 0; i < params->n_acl_entries; i++) |
| 9233 | { |
| 9234 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9235 | "** Add ACL MAC entry %i in WhiletList :" |
| 9236 | MAC_ADDRESS_STR, i, |
| 9237 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 9238 | |
| 9239 | vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr, |
| 9240 | sizeof(qcmacaddr)); |
| 9241 | } |
| 9242 | } |
| 9243 | else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl) |
| 9244 | { |
| 9245 | pConfig->num_deny_mac = params->n_acl_entries; |
| 9246 | for (i = 0; i < params->n_acl_entries; i++) |
| 9247 | { |
| 9248 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9249 | "** Add ACL MAC entry %i in BlackList :" |
| 9250 | MAC_ADDRESS_STR, i, |
| 9251 | MAC_ADDR_ARRAY(params->mac_addrs[i].addr)); |
| 9252 | |
| 9253 | vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr, |
| 9254 | sizeof(qcmacaddr)); |
| 9255 | } |
| 9256 | } |
| 9257 | |
| 9258 | if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig)) |
| 9259 | { |
| 9260 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9261 | "%s: SAP Set Mac Acl fail", __func__); |
| 9262 | return -EINVAL; |
| 9263 | } |
| 9264 | } |
| 9265 | else |
| 9266 | { |
| 9267 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9268 | "%s: Invalid device_mode = %d", |
| 9269 | __func__, pAdapter->device_mode); |
| 9270 | return -EINVAL; |
| 9271 | } |
| 9272 | |
| 9273 | return 0; |
| 9274 | } |
| 9275 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9276 | #ifdef WLAN_NL80211_TESTMODE |
| 9277 | #ifdef FEATURE_WLAN_LPHB |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9278 | void wlan_hdd_cfg80211_lphb_ind_handler |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9279 | ( |
| 9280 | void *pAdapter, |
| 9281 | void *indCont |
| 9282 | ) |
| 9283 | { |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9284 | tSirLPHBInd *lphbInd; |
| 9285 | struct sk_buff *skb; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9286 | |
| 9287 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9288 | "LPHB indication arrived"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9289 | |
| 9290 | if (NULL == indCont) |
| 9291 | { |
| 9292 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9293 | "LPHB IND, invalid argument"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9294 | return; |
| 9295 | } |
| 9296 | |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9297 | lphbInd = (tSirLPHBInd *)indCont; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9298 | skb = cfg80211_testmode_alloc_event_skb( |
| 9299 | ((hdd_adapter_t *)pAdapter)->wdev.wiphy, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9300 | sizeof(tSirLPHBInd), |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9301 | GFP_ATOMIC); |
| 9302 | if (!skb) |
| 9303 | { |
| 9304 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9305 | "LPHB timeout, NL buffer alloc fail"); |
| 9306 | return; |
| 9307 | } |
| 9308 | |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 9309 | if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB)) |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9310 | { |
| 9311 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9312 | "WLAN_HDD_TM_ATTR_CMD put fail"); |
| 9313 | goto nla_put_failure; |
| 9314 | } |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 9315 | if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType)) |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9316 | { |
| 9317 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9318 | "WLAN_HDD_TM_ATTR_TYPE put fail"); |
| 9319 | goto nla_put_failure; |
| 9320 | } |
Leo Chang | ac3ba77 | 2013-10-07 09:47:04 -0700 | [diff] [blame] | 9321 | if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA, |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9322 | sizeof(tSirLPHBInd), lphbInd)) |
| 9323 | { |
| 9324 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9325 | "WLAN_HDD_TM_ATTR_DATA put fail"); |
| 9326 | goto nla_put_failure; |
| 9327 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9328 | cfg80211_testmode_event(skb, GFP_ATOMIC); |
| 9329 | return; |
| 9330 | |
| 9331 | nla_put_failure: |
| 9332 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9333 | "NLA Put fail"); |
| 9334 | kfree_skb(skb); |
| 9335 | |
| 9336 | return; |
| 9337 | } |
| 9338 | #endif /* FEATURE_WLAN_LPHB */ |
| 9339 | |
| 9340 | static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len) |
| 9341 | { |
| 9342 | struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1]; |
| 9343 | int err = 0; |
| 9344 | #ifdef FEATURE_WLAN_LPHB |
| 9345 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9346 | eHalStatus smeStatus; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9347 | #endif /* FEATURE_WLAN_LPHB */ |
| 9348 | |
| 9349 | err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy); |
| 9350 | if (err) |
| 9351 | { |
| 9352 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9353 | "%s Testmode INV ATTR", __func__); |
| 9354 | return err; |
| 9355 | } |
| 9356 | |
| 9357 | if (!tb[WLAN_HDD_TM_ATTR_CMD]) |
| 9358 | { |
| 9359 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9360 | "%s Testmode INV CMD", __func__); |
| 9361 | return -EINVAL; |
| 9362 | } |
| 9363 | |
| 9364 | switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD])) |
| 9365 | { |
| 9366 | #ifdef FEATURE_WLAN_LPHB |
| 9367 | /* Low Power Heartbeat configuration request */ |
| 9368 | case WLAN_HDD_TM_CMD_WLAN_HB: |
| 9369 | { |
| 9370 | int buf_len; |
| 9371 | void *buf; |
| 9372 | tSirLPHBReq *hb_params = NULL; |
Amar Singhal | 0585270 | 2014-02-04 14:40:00 -0800 | [diff] [blame] | 9373 | tSirLPHBReq *hb_params_temp = NULL; |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9374 | |
| 9375 | if (!tb[WLAN_HDD_TM_ATTR_DATA]) |
| 9376 | { |
| 9377 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9378 | "%s Testmode INV DATA", __func__); |
| 9379 | return -EINVAL; |
| 9380 | } |
| 9381 | |
| 9382 | buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]); |
| 9383 | buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]); |
Amar Singhal | 0585270 | 2014-02-04 14:40:00 -0800 | [diff] [blame] | 9384 | |
| 9385 | hb_params_temp =(tSirLPHBReq *)buf; |
| 9386 | if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) && |
| 9387 | (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0)) |
| 9388 | return -EINVAL; |
| 9389 | |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9390 | hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq)); |
| 9391 | if (NULL == hb_params) |
| 9392 | { |
| 9393 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9394 | "%s Request Buffer Alloc Fail", __func__); |
| 9395 | return -EINVAL; |
| 9396 | } |
| 9397 | |
| 9398 | vos_mem_copy(hb_params, buf, buf_len); |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9399 | smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal), |
| 9400 | hb_params, |
| 9401 | wlan_hdd_cfg80211_lphb_ind_handler); |
| 9402 | if (eHAL_STATUS_SUCCESS != smeStatus) |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9403 | { |
Leo Chang | d9df8aa | 2013-09-26 13:32:26 -0700 | [diff] [blame] | 9404 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9405 | "LPHB Config Fail, disable"); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9406 | vos_mem_free(hb_params); |
| 9407 | } |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9408 | return 0; |
| 9409 | } |
| 9410 | #endif /* FEATURE_WLAN_LPHB */ |
| 9411 | default: |
c_hpothu | 6ff1c3c | 2013-10-01 19:01:57 +0530 | [diff] [blame] | 9412 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9413 | "%s: unsupported event",__func__); |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9414 | return -EOPNOTSUPP; |
| 9415 | } |
| 9416 | |
| 9417 | return err; |
| 9418 | } |
| 9419 | #endif /* CONFIG_NL80211_TESTMODE */ |
| 9420 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9421 | static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy, |
| 9422 | struct net_device *dev, |
| 9423 | int idx, struct survey_info *survey) |
| 9424 | { |
| 9425 | hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 9426 | hdd_context_t *pHddCtx; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 9427 | hdd_station_ctx_t *pHddStaCtx; |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9428 | tHalHandle halHandle; |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 9429 | v_U32_t channel = 0, freq = 0; /* Initialization Required */ |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9430 | v_S7_t snr,rssi; |
| 9431 | int status, i, j, filled = 0; |
| 9432 | |
| 9433 | ENTER(); |
| 9434 | |
| 9435 | |
| 9436 | if (NULL == pAdapter) |
| 9437 | { |
| 9438 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9439 | "%s: HDD adapter is Null", __func__); |
| 9440 | return -ENODEV; |
| 9441 | } |
| 9442 | |
| 9443 | if (NULL == wiphy) |
| 9444 | { |
| 9445 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9446 | "%s: wiphy is Null", __func__); |
| 9447 | return -ENODEV; |
| 9448 | } |
| 9449 | |
| 9450 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 9451 | status = wlan_hdd_validate_context(pHddCtx); |
| 9452 | |
| 9453 | if (0 != status) |
| 9454 | { |
| 9455 | VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9456 | "%s: HDD context is not valid", __func__); |
| 9457 | return status; |
| 9458 | } |
| 9459 | |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 9460 | pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter); |
| 9461 | |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9462 | if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring || |
Mihir Shete | d9072e0 | 2013-08-21 17:02:29 +0530 | [diff] [blame] | 9463 | 0 != pAdapter->survey_idx || |
| 9464 | eConnectionState_Associated != pHddStaCtx->conn_info.connState) |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9465 | { |
| 9466 | /* The survey dump ops when implemented completely is expected to |
| 9467 | * return a survey of all channels and the ops is called by the |
| 9468 | * kernel with incremental values of the argument 'idx' till it |
| 9469 | * returns -ENONET. But we can only support the survey for the |
| 9470 | * operating channel for now. survey_idx is used to track |
| 9471 | * that the ops is called only once and then return -ENONET for |
| 9472 | * the next iteration |
| 9473 | */ |
| 9474 | pAdapter->survey_idx = 0; |
| 9475 | return -ENONET; |
| 9476 | } |
| 9477 | |
| 9478 | halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter); |
| 9479 | |
| 9480 | wlan_hdd_get_snr(pAdapter, &snr); |
| 9481 | wlan_hdd_get_rssi(pAdapter, &rssi); |
| 9482 | |
| 9483 | sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId); |
| 9484 | hdd_wlan_get_freq(channel, &freq); |
| 9485 | |
| 9486 | |
| 9487 | for (i = 0; i < IEEE80211_NUM_BANDS; i++) |
| 9488 | { |
| 9489 | if (NULL == wiphy->bands[i]) |
| 9490 | { |
| 9491 | VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO, |
| 9492 | "%s: wiphy->bands[i] is NULL, i = %d", __func__, i); |
| 9493 | continue; |
| 9494 | } |
| 9495 | |
| 9496 | for (j = 0; j < wiphy->bands[i]->n_channels; j++) |
| 9497 | { |
| 9498 | struct ieee80211_supported_band *band = wiphy->bands[i]; |
| 9499 | |
| 9500 | if (band->channels[j].center_freq == (v_U16_t)freq) |
| 9501 | { |
| 9502 | survey->channel = &band->channels[j]; |
| 9503 | /* The Rx BDs contain SNR values in dB for the received frames |
| 9504 | * while the supplicant expects noise. So we calculate and |
| 9505 | * return the value of noise (dBm) |
| 9506 | * SNR (dB) = RSSI (dBm) - NOISE (dBm) |
| 9507 | */ |
| 9508 | survey->noise = rssi - snr; |
| 9509 | survey->filled = SURVEY_INFO_NOISE_DBM; |
| 9510 | filled = 1; |
| 9511 | } |
| 9512 | } |
| 9513 | } |
| 9514 | |
| 9515 | if (filled) |
| 9516 | pAdapter->survey_idx = 1; |
| 9517 | else |
| 9518 | { |
| 9519 | pAdapter->survey_idx = 0; |
| 9520 | return -ENONET; |
| 9521 | } |
| 9522 | |
| 9523 | return 0; |
| 9524 | } |
| 9525 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9526 | /* |
| 9527 | * FUNCTION: wlan_hdd_cfg80211_resume_wlan |
| 9528 | * this is called when cfg80211 driver resume |
| 9529 | * driver updates latest sched_scan scan result(if any) to cfg80211 database |
| 9530 | */ |
| 9531 | int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy) |
| 9532 | { |
| 9533 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 9534 | hdd_adapter_t *pAdapter; |
| 9535 | hdd_adapter_list_node_t *pAdapterNode, *pNext; |
| 9536 | VOS_STATUS status = VOS_STATUS_SUCCESS; |
| 9537 | |
| 9538 | ENTER(); |
| 9539 | |
| 9540 | if ( NULL == pHddCtx ) |
| 9541 | { |
| 9542 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9543 | "%s: HddCtx validation failed", __func__); |
| 9544 | return 0; |
| 9545 | } |
| 9546 | |
| 9547 | if (pHddCtx->isLogpInProgress) |
| 9548 | { |
| 9549 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9550 | "%s: LOGP in Progress. Ignore!!!", __func__); |
| 9551 | return 0; |
| 9552 | } |
| 9553 | |
| 9554 | if (pHddCtx->isLoadUnloadInProgress) |
| 9555 | { |
| 9556 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
| 9557 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 9558 | return 0; |
| 9559 | } |
| 9560 | |
| 9561 | spin_lock(&pHddCtx->schedScan_lock); |
| 9562 | pHddCtx->isWiphySuspended = FALSE; |
| 9563 | if (TRUE != pHddCtx->isSchedScanUpdatePending) |
| 9564 | { |
| 9565 | spin_unlock(&pHddCtx->schedScan_lock); |
| 9566 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9567 | "%s: Return resume is not due to PNO indication", __func__); |
| 9568 | return 0; |
| 9569 | } |
| 9570 | // Reset flag to avoid updatating cfg80211 data old results again |
| 9571 | pHddCtx->isSchedScanUpdatePending = FALSE; |
| 9572 | spin_unlock(&pHddCtx->schedScan_lock); |
| 9573 | |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9574 | |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9575 | status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode ); |
| 9576 | |
| 9577 | while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status ) |
| 9578 | { |
| 9579 | pAdapter = pAdapterNode->pAdapter; |
| 9580 | if ( (NULL != pAdapter) && |
| 9581 | (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ) |
| 9582 | { |
| 9583 | if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter)) |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9584 | { |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9585 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN, |
| 9586 | "%s: NO SCAN result", __func__); |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9587 | } |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9588 | else |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9589 | { |
| 9590 | /* Acquire wakelock to handle the case where APP's tries to |
| 9591 | * suspend immediately after updating the scan results. Whis |
| 9592 | * results in app's is in suspended state and not able to |
| 9593 | * process the connect request to AP |
| 9594 | */ |
| 9595 | hdd_prevent_suspend_timeout(2000); |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9596 | cfg80211_sched_scan_results(pHddCtx->wiphy); |
Mahesh A Saptasagar | b9c5040 | 2014-01-16 15:49:22 +0530 | [diff] [blame] | 9597 | } |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9598 | |
| 9599 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9600 | "%s : cfg80211 scan result database updated", __func__); |
| 9601 | |
| 9602 | return 0; |
| 9603 | |
| 9604 | } |
| 9605 | status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext ); |
| 9606 | pAdapterNode = pNext; |
| 9607 | } |
| 9608 | |
| 9609 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 9610 | "%s: Failed to find Adapter", __func__); |
| 9611 | return 0; |
| 9612 | } |
| 9613 | |
| 9614 | /* |
| 9615 | * FUNCTION: wlan_hdd_cfg80211_suspend_wlan |
| 9616 | * this is called when cfg80211 driver suspends |
| 9617 | */ |
| 9618 | int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy, |
| 9619 | struct cfg80211_wowlan *wow) |
| 9620 | { |
| 9621 | hdd_context_t *pHddCtx = wiphy_priv(wiphy); |
| 9622 | |
| 9623 | ENTER(); |
| 9624 | if (NULL == pHddCtx) |
| 9625 | { |
| 9626 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, |
| 9627 | "%s: HddCtx validation failed", __func__); |
| 9628 | return 0; |
| 9629 | } |
| 9630 | |
| 9631 | pHddCtx->isWiphySuspended = TRUE; |
| 9632 | |
| 9633 | EXIT(); |
| 9634 | |
| 9635 | return 0; |
| 9636 | } |
| 9637 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9638 | /* cfg80211_ops */ |
Gopichand Nakkala | 747461f | 2013-04-24 19:24:45 +0530 | [diff] [blame] | 9639 | static struct cfg80211_ops wlan_hdd_cfg80211_ops = |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9640 | { |
| 9641 | .add_virtual_intf = wlan_hdd_add_virtual_intf, |
| 9642 | .del_virtual_intf = wlan_hdd_del_virtual_intf, |
| 9643 | .change_virtual_intf = wlan_hdd_cfg80211_change_iface, |
| 9644 | .change_station = wlan_hdd_change_station, |
| 9645 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 9646 | .add_beacon = wlan_hdd_cfg80211_add_beacon, |
| 9647 | .del_beacon = wlan_hdd_cfg80211_del_beacon, |
| 9648 | .set_beacon = wlan_hdd_cfg80211_set_beacon, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9649 | #else |
| 9650 | .start_ap = wlan_hdd_cfg80211_start_ap, |
| 9651 | .change_beacon = wlan_hdd_cfg80211_change_beacon, |
| 9652 | .stop_ap = wlan_hdd_cfg80211_stop_ap, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9653 | #endif |
| 9654 | .change_bss = wlan_hdd_cfg80211_change_bss, |
| 9655 | .add_key = wlan_hdd_cfg80211_add_key, |
| 9656 | .get_key = wlan_hdd_cfg80211_get_key, |
| 9657 | .del_key = wlan_hdd_cfg80211_del_key, |
| 9658 | .set_default_key = wlan_hdd_cfg80211_set_default_key, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 9659 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9660 | .set_channel = wlan_hdd_cfg80211_set_channel, |
Jeff Johnson | 3bbe4bf | 2013-01-18 17:05:29 -0800 | [diff] [blame] | 9661 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9662 | .scan = wlan_hdd_cfg80211_scan, |
| 9663 | .connect = wlan_hdd_cfg80211_connect, |
| 9664 | .disconnect = wlan_hdd_cfg80211_disconnect, |
| 9665 | .join_ibss = wlan_hdd_cfg80211_join_ibss, |
| 9666 | .leave_ibss = wlan_hdd_cfg80211_leave_ibss, |
| 9667 | .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params, |
| 9668 | .set_tx_power = wlan_hdd_cfg80211_set_txpower, |
| 9669 | .get_tx_power = wlan_hdd_cfg80211_get_txpower, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9670 | .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel, |
| 9671 | .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel, |
| 9672 | .mgmt_tx = wlan_hdd_action, |
| 9673 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
| 9674 | .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait, |
| 9675 | .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key, |
| 9676 | .set_txq_params = wlan_hdd_set_txq_params, |
| 9677 | #endif |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9678 | .get_station = wlan_hdd_cfg80211_get_station, |
| 9679 | .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt, |
| 9680 | .del_station = wlan_hdd_cfg80211_del_station, |
Jeff Johnson | 04dd8a8 | 2012-06-29 20:41:40 -0700 | [diff] [blame] | 9681 | .add_station = wlan_hdd_cfg80211_add_station, |
| 9682 | #ifdef FEATURE_WLAN_LFR |
| 9683 | .set_pmksa = wlan_hdd_cfg80211_set_pmksa, |
| 9684 | .del_pmksa = wlan_hdd_cfg80211_del_pmksa, |
| 9685 | .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa, |
| 9686 | #endif |
Madan Mohan Koyyalamudi | ea77388 | 2012-11-02 13:37:21 -0700 | [diff] [blame] | 9687 | #if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211) |
| 9688 | .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies, |
| 9689 | #endif |
Mohit Khanna | 698ba2a | 2012-12-04 15:08:18 -0800 | [diff] [blame] | 9690 | #ifdef FEATURE_WLAN_TDLS |
| 9691 | .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt, |
| 9692 | .tdls_oper = wlan_hdd_cfg80211_tdls_oper, |
| 9693 | #endif |
Gopichand Nakkala | 870cbae | 2013-03-15 21:16:09 +0530 | [diff] [blame] | 9694 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 9695 | .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data, |
| 9696 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
Gopichand Nakkala | 8e93fde | 2013-05-10 17:40:12 +0530 | [diff] [blame] | 9697 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 9698 | .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start, |
| 9699 | .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop, |
| 9700 | #endif /*FEATURE_WLAN_SCAN_PNO */ |
Kamath Vinayak | 4000c9a | 2013-08-23 14:24:27 +0530 | [diff] [blame] | 9701 | .resume = wlan_hdd_cfg80211_resume_wlan, |
| 9702 | .suspend = wlan_hdd_cfg80211_suspend_wlan, |
Gopichand Nakkala | c005b7c | 2013-05-14 16:04:14 +0530 | [diff] [blame] | 9703 | .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl, |
Leo Chang | 9056f46 | 2013-08-01 19:21:11 -0700 | [diff] [blame] | 9704 | #ifdef WLAN_NL80211_TESTMODE |
| 9705 | .testmode_cmd = wlan_hdd_cfg80211_testmode, |
| 9706 | #endif |
Madan Mohan Koyyalamudi | d9383fd | 2013-08-13 09:27:30 +0530 | [diff] [blame] | 9707 | .dump_survey = wlan_hdd_cfg80211_dump_survey, |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 9708 | }; |
| 9709 | |