blob: 30a2c708c4ad218b8df8585c800af16c476016a9 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam842dad02014-02-18 18:44:02 -080026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/**========================================================================
31
32 \file wlan_hdd_cfg80211.c
33
34 \brief WLAN Host Device Driver implementation
35
Jeff Johnson295189b2012-06-20 16:38:30 -070036 ========================================================================*/
37
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070038/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070039
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070043 This section contains comments describing changes made to the module.
44 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070045
46
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070047 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070048
49
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070050 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070051 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070053
54 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070055 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070056 ==========================================================================*/
57
Jeff Johnson295189b2012-06-20 16:38:30 -070058
59#include <linux/version.h>
60#include <linux/module.h>
61#include <linux/kernel.h>
62#include <linux/init.h>
63#include <linux/wireless.h>
64#include <wlan_hdd_includes.h>
65#include <net/arp.h>
66#include <net/cfg80211.h>
67#include <linux/wireless.h>
68#include <wlan_hdd_wowl.h>
69#include <aniGlobal.h>
70#include "ccmApi.h"
71#include "sirParams.h"
72#include "dot11f.h"
73#include "wlan_hdd_assoc.h"
74#include "wlan_hdd_wext.h"
75#include "sme_Api.h"
76#include "wlan_hdd_p2p.h"
77#include "wlan_hdd_cfg80211.h"
78#include "wlan_hdd_hostapd.h"
79#include "sapInternal.h"
80#include "wlan_hdd_softap_tx_rx.h"
81#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053082#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053083#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053084#include "wlan_hdd_trace.h"
85#include "vos_types.h"
86#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070087#ifdef WLAN_BTAMP_FEATURE
88#include "bap_hdd_misc.h"
89#endif
90#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080091#ifdef FEATURE_WLAN_TDLS
92#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053093#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053094#include "wlan_qct_wda.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080095#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Lee Hoonkic1262f22013-01-24 21:59:00 -0800133#ifndef WLAN_FEATURE_TDLS_DEBUG
134#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
135#else
136#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
137#endif
138
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530139#ifdef WLAN_FEATURE_VOWIFI_11R
140#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
141#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
142#endif
143
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530144#define HDD_CHANNEL_14 14
145
Sunil Duttc69bccb2014-05-26 21:30:20 +0530146#ifdef WLAN_FEATURE_LINK_LAYER_STATS
147/*
148 * Used to allocate the size of 4096 for the link layer stats.
149 * The size of 4096 is considered assuming that all data per
150 * respective event fit with in the limit.Please take a call
151 * on the limit based on the data requirements on link layer
152 * statistics.
153 */
154#define LL_STATS_EVENT_BUF_SIZE 4096
155#endif
156
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530157static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700158{
159 WLAN_CIPHER_SUITE_WEP40,
160 WLAN_CIPHER_SUITE_WEP104,
161 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800162#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700163#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
164 WLAN_CIPHER_SUITE_KRK,
165 WLAN_CIPHER_SUITE_CCMP,
166#else
167 WLAN_CIPHER_SUITE_CCMP,
168#endif
169#ifdef FEATURE_WLAN_WAPI
170 WLAN_CIPHER_SUITE_SMS4,
171#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700172#ifdef WLAN_FEATURE_11W
173 WLAN_CIPHER_SUITE_AES_CMAC,
174#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700175};
176
177static inline int is_broadcast_ether_addr(const u8 *addr)
178{
179 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
180 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
181}
182
183static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530184{
Jeff Johnson295189b2012-06-20 16:38:30 -0700185 HDD2GHZCHAN(2412, 1, 0) ,
186 HDD2GHZCHAN(2417, 2, 0) ,
187 HDD2GHZCHAN(2422, 3, 0) ,
188 HDD2GHZCHAN(2427, 4, 0) ,
189 HDD2GHZCHAN(2432, 5, 0) ,
190 HDD2GHZCHAN(2437, 6, 0) ,
191 HDD2GHZCHAN(2442, 7, 0) ,
192 HDD2GHZCHAN(2447, 8, 0) ,
193 HDD2GHZCHAN(2452, 9, 0) ,
194 HDD2GHZCHAN(2457, 10, 0) ,
195 HDD2GHZCHAN(2462, 11, 0) ,
196 HDD2GHZCHAN(2467, 12, 0) ,
197 HDD2GHZCHAN(2472, 13, 0) ,
198 HDD2GHZCHAN(2484, 14, 0) ,
199};
200
Jeff Johnson295189b2012-06-20 16:38:30 -0700201static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
202{
203 HDD2GHZCHAN(2412, 1, 0) ,
204 HDD2GHZCHAN(2437, 6, 0) ,
205 HDD2GHZCHAN(2462, 11, 0) ,
206};
Jeff Johnson295189b2012-06-20 16:38:30 -0700207
208static struct ieee80211_channel hdd_channels_5_GHZ[] =
209{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700210 HDD5GHZCHAN(4920, 240, 0) ,
211 HDD5GHZCHAN(4940, 244, 0) ,
212 HDD5GHZCHAN(4960, 248, 0) ,
213 HDD5GHZCHAN(4980, 252, 0) ,
214 HDD5GHZCHAN(5040, 208, 0) ,
215 HDD5GHZCHAN(5060, 212, 0) ,
216 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 HDD5GHZCHAN(5180, 36, 0) ,
218 HDD5GHZCHAN(5200, 40, 0) ,
219 HDD5GHZCHAN(5220, 44, 0) ,
220 HDD5GHZCHAN(5240, 48, 0) ,
221 HDD5GHZCHAN(5260, 52, 0) ,
222 HDD5GHZCHAN(5280, 56, 0) ,
223 HDD5GHZCHAN(5300, 60, 0) ,
224 HDD5GHZCHAN(5320, 64, 0) ,
225 HDD5GHZCHAN(5500,100, 0) ,
226 HDD5GHZCHAN(5520,104, 0) ,
227 HDD5GHZCHAN(5540,108, 0) ,
228 HDD5GHZCHAN(5560,112, 0) ,
229 HDD5GHZCHAN(5580,116, 0) ,
230 HDD5GHZCHAN(5600,120, 0) ,
231 HDD5GHZCHAN(5620,124, 0) ,
232 HDD5GHZCHAN(5640,128, 0) ,
233 HDD5GHZCHAN(5660,132, 0) ,
234 HDD5GHZCHAN(5680,136, 0) ,
235 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800236#ifdef FEATURE_WLAN_CH144
237 HDD5GHZCHAN(5720,144, 0) ,
238#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 HDD5GHZCHAN(5745,149, 0) ,
240 HDD5GHZCHAN(5765,153, 0) ,
241 HDD5GHZCHAN(5785,157, 0) ,
242 HDD5GHZCHAN(5805,161, 0) ,
243 HDD5GHZCHAN(5825,165, 0) ,
244};
245
246static struct ieee80211_rate g_mode_rates[] =
247{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530248 HDD_G_MODE_RATETAB(10, 0x1, 0),
249 HDD_G_MODE_RATETAB(20, 0x2, 0),
250 HDD_G_MODE_RATETAB(55, 0x4, 0),
251 HDD_G_MODE_RATETAB(110, 0x8, 0),
252 HDD_G_MODE_RATETAB(60, 0x10, 0),
253 HDD_G_MODE_RATETAB(90, 0x20, 0),
254 HDD_G_MODE_RATETAB(120, 0x40, 0),
255 HDD_G_MODE_RATETAB(180, 0x80, 0),
256 HDD_G_MODE_RATETAB(240, 0x100, 0),
257 HDD_G_MODE_RATETAB(360, 0x200, 0),
258 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700259 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530260};
Jeff Johnson295189b2012-06-20 16:38:30 -0700261
262static struct ieee80211_rate a_mode_rates[] =
263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530264 HDD_G_MODE_RATETAB(60, 0x10, 0),
265 HDD_G_MODE_RATETAB(90, 0x20, 0),
266 HDD_G_MODE_RATETAB(120, 0x40, 0),
267 HDD_G_MODE_RATETAB(180, 0x80, 0),
268 HDD_G_MODE_RATETAB(240, 0x100, 0),
269 HDD_G_MODE_RATETAB(360, 0x200, 0),
270 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 HDD_G_MODE_RATETAB(540, 0x800, 0),
272};
273
274static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
275{
276 .channels = hdd_channels_2_4_GHZ,
277 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
278 .band = IEEE80211_BAND_2GHZ,
279 .bitrates = g_mode_rates,
280 .n_bitrates = g_mode_rates_size,
281 .ht_cap.ht_supported = 1,
282 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
283 | IEEE80211_HT_CAP_GRN_FLD
284 | IEEE80211_HT_CAP_DSSSCCK40
285 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
286 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
287 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
288 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
289 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
290 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
291};
292
Jeff Johnson295189b2012-06-20 16:38:30 -0700293static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
294{
295 .channels = hdd_social_channels_2_4_GHZ,
296 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
297 .band = IEEE80211_BAND_2GHZ,
298 .bitrates = g_mode_rates,
299 .n_bitrates = g_mode_rates_size,
300 .ht_cap.ht_supported = 1,
301 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
302 | IEEE80211_HT_CAP_GRN_FLD
303 | IEEE80211_HT_CAP_DSSSCCK40
304 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
305 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
306 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
307 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
308 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
309 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
310};
Jeff Johnson295189b2012-06-20 16:38:30 -0700311
312static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
313{
314 .channels = hdd_channels_5_GHZ,
315 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
316 .band = IEEE80211_BAND_5GHZ,
317 .bitrates = a_mode_rates,
318 .n_bitrates = a_mode_rates_size,
319 .ht_cap.ht_supported = 1,
320 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
321 | IEEE80211_HT_CAP_GRN_FLD
322 | IEEE80211_HT_CAP_DSSSCCK40
323 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
324 | IEEE80211_HT_CAP_SGI_40
325 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
326 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
327 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
328 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
329 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
330 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
331};
332
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530333/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 TX/RX direction for each kind of interface */
335static const struct ieee80211_txrx_stypes
336wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
337 [NL80211_IFTYPE_STATION] = {
338 .tx = 0xffff,
339 .rx = BIT(SIR_MAC_MGMT_ACTION) |
340 BIT(SIR_MAC_MGMT_PROBE_REQ),
341 },
342 [NL80211_IFTYPE_AP] = {
343 .tx = 0xffff,
344 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
345 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
346 BIT(SIR_MAC_MGMT_PROBE_REQ) |
347 BIT(SIR_MAC_MGMT_DISASSOC) |
348 BIT(SIR_MAC_MGMT_AUTH) |
349 BIT(SIR_MAC_MGMT_DEAUTH) |
350 BIT(SIR_MAC_MGMT_ACTION),
351 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700352 [NL80211_IFTYPE_ADHOC] = {
353 .tx = 0xffff,
354 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
355 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
356 BIT(SIR_MAC_MGMT_PROBE_REQ) |
357 BIT(SIR_MAC_MGMT_DISASSOC) |
358 BIT(SIR_MAC_MGMT_AUTH) |
359 BIT(SIR_MAC_MGMT_DEAUTH) |
360 BIT(SIR_MAC_MGMT_ACTION),
361 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700362 [NL80211_IFTYPE_P2P_CLIENT] = {
363 .tx = 0xffff,
364 .rx = BIT(SIR_MAC_MGMT_ACTION) |
365 BIT(SIR_MAC_MGMT_PROBE_REQ),
366 },
367 [NL80211_IFTYPE_P2P_GO] = {
368 /* This is also same as for SoftAP */
369 .tx = 0xffff,
370 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
371 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
372 BIT(SIR_MAC_MGMT_PROBE_REQ) |
373 BIT(SIR_MAC_MGMT_DISASSOC) |
374 BIT(SIR_MAC_MGMT_AUTH) |
375 BIT(SIR_MAC_MGMT_DEAUTH) |
376 BIT(SIR_MAC_MGMT_ACTION),
377 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700378};
379
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800380#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800381static const struct ieee80211_iface_limit
382wlan_hdd_iface_limit[] = {
383 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800384 /* max = 3 ; Our driver create two interfaces during driver init
385 * wlan0 and p2p0 interfaces. p2p0 is considered as station
386 * interface until a group is formed. In JB architecture, once the
387 * group is formed, interface type of p2p0 is changed to P2P GO or
388 * Client.
389 * When supplicant remove the group, it first issue a set interface
390 * cmd to change the mode back to Station. In JB this works fine as
391 * we advertize two station type interface during driver init.
392 * Some vendors create separate interface for P2P GO/Client,
393 * after group formation(Third one). But while group remove
394 * supplicant first tries to change the mode(3rd interface) to STATION
395 * But as we advertized only two sta type interfaces nl80211 was
396 * returning error for the third one which was leading to failure in
397 * delete interface. Ideally while removing the group, supplicant
398 * should not try to change the 3rd interface mode to Station type.
399 * Till we get a fix in wpa_supplicant, we advertize max STA
400 * interface type to 3
401 */
402 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800403 .types = BIT(NL80211_IFTYPE_STATION),
404 },
405 {
406 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700407 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800408 },
409 {
410 .max = 1,
411 .types = BIT(NL80211_IFTYPE_P2P_GO) |
412 BIT(NL80211_IFTYPE_P2P_CLIENT),
413 },
414};
415
416/* By default, only single channel concurrency is allowed */
417static struct ieee80211_iface_combination
418wlan_hdd_iface_combination = {
419 .limits = wlan_hdd_iface_limit,
420 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800421 /*
422 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
423 * and p2p0 interfaces during driver init
424 * Some vendors create separate interface for P2P operations.
425 * wlan0: STA interface
426 * p2p0: P2P Device interface, action frames goes
427 * through this interface.
428 * p2p-xx: P2P interface, After GO negotiation this interface is
429 * created for p2p operations(GO/CLIENT interface).
430 */
431 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800432 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
433 .beacon_int_infra_match = false,
434};
435#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800436
Jeff Johnson295189b2012-06-20 16:38:30 -0700437static struct cfg80211_ops wlan_hdd_cfg80211_ops;
438
439/* Data rate 100KBPS based on IE Index */
440struct index_data_rate_type
441{
442 v_U8_t beacon_rate_index;
443 v_U16_t supported_rate[4];
444};
445
446/* 11B, 11G Rate table include Basic rate and Extended rate
447 The IDX field is the rate index
448 The HI field is the rate when RSSI is strong or being ignored
449 (in this case we report actual rate)
450 The MID field is the rate when RSSI is moderate
451 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
452 The LO field is the rate when RSSI is low
453 (in this case we don't report rates, actual current rate used)
454 */
455static const struct
456{
457 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700458 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700459} supported_data_rate[] =
460{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700461/* IDX HI HM LM LO (RSSI-based index */
462 {2, { 10, 10, 10, 0}},
463 {4, { 20, 20, 10, 0}},
464 {11, { 55, 20, 10, 0}},
465 {12, { 60, 55, 20, 0}},
466 {18, { 90, 55, 20, 0}},
467 {22, {110, 55, 20, 0}},
468 {24, {120, 90, 60, 0}},
469 {36, {180, 120, 60, 0}},
470 {44, {220, 180, 60, 0}},
471 {48, {240, 180, 90, 0}},
472 {66, {330, 180, 90, 0}},
473 {72, {360, 240, 90, 0}},
474 {96, {480, 240, 120, 0}},
475 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700476};
477
478/* MCS Based rate table */
479static struct index_data_rate_type supported_mcs_rate[] =
480{
481/* MCS L20 L40 S20 S40 */
482 {0, {65, 135, 72, 150}},
483 {1, {130, 270, 144, 300}},
484 {2, {195, 405, 217, 450}},
485 {3, {260, 540, 289, 600}},
486 {4, {390, 810, 433, 900}},
487 {5, {520, 1080, 578, 1200}},
488 {6, {585, 1215, 650, 1350}},
489 {7, {650, 1350, 722, 1500}}
490};
491
Leo Chang6f8870f2013-03-26 18:11:36 -0700492#ifdef WLAN_FEATURE_11AC
493
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530494#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700495
496struct index_vht_data_rate_type
497{
498 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530499 v_U16_t supported_VHT80_rate[2];
500 v_U16_t supported_VHT40_rate[2];
501 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700502};
503
504typedef enum
505{
506 DATA_RATE_11AC_MAX_MCS_7,
507 DATA_RATE_11AC_MAX_MCS_8,
508 DATA_RATE_11AC_MAX_MCS_9,
509 DATA_RATE_11AC_MAX_MCS_NA
510} eDataRate11ACMaxMcs;
511
512/* MCS Based VHT rate table */
513static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
514{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530515/* MCS L80 S80 L40 S40 L20 S40*/
516 {0, {293, 325}, {135, 150}, {65, 72}},
517 {1, {585, 650}, {270, 300}, {130, 144}},
518 {2, {878, 975}, {405, 450}, {195, 217}},
519 {3, {1170, 1300}, {540, 600}, {260, 289}},
520 {4, {1755, 1950}, {810, 900}, {390, 433}},
521 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
522 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
523 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
524 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
525 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700526};
527#endif /* WLAN_FEATURE_11AC */
528
Jeff Johnson295189b2012-06-20 16:38:30 -0700529extern struct net_device_ops net_ops_struct;
530
Leo Chang9056f462013-08-01 19:21:11 -0700531#ifdef WLAN_NL80211_TESTMODE
532enum wlan_hdd_tm_attr
533{
534 WLAN_HDD_TM_ATTR_INVALID = 0,
535 WLAN_HDD_TM_ATTR_CMD = 1,
536 WLAN_HDD_TM_ATTR_DATA = 2,
537 WLAN_HDD_TM_ATTR_TYPE = 3,
538 /* keep last */
539 WLAN_HDD_TM_ATTR_AFTER_LAST,
540 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
541};
542
543enum wlan_hdd_tm_cmd
544{
545 WLAN_HDD_TM_CMD_WLAN_HB = 1,
546};
547
548#define WLAN_HDD_TM_DATA_MAX_LEN 5000
549
550static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
551{
552 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
553 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
554 .len = WLAN_HDD_TM_DATA_MAX_LEN },
555};
556#endif /* WLAN_NL80211_TESTMODE */
557
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800558#ifdef FEATURE_WLAN_CH_AVOID
559/*
560 * FUNCTION: wlan_hdd_send_avoid_freq_event
561 * This is called when wlan driver needs to send vendor specific
562 * avoid frequency range event to userspace
563 */
564int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
565 tHddAvoidFreqList *pAvoidFreqList)
566{
567 struct sk_buff *vendor_event;
568
569 ENTER();
570
571 if (!pHddCtx)
572 {
573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
574 "%s: HDD context is null", __func__);
575 return -1;
576 }
577
578 if (!pAvoidFreqList)
579 {
580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
581 "%s: pAvoidFreqList is null", __func__);
582 return -1;
583 }
584
585 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
586 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530587 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800588 GFP_KERNEL);
589 if (!vendor_event)
590 {
591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
592 "%s: cfg80211_vendor_event_alloc failed", __func__);
593 return -1;
594 }
595
596 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
597 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
598
599 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
600
601 EXIT();
602 return 0;
603}
604#endif /* FEATURE_WLAN_CH_AVOID */
605
Sunil Duttc69bccb2014-05-26 21:30:20 +0530606#ifdef WLAN_FEATURE_LINK_LAYER_STATS
607
608static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
609 struct sk_buff *vendor_event)
610{
611 if (nla_put_u8(vendor_event,
612 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
613 stats->rate.preamble) ||
614 nla_put_u8(vendor_event,
615 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
616 stats->rate.nss) ||
617 nla_put_u8(vendor_event,
618 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
619 stats->rate.bw) ||
620 nla_put_u8(vendor_event,
621 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
622 stats->rate.rateMcsIdx) ||
623 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
624 stats->rate.bitrate ) ||
625 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
626 stats->txMpdu ) ||
627 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
628 stats->rxMpdu ) ||
629 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
630 stats->mpduLost ) ||
631 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
632 stats->retries) ||
633 nla_put_u32(vendor_event,
634 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
635 stats->retriesShort ) ||
636 nla_put_u32(vendor_event,
637 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
638 stats->retriesLong))
639 {
640 hddLog(VOS_TRACE_LEVEL_ERROR,
641 FL("QCA_WLAN_VENDOR_ATTR put fail"));
642 return FALSE;
643 }
644 return TRUE;
645}
646
647static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
648 struct sk_buff *vendor_event)
649{
650 u32 i = 0;
651 struct nlattr *rateInfo;
652 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
653 stats->type) ||
654 nla_put(vendor_event,
655 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
656 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
657 nla_put_u32(vendor_event,
658 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
659 stats->capabilities) ||
660 nla_put_u32(vendor_event,
661 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
662 stats->numRate))
663 {
664 hddLog(VOS_TRACE_LEVEL_ERROR,
665 FL("QCA_WLAN_VENDOR_ATTR put fail"));
666 goto error;
667 }
668
669 rateInfo = nla_nest_start(vendor_event,
670 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
671 for (i = 0; i < stats->numRate; i++)
672 {
673 struct nlattr *rates;
674 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
675 stats->rateStats +
676 (i * sizeof(tSirWifiRateStat)));
677 rates = nla_nest_start(vendor_event, i);
678
679 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
680 {
681 hddLog(VOS_TRACE_LEVEL_ERROR,
682 FL("QCA_WLAN_VENDOR_ATTR put fail"));
683 return FALSE;
684 }
685 nla_nest_end(vendor_event, rates);
686 }
687 nla_nest_end(vendor_event, rateInfo);
688
689 return TRUE;
690error:
691 return FALSE;
692}
693
694static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
695 struct sk_buff *vendor_event)
696{
697 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
698 stats->ac ) ||
699 nla_put_u32(vendor_event,
700 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
701 stats->txMpdu ) ||
702 nla_put_u32(vendor_event,
703 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
704 stats->rxMpdu ) ||
705 nla_put_u32(vendor_event,
706 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
707 stats->txMcast ) ||
708 nla_put_u32(vendor_event,
709 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
710 stats->rxMcast ) ||
711 nla_put_u32(vendor_event,
712 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
713 stats->rxAmpdu ) ||
714 nla_put_u32(vendor_event,
715 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
716 stats->txAmpdu ) ||
717 nla_put_u32(vendor_event,
718 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
719 stats->mpduLost )||
720 nla_put_u32(vendor_event,
721 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
722 stats->retries ) ||
723 nla_put_u32(vendor_event,
724 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
725 stats->retriesShort ) ||
726 nla_put_u32(vendor_event,
727 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
728 stats->retriesLong ) ||
729 nla_put_u32(vendor_event,
730 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
731 stats->contentionTimeMin ) ||
732 nla_put_u32(vendor_event,
733 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
734 stats->contentionTimeMax ) ||
735 nla_put_u32(vendor_event,
736 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
737 stats->contentionTimeAvg ) ||
738 nla_put_u32(vendor_event,
739 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
740 stats->contentionNumSamples ))
741 {
742 hddLog(VOS_TRACE_LEVEL_ERROR,
743 FL("QCA_WLAN_VENDOR_ATTR put fail") );
744 return FALSE;
745 }
746 return TRUE;
747}
748
749static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
750 struct sk_buff *vendor_event)
751{
752 if (nla_put_u32(vendor_event,
753 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
754 nla_put(vendor_event,
755 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
756 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
757 nla_put_u32(vendor_event,
758 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
759 stats->state ) ||
760 nla_put_u32(vendor_event,
761 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
762 stats->roaming ) ||
763 nla_put_u32(vendor_event,
764 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
765 stats->capabilities ) ||
766 nla_put(vendor_event,
767 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
768 strlen(stats->ssid), stats->ssid) ||
769 nla_put(vendor_event,
770 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
771 WNI_CFG_BSSID_LEN, stats->bssid) ||
772 nla_put(vendor_event,
773 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
774 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
775 nla_put(vendor_event,
776 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
777 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
778 )
779 {
780 hddLog(VOS_TRACE_LEVEL_ERROR,
781 FL("QCA_WLAN_VENDOR_ATTR put fail") );
782 return FALSE;
783 }
784 return TRUE;
785}
786
787static v_BOOL_t put_wifi_iface_stats(tpSirWifiIfaceStat pWifiIfaceStat,
788 struct sk_buff *vendor_event)
789{
790 int i = 0;
791 struct nlattr *wmmInfo;
792 if (FALSE == put_wifi_interface_info(
793 &pWifiIfaceStat->info,
794 vendor_event))
795 {
796 hddLog(VOS_TRACE_LEVEL_ERROR,
797 FL("QCA_WLAN_VENDOR_ATTR put fail") );
798 return FALSE;
799
800 }
801
802 if (nla_put_u32(vendor_event,
803 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
804 pWifiIfaceStat->beaconRx) ||
805 nla_put_u32(vendor_event,
806 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
807 pWifiIfaceStat->mgmtRx) ||
808 nla_put_u32(vendor_event,
809 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
810 pWifiIfaceStat->mgmtActionRx) ||
811 nla_put_u32(vendor_event,
812 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
813 pWifiIfaceStat->mgmtActionTx) ||
814 nla_put_u32(vendor_event,
815 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
816 pWifiIfaceStat->rssiMgmt) ||
817 nla_put_u32(vendor_event,
818 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
819 pWifiIfaceStat->rssiData) ||
820 nla_put_u32(vendor_event,
821 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
822 pWifiIfaceStat->rssiAck))
823 {
824 hddLog(VOS_TRACE_LEVEL_ERROR,
825 FL("QCA_WLAN_VENDOR_ATTR put fail"));
826 return FALSE;
827 }
828
829 wmmInfo = nla_nest_start(vendor_event,
830 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
831 for (i = 0; i < WIFI_AC_MAX; i++)
832 {
833 struct nlattr *wmmStats;
834 wmmStats = nla_nest_start(vendor_event, i);
835 if (FALSE == put_wifi_wmm_ac_stat(
836 &pWifiIfaceStat->AccessclassStats[i],
837 vendor_event))
838 {
839 hddLog(VOS_TRACE_LEVEL_ERROR,
840 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
841 return FALSE;
842 }
843
844 nla_nest_end(vendor_event, wmmStats);
845 }
846 nla_nest_end(vendor_event, wmmInfo);
847 return TRUE;
848}
849
850static tSirWifiInterfaceMode
851 hdd_map_device_to_ll_iface_mode ( int deviceMode )
852{
853 switch (deviceMode)
854 {
855 case WLAN_HDD_INFRA_STATION:
856 return WIFI_INTERFACE_STA;
857 case WLAN_HDD_SOFTAP:
858 return WIFI_INTERFACE_SOFTAP;
859 case WLAN_HDD_P2P_CLIENT:
860 return WIFI_INTERFACE_P2P_CLIENT;
861 case WLAN_HDD_P2P_GO:
862 return WIFI_INTERFACE_P2P_GO;
863 case WLAN_HDD_IBSS:
864 return WIFI_INTERFACE_IBSS;
865 default:
866 /* Return Interface Mode as STA for all the unsupported modes */
867 return WIFI_INTERFACE_STA;
868 }
869}
870
871static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
872 tpSirWifiInterfaceInfo pInfo)
873{
874 v_U8_t *staMac = NULL;
875 hdd_station_ctx_t *pHddStaCtx;
876 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
877 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
878
879 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
880
881 vos_mem_copy(pInfo->macAddr,
882 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
883
884 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
885 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
886 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
887 {
888 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
889 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
890 {
891 pInfo->state = WIFI_DISCONNECTED;
892 }
893 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
894 {
895 hddLog(VOS_TRACE_LEVEL_ERROR,
896 "%s: Session ID %d, Connection is in progress", __func__,
897 pAdapter->sessionId);
898 pInfo->state = WIFI_ASSOCIATING;
899 }
900 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
901 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
902 {
903 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
904 hddLog(VOS_TRACE_LEVEL_ERROR,
905 "%s: client " MAC_ADDRESS_STR
906 " is in the middle of WPS/EAPOL exchange.", __func__,
907 MAC_ADDR_ARRAY(staMac));
908 pInfo->state = WIFI_AUTHENTICATING;
909 }
910 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
911 {
912 pInfo->state = WIFI_ASSOCIATED;
913 vos_mem_copy(pInfo->bssid,
914 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
915 vos_mem_copy(pInfo->ssid,
916 pHddStaCtx->conn_info.SSID.SSID.ssId,
917 pHddStaCtx->conn_info.SSID.SSID.length);
918 //NULL Terminate the string.
919 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
920 }
921 }
922 vos_mem_copy(pInfo->countryStr,
923 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
924
925 vos_mem_copy(pInfo->apCountryStr,
926 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
927
928 return TRUE;
929}
930
931/*
932 * hdd_link_layer_process_peer_stats () - This function is called after
933 * receiving Link Layer Peer statistics from FW.This function converts
934 * the firmware data to the NL data and sends the same to the kernel/upper
935 * layers.
936 */
937static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
938 v_VOID_t *pData)
939{
940 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
941 tpSirWifiRateStat pWifiRateStat;
942 tpSirWifiPeerStat pWifiPeerStat;
943 tpSirWifiPeerInfo pWifiPeerInfo;
944 struct nlattr *peerInfo;
945 struct sk_buff *vendor_event;
946 int status, i;
947
948 status = wlan_hdd_validate_context(pHddCtx);
949 if (0 != status)
950 {
951 hddLog(VOS_TRACE_LEVEL_ERROR,
952 FL("HDD context is not valid") );
953 return;
954 }
955
956 pWifiPeerStat = (tpSirWifiPeerStat) pData;
957
958 hddLog(VOS_TRACE_LEVEL_INFO,
959 "LL_STATS_PEER_ALL : numPeers %u",
960 pWifiPeerStat->numPeers);
961 {
962 for (i = 0; i < pWifiPeerStat->numPeers; i++)
963 {
964 pWifiPeerInfo = (tpSirWifiPeerInfo)
965 ((uint8 *)pWifiPeerStat->peerInfo +
966 ( i * sizeof(tSirWifiPeerInfo)));
967
968 hddLog(VOS_TRACE_LEVEL_INFO,
969 " %d) LL_STATS Channel Stats "
970 " Peer Type %u "
971 " peerMacAddress %pM "
972 " capabilities 0x%x "
973 " numRate %u ",
974 i,
975 pWifiPeerInfo->type,
976 pWifiPeerInfo->peerMacAddress,
977 pWifiPeerInfo->capabilities,
978 pWifiPeerInfo->numRate);
979 {
980 int j;
981 for (j = 0; j < pWifiPeerInfo->numRate; j++)
982 {
983 pWifiRateStat = (tpSirWifiRateStat)
984 ((tANI_U8 *) pWifiPeerInfo->rateStats +
985 ( j * sizeof(tSirWifiRateStat)));
986
987 hddLog(VOS_TRACE_LEVEL_INFO,
988 " peer Rate Stats "
989 " preamble %u "
990 " nss %u "
991 " bw %u "
992 " rateMcsIdx %u "
993 " reserved %u "
994 " bitrate %u "
995 " txMpdu %u "
996 " rxMpdu %u "
997 " mpduLost %u "
998 " retries %u "
999 " retriesShort %u "
1000 " retriesLong %u",
1001 pWifiRateStat->rate.preamble,
1002 pWifiRateStat->rate.nss,
1003 pWifiRateStat->rate.bw,
1004 pWifiRateStat->rate.rateMcsIdx,
1005 pWifiRateStat->rate.reserved,
1006 pWifiRateStat->rate.bitrate,
1007 pWifiRateStat->txMpdu,
1008 pWifiRateStat->rxMpdu,
1009 pWifiRateStat->mpduLost,
1010 pWifiRateStat->retries,
1011 pWifiRateStat->retriesShort,
1012 pWifiRateStat->retriesLong);
1013 }
1014 }
1015 }
1016 }
1017
1018 /*
1019 * Allocate a size of 4096 for the peer stats comprising
1020 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1021 * sizeof (tSirWifiRateStat).Each field is put with an
1022 * NL attribute.The size of 4096 is considered assuming
1023 * that number of rates shall not exceed beyond 50 with
1024 * the sizeof (tSirWifiRateStat) being 32.
1025 */
1026 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1027 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1028 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1029 GFP_KERNEL);
1030 if (!vendor_event)
1031 {
1032 hddLog(VOS_TRACE_LEVEL_ERROR,
1033 "%s: cfg80211_vendor_event_alloc failed",
1034 __func__);
1035 return;
1036 }
1037 if (nla_put_u32(vendor_event,
1038 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1039 pWifiPeerStat->numPeers))
1040 {
1041 hddLog(VOS_TRACE_LEVEL_ERROR,
1042 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1043 kfree_skb(vendor_event);
1044 return;
1045 }
1046
1047 peerInfo = nla_nest_start(vendor_event,
1048 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
1049
1050 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1051 pWifiPeerStat->peerInfo);
1052
1053 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1054 {
1055 struct nlattr *peers = nla_nest_start(vendor_event, i);
1056 int numRate = pWifiPeerInfo->numRate;
1057
1058 if (FALSE == put_wifi_peer_info(
1059 pWifiPeerInfo, vendor_event))
1060 {
1061 hddLog(VOS_TRACE_LEVEL_ERROR,
1062 "%s: put_wifi_peer_info put fail", __func__);
1063 kfree_skb(vendor_event);
1064 return;
1065 }
1066
1067 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1068 pWifiPeerStat->peerInfo +
1069 (i * sizeof(tSirWifiPeerInfo)) +
1070 (numRate * sizeof (tSirWifiRateStat)));
1071 nla_nest_end(vendor_event, peers);
1072 }
1073 nla_nest_end(vendor_event, peerInfo);
1074 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1075}
1076
1077/*
1078 * hdd_link_layer_process_iface_stats () - This function is called after
1079 * receiving Link Layer Interface statistics from FW.This function converts
1080 * the firmware data to the NL data and sends the same to the kernel/upper
1081 * layers.
1082 */
1083static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1084 v_VOID_t *pData)
1085{
1086 tpSirWifiIfaceStat pWifiIfaceStat;
1087 struct sk_buff *vendor_event;
1088 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1089 int status;
1090
1091 status = wlan_hdd_validate_context(pHddCtx);
1092 if (0 != status)
1093 {
1094 hddLog(VOS_TRACE_LEVEL_ERROR,
1095 FL("HDD context is not valid") );
1096 return;
1097 }
1098 /*
1099 * Allocate a size of 4096 for the interface stats comprising
1100 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1101 * assuming that all these fit with in the limit.Please take
1102 * a call on the limit based on the data requirements on
1103 * interface statistics.
1104 */
1105 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1106 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1107 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1108 GFP_KERNEL);
1109 if (!vendor_event)
1110 {
1111 hddLog(VOS_TRACE_LEVEL_ERROR,
1112 FL("cfg80211_vendor_event_alloc failed") );
1113 return;
1114 }
1115
1116 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1117
1118 hddLog(VOS_TRACE_LEVEL_INFO,
1119 "WMI_LINK_STATS_IFACE Data");
1120
1121 hddLog(VOS_TRACE_LEVEL_INFO,
1122 "LL_STATS_IFACE: "
1123 " Mode %u "
1124 " MAC %pM "
1125 " State %u "
1126 " Roaming %u "
1127 " capabilities 0x%x "
1128 " SSID %s "
1129 " BSSID %pM",
1130 pWifiIfaceStat->info.mode,
1131 pWifiIfaceStat->info.macAddr,
1132 pWifiIfaceStat->info.state,
1133 pWifiIfaceStat->info.roaming,
1134 pWifiIfaceStat->info.capabilities,
1135 pWifiIfaceStat->info.ssid,
1136 pWifiIfaceStat->info.bssid);
1137
1138 hddLog(VOS_TRACE_LEVEL_INFO,
1139 " AP country str: %c%c%c",
1140 pWifiIfaceStat->info.apCountryStr[0],
1141 pWifiIfaceStat->info.apCountryStr[1],
1142 pWifiIfaceStat->info.apCountryStr[2]);
1143
1144
1145 hddLog(VOS_TRACE_LEVEL_INFO,
1146 " Country Str Association: %c%c%c",
1147 pWifiIfaceStat->info.countryStr[0],
1148 pWifiIfaceStat->info.countryStr[1],
1149 pWifiIfaceStat->info.countryStr[2]);
1150
1151 hddLog(VOS_TRACE_LEVEL_INFO,
1152 " beaconRx %u "
1153 " mgmtRx %u "
1154 " mgmtActionRx %u "
1155 " mgmtActionTx %u "
1156 " rssiMgmt %u "
1157 " rssiData %u "
1158 " rssiAck %u",
1159 pWifiIfaceStat->beaconRx,
1160 pWifiIfaceStat->mgmtRx,
1161 pWifiIfaceStat->mgmtActionRx,
1162 pWifiIfaceStat->mgmtActionTx,
1163 pWifiIfaceStat->rssiMgmt,
1164 pWifiIfaceStat->rssiData,
1165 pWifiIfaceStat->rssiAck );
1166
1167
1168 {
1169 int i;
1170 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1171 {
1172 hddLog(VOS_TRACE_LEVEL_INFO,
1173
1174 " %d) LL_STATS IFACE: "
1175 " ac: %u txMpdu: %u "
1176 " rxMpdu: %u txMcast: %u "
1177 " rxMcast: %u rxAmpdu: %u "
1178 " txAmpdu: %u mpduLost: %u "
1179 " retries: %u retriesShort: %u "
1180 " retriesLong: %u contentionTimeMin: %u "
1181 " contentionTimeMax: %u contentionTimeAvg: %u "
1182 " contentionNumSamples: %u",
1183 i,
1184 pWifiIfaceStat->AccessclassStats[i].ac,
1185 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1186 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1187 pWifiIfaceStat->AccessclassStats[i].txMcast,
1188 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1189 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1190 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1191 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1192 pWifiIfaceStat->AccessclassStats[i].retries,
1193 pWifiIfaceStat->
1194 AccessclassStats[i].retriesShort,
1195 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1196 pWifiIfaceStat->
1197 AccessclassStats[i].contentionTimeMin,
1198 pWifiIfaceStat->
1199 AccessclassStats[i].contentionTimeMax,
1200 pWifiIfaceStat->
1201 AccessclassStats[i].contentionTimeAvg,
1202 pWifiIfaceStat->
1203 AccessclassStats[i].contentionNumSamples);
1204
1205 }
1206 }
1207
1208 if (FALSE == hdd_get_interface_info( pAdapter,
1209 &pWifiIfaceStat->info))
1210 {
1211 hddLog(VOS_TRACE_LEVEL_ERROR,
1212 FL("hdd_get_interface_info get fail") );
1213 kfree_skb(vendor_event);
1214 return;
1215 }
1216
1217 if (FALSE == put_wifi_iface_stats( pWifiIfaceStat,
1218 vendor_event))
1219 {
1220 hddLog(VOS_TRACE_LEVEL_ERROR,
1221 FL("put_wifi_iface_stats fail") );
1222 kfree_skb(vendor_event);
1223 return;
1224 }
1225 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1226}
1227
1228/*
1229 * hdd_link_layer_process_radio_stats () - This function is called after
1230 * receiving Link Layer Radio statistics from FW.This function converts
1231 * the firmware data to the NL data and sends the same to the kernel/upper
1232 * layers.
1233 */
1234static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1235 v_VOID_t *pData)
1236{
1237 int status, i;
1238 tpSirWifiRadioStat pWifiRadioStat;
1239 tpSirWifiChannelStats pWifiChannelStats;
1240 struct sk_buff *vendor_event;
1241 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1242 struct nlattr *chList;
1243
1244 status = wlan_hdd_validate_context(pHddCtx);
1245 if (0 != status)
1246 {
1247 hddLog(VOS_TRACE_LEVEL_ERROR,
1248 FL("HDD context is not valid") );
1249 return;
1250 }
1251 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1252
1253 hddLog(VOS_TRACE_LEVEL_INFO,
1254 "LL_STATS_RADIO"
1255 " radio is %d onTime is %u "
1256 " txTime is %u rxTime is %u "
1257 " onTimeScan is %u onTimeNbd is %u "
1258 " onTimeGscan is %u onTimeRoamScan is %u "
1259 " onTimePnoScan is %u onTimeHs20 is %u "
1260 " numChannels is %u",
1261 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1262 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1263 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
1264 pWifiRadioStat->onTimeGscan,
1265 pWifiRadioStat->onTimeRoamScan,
1266 pWifiRadioStat->onTimePnoScan,
1267 pWifiRadioStat->onTimeHs20,
1268 pWifiRadioStat->numChannels);
1269 /*
1270 * Allocate a size of 4096 for the Radio stats comprising
1271 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1272 * (tSirWifiChannelStats).Each channel data is put with an
1273 * NL attribute.The size of 4096 is considered assuming that
1274 * number of channels shall not exceed beyond 60 with the
1275 * sizeof (tSirWifiChannelStats) being 24 bytes.
1276 */
1277
1278 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1279 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1280 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1281 GFP_KERNEL);
1282
1283 if (!vendor_event)
1284 {
1285 hddLog(VOS_TRACE_LEVEL_ERROR,
1286 FL("cfg80211_vendor_event_alloc failed") );
1287 return;
1288 }
1289
1290 if (nla_put_u32(vendor_event,
1291 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1292 pWifiRadioStat->radio) ||
1293 nla_put_u32(vendor_event,
1294 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1295 pWifiRadioStat->onTime) ||
1296 nla_put_u32(vendor_event,
1297 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1298 pWifiRadioStat->txTime) ||
1299 nla_put_u32(vendor_event,
1300 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1301 pWifiRadioStat->rxTime) ||
1302 nla_put_u32(vendor_event,
1303 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1304 pWifiRadioStat->onTimeScan) ||
1305 nla_put_u32(vendor_event,
1306 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1307 pWifiRadioStat->onTimeNbd) ||
1308 nla_put_u32(vendor_event,
1309 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_GSCAN,
1310 pWifiRadioStat->onTimeGscan)||
1311 nla_put_u32(vendor_event,
1312 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1313 pWifiRadioStat->onTimeRoamScan) ||
1314 nla_put_u32(vendor_event,
1315 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1316 pWifiRadioStat->onTimePnoScan) ||
1317 nla_put_u32(vendor_event,
1318 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1319 pWifiRadioStat->onTimeHs20) ||
1320 nla_put_u32(vendor_event,
1321 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1322 pWifiRadioStat->numChannels))
1323 {
1324 hddLog(VOS_TRACE_LEVEL_ERROR,
1325 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1326 kfree_skb(vendor_event);
1327 return ;
1328 }
1329
1330 chList = nla_nest_start(vendor_event,
1331 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
1332 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1333 {
1334 struct nlattr *chInfo;
1335
1336 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1337 pWifiRadioStat->channels +
1338 (i * sizeof(tSirWifiChannelStats)));
1339
1340 hddLog(VOS_TRACE_LEVEL_INFO,
1341 " %d) Channel Info"
1342 " width is %u "
1343 " CenterFreq %u "
1344 " CenterFreq0 %u "
1345 " CenterFreq1 %u "
1346 " onTime %u "
1347 " ccaBusyTime %u",
1348 i,
1349 pWifiChannelStats->channel.width,
1350 pWifiChannelStats->channel.centerFreq,
1351 pWifiChannelStats->channel.centerFreq0,
1352 pWifiChannelStats->channel.centerFreq1,
1353 pWifiChannelStats->onTime,
1354 pWifiChannelStats->ccaBusyTime);
1355
1356
1357 chInfo = nla_nest_start(vendor_event, i);
1358
1359 if (nla_put_u32(vendor_event,
1360 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1361 pWifiChannelStats->channel.width) ||
1362 nla_put_u32(vendor_event,
1363 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1364 pWifiChannelStats->channel.centerFreq) ||
1365 nla_put_u32(vendor_event,
1366 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1367 pWifiChannelStats->channel.centerFreq0) ||
1368 nla_put_u32(vendor_event,
1369 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1370 pWifiChannelStats->channel.centerFreq1) ||
1371 nla_put_u32(vendor_event,
1372 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1373 pWifiChannelStats->onTime) ||
1374 nla_put_u32(vendor_event,
1375 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1376 pWifiChannelStats->ccaBusyTime))
1377 {
1378 hddLog(VOS_TRACE_LEVEL_ERROR,
1379 FL("cfg80211_vendor_event_alloc failed") );
1380 kfree_skb(vendor_event);
1381 return ;
1382 }
1383 nla_nest_end(vendor_event, chInfo);
1384 }
1385 nla_nest_end(vendor_event, chList);
1386
1387 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1388 return;
1389}
1390
1391/*
1392 * hdd_link_layer_stats_ind_callback () - This function is called after
1393 * receiving Link Layer indications from FW.This callback converts the firmware
1394 * data to the NL data and send the same to the kernel/upper layers.
1395 */
1396static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1397 int indType,
1398 void *pRsp )
1399{
1400 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCtx;
1401 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1402 int status;
1403
1404 status = wlan_hdd_validate_context(pHddCtx);
1405
1406 if (0 != status)
1407 {
1408 hddLog(VOS_TRACE_LEVEL_ERROR,
1409 FL("HDD context is not valid"));
1410 return;
1411 }
1412
1413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1414 "%s: Link Layer Indication indType: %d", __func__, indType);
1415 switch (indType)
1416 {
1417 case SIR_HAL_LL_STATS_RESULTS_RSP:
1418 {
1419 tpSirLLStatsResults linkLayerStatsResults =
1420 (tpSirLLStatsResults)pRsp;
1421
1422
1423 hddLog(VOS_TRACE_LEVEL_INFO,
1424 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1425 hddLog(VOS_TRACE_LEVEL_INFO,
1426 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1427 linkLayerStatsResults->paramId);
1428 hddLog(VOS_TRACE_LEVEL_INFO,
1429 "LL_STATS RESULTS RESPONSE ifaceId = %u",
1430 linkLayerStatsResults->ifaceId);
1431 hddLog(VOS_TRACE_LEVEL_INFO,
1432 "LL_STATS RESULTS RESPONSE respId = %u",
1433 linkLayerStatsResults->respId);
1434 hddLog(VOS_TRACE_LEVEL_INFO,
1435 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1436 linkLayerStatsResults->moreResultToFollow);
1437 hddLog(VOS_TRACE_LEVEL_INFO,
1438 "LL_STATS RESULTS RESPONSE result = %p",
1439 linkLayerStatsResults->result);
1440 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1441 {
1442 hdd_link_layer_process_radio_stats(pAdapter,
1443 (v_VOID_t *)linkLayerStatsResults->result);
1444 }
1445 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1446 {
1447 hdd_link_layer_process_iface_stats(pAdapter,
1448 (v_VOID_t *)linkLayerStatsResults->result);
1449 }
1450 else if ( linkLayerStatsResults->paramId &
1451 WMI_LINK_STATS_ALL_PEER )
1452 {
1453 hdd_link_layer_process_peer_stats(pAdapter,
1454 (v_VOID_t *)linkLayerStatsResults->result);
1455 } /* WMI_LINK_STATS_ALL_PEER */
1456 else
1457 {
1458 hddLog(VOS_TRACE_LEVEL_ERROR,
1459 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1460 }
1461
1462 break;
1463 }
1464 default:
1465 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1466 break;
1467 }
1468 return;
1469}
1470
1471const struct
1472nla_policy
1473qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1474{
1475 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1476 { .type = NLA_U32 },
1477 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1478 { .type = NLA_U32 },
1479};
1480
1481static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1482 struct wireless_dev *wdev,
1483 void *data,
1484 int data_len)
1485{
1486 int status;
1487 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
1488 tpSirLLStatsSetReq pLinkLayerStatsSetReq;
1489 struct net_device *dev = wdev->netdev;
1490 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1491 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1492
1493 status = wlan_hdd_validate_context(pHddCtx);
1494 if (0 != status)
1495 {
1496 hddLog(VOS_TRACE_LEVEL_ERROR,
1497 FL("HDD context is not valid"));
1498 return -EINVAL;
1499 }
1500
1501 if (NULL == pAdapter)
1502 {
1503 hddLog(VOS_TRACE_LEVEL_ERROR,
1504 FL("HDD adapter is Null"));
1505 return -ENODEV;
1506 }
1507
1508 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1509 (struct nlattr *)data,
1510 data_len, qca_wlan_vendor_ll_set_policy))
1511 {
1512 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1513 return -EINVAL;
1514 }
1515 if (!tb_vendor
1516 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1517 {
1518 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1519 return -EINVAL;
1520 }
1521 if (!tb_vendor[
1522 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1523 {
1524 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1525 return -EINVAL;
1526 }
1527 pLinkLayerStatsSetReq = vos_mem_malloc(sizeof(tSirLLStatsSetReq));
1528 if (NULL == pLinkLayerStatsSetReq)
1529 {
1530 hddLog(VOS_TRACE_LEVEL_ERROR,
1531 FL(" Unable to allocate memory to pLinkLayerStatsSetReq") );
1532 return -ENOMEM;
1533 }
1534 // Shall take the request Id if the Upper layers pass. 1 For now.
1535 pLinkLayerStatsSetReq->reqId = 1;
1536
1537 pLinkLayerStatsSetReq->mpduSizeThreshold =
1538 nla_get_u32(
1539 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1540
1541 pLinkLayerStatsSetReq->aggressiveStatisticsGathering =
1542 nla_get_u32(
1543 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1544
1545 /* staId 0 in Firmware is reserved for Broadcast/Multicast data.
1546 * Hence the interface staId start from 1. Hence the staId matching the
1547 * interface in the firmware is sessionId + 1.
1548 */
1549 pLinkLayerStatsSetReq->staId = pAdapter->sessionId + 1;
1550
1551
1552 hddLog(VOS_TRACE_LEVEL_INFO,
1553 "LL_STATS_SET reqId = %d",
1554 pLinkLayerStatsSetReq->reqId);
1555 hddLog(VOS_TRACE_LEVEL_INFO,
1556 "LL_STATS_SET staId = %d", pLinkLayerStatsSetReq->staId);
1557 hddLog(VOS_TRACE_LEVEL_INFO,
1558 "LL_STATS_SET mpduSizeThreshold = %d",
1559 pLinkLayerStatsSetReq->mpduSizeThreshold);
1560 hddLog(VOS_TRACE_LEVEL_INFO,
1561 "LL_STATS_SET aggressive Statistics Gathering = %d",
1562 pLinkLayerStatsSetReq->aggressiveStatisticsGathering);
1563
1564 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1565 pHddCtx->hHal,
1566 pAdapter->sessionId,
1567 hdd_link_layer_stats_ind_callback,
1568 pAdapter))
1569 {
1570 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1571 "sme_SetLinkLayerStatsIndCB Failed", __func__);
1572 vos_mem_free(pLinkLayerStatsSetReq);
1573 return -EINVAL;
1574
1575 }
1576 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
1577 pLinkLayerStatsSetReq))
1578 {
1579 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1580 "sme_LLStatsSetReq Failed", __func__);
1581 vos_mem_free(pLinkLayerStatsSetReq);
1582 return -EINVAL;
1583 }
1584
1585 pAdapter->isLinkLayerStatsSet = 1;
1586
1587 return 0;
1588}
1589
1590const struct
1591nla_policy
1592qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1593{
1594 /* Unsigned 32bit value provided by the caller issuing the GET stats
1595 * command. When reporting
1596 * the stats results, the driver uses the same value to indicate
1597 * which GET request the results
1598 * correspond to.
1599 */
1600 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1601
1602 /* Unsigned 32bit value . bit mask to identify what statistics are
1603 requested for retrieval */
1604 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1605};
1606
1607static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1608 struct wireless_dev *wdev,
1609 void *data,
1610 int data_len)
1611{
1612 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1613 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
1614 tpSirLLStatsGetReq pLinkLayerStatsGetReq;
1615 struct net_device *dev = wdev->netdev;
1616 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1617 int status;
1618
1619 status = wlan_hdd_validate_context(pHddCtx);
1620 if (0 != status)
1621 {
1622 hddLog(VOS_TRACE_LEVEL_ERROR,
1623 FL("HDD context is not valid"));
1624 return -EINVAL ;
1625 }
1626
1627 if (NULL == pAdapter)
1628 {
1629 hddLog(VOS_TRACE_LEVEL_FATAL,
1630 "%s: HDD adapter is Null", __func__);
1631 return -ENODEV;
1632 }
1633
1634 if (!pAdapter->isLinkLayerStatsSet)
1635 {
1636 hddLog(VOS_TRACE_LEVEL_FATAL,
1637 "%s: isLinkLayerStatsSet : %d",
1638 __func__, pAdapter->isLinkLayerStatsSet);
1639 return -EINVAL;
1640 }
1641
1642 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
1643 (struct nlattr *)data,
1644 data_len, qca_wlan_vendor_ll_get_policy))
1645 {
1646 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1647 return -EINVAL;
1648 }
1649
1650 if (!tb_vendor
1651 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
1652 {
1653 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
1654 return -EINVAL;
1655 }
1656
1657 if (!tb_vendor
1658 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
1659 {
1660 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
1661 return -EINVAL;
1662 }
1663
1664 pLinkLayerStatsGetReq = vos_mem_malloc(sizeof(tSirLLStatsGetReq));
1665
1666 if (NULL == pLinkLayerStatsGetReq)
1667 {
1668 hddLog(VOS_TRACE_LEVEL_ERROR,
1669 FL("Unable to allocate memory to pLinkLayerStatsGetReq"));
1670 return -ENOMEM;
1671 }
1672
1673 pLinkLayerStatsGetReq->reqId =
1674 nla_get_u32( tb_vendor[
1675 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
1676 pLinkLayerStatsGetReq->paramIdMask =
1677 nla_get_u32( tb_vendor[
1678 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
1679
1680 /* staId 0 in Firmware is reserved for Broadcast/Multicast data.
1681 * Hence the interface staId start from 1. Hence the staId matching the
1682 * interface in the firmware is sessionId + 1.
1683 */
1684 pLinkLayerStatsGetReq->staId = pAdapter->sessionId + 1;
1685
1686 hddLog(VOS_TRACE_LEVEL_INFO,
1687 "LL_STATS_GET reqId = %d", pLinkLayerStatsGetReq->reqId);
1688 hddLog(VOS_TRACE_LEVEL_INFO,
1689 "LL_STATS_GET staId = %d", pLinkLayerStatsGetReq->staId);
1690 hddLog(VOS_TRACE_LEVEL_INFO,
1691 "LL_STATS_GET paramIdMask = %d",
1692 pLinkLayerStatsGetReq->paramIdMask);
1693
1694 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
1695 pLinkLayerStatsGetReq))
1696 {
1697 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1698 "sme_LLStatsGetReq Failed", __func__);
1699 vos_mem_free(pLinkLayerStatsGetReq);
1700 return -EINVAL;
1701 }
1702 return 0;
1703}
1704
1705const struct
1706nla_policy
1707qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
1708{
1709 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
1710 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
1711 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
1712 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
1713};
1714
1715static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
1716 struct wireless_dev *wdev,
1717 void *data,
1718 int data_len)
1719{
1720 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1721 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
1722 tpSirLLStatsClearReq pLinkLayerStatsClearReq;
1723 struct net_device *dev = wdev->netdev;
1724 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1725 u32 statsClearReqMask;
1726 u8 stopReq;
1727 int status;
1728
1729 status = wlan_hdd_validate_context(pHddCtx);
1730 if (0 != status)
1731 {
1732 hddLog(VOS_TRACE_LEVEL_ERROR,
1733 FL("HDD context is not valid"));
1734 return -EINVAL;
1735 }
1736
1737 if (NULL == pAdapter)
1738 {
1739 hddLog(VOS_TRACE_LEVEL_FATAL,
1740 "%s: HDD adapter is Null", __func__);
1741 return -ENODEV;
1742 }
1743
1744 if (!pAdapter->isLinkLayerStatsSet)
1745 {
1746 hddLog(VOS_TRACE_LEVEL_FATAL,
1747 "%s: isLinkLayerStatsSet : %d",
1748 __func__, pAdapter->isLinkLayerStatsSet);
1749 return -EINVAL;
1750 }
1751
1752 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
1753 (struct nlattr *)data,
1754 data_len, qca_wlan_vendor_ll_clr_policy))
1755 {
1756 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1757 return -EINVAL;
1758 }
1759
1760 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
1761
1762 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
1763 {
1764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
1765 return -EINVAL;
1766
1767 }
1768
1769 pLinkLayerStatsClearReq = vos_mem_malloc(sizeof(tSirLLStatsClearReq));
1770 if (NULL == pLinkLayerStatsClearReq)
1771 {
1772 hddLog(VOS_TRACE_LEVEL_ERROR,
1773 FL("Unable to allocate memory to pLinkLayerStatsClearReq"));
1774 return -ENOMEM;
1775 }
1776
1777 statsClearReqMask = pLinkLayerStatsClearReq->statsClearReqMask =
1778 nla_get_u32(
1779 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
1780
1781 stopReq = pLinkLayerStatsClearReq->stopReq =
1782 nla_get_u8(
1783 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
1784
1785 // Shall take the request Id if the Upper layers pass. 1 For now.
1786 pLinkLayerStatsClearReq->reqId = 1;
1787
1788 /* staId 0 in Firmware is reserved for Broadcast/Multicast data.
1789 * Hence the interface staId start from 1. Hence the staId matching the
1790 * interface in the firmware is sessionId + 1.
1791 */
1792 pLinkLayerStatsClearReq->staId = pAdapter->sessionId + 1;
1793
1794 hddLog(VOS_TRACE_LEVEL_INFO,
1795 "LL_STATS_CLEAR reqId = %d", pLinkLayerStatsClearReq->reqId);
1796 hddLog(VOS_TRACE_LEVEL_INFO,
1797 "LL_STATS_CLEAR staId = %d", pLinkLayerStatsClearReq->staId);
1798 hddLog(VOS_TRACE_LEVEL_INFO,
1799 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
1800 pLinkLayerStatsClearReq->statsClearReqMask);
1801 hddLog(VOS_TRACE_LEVEL_INFO,
1802 "LL_STATS_CLEAR stopReq = %d",
1803 pLinkLayerStatsClearReq->stopReq);
1804
1805 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
1806 pLinkLayerStatsClearReq))
1807 {
1808 struct sk_buff *temp_skbuff;
1809 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
1810 2 * sizeof(u32) +
1811 NLMSG_HDRLEN);
1812
1813 if (temp_skbuff != NULL)
1814 {
1815
1816 if (nla_put_u32(temp_skbuff,
1817 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
1818 statsClearReqMask) ||
1819 nla_put_u32(temp_skbuff,
1820 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
1821 stopReq))
1822 {
1823 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
1824 kfree_skb(temp_skbuff);
1825 return -EINVAL;
1826 }
1827 /* If the ask is to stop the stats collection as part of clear
1828 * (stopReq = 1) , ensure that no further requests of get
1829 * go to the firmware by having isLinkLayerStatsSet set to 0.
1830 * However it the stopReq as part of the clear request is 0 ,
1831 * the request to get the statistics are ehonoured as in this
1832 * case the firmware is just asked to clear the statistics.
1833 */
1834 if (pLinkLayerStatsClearReq->stopReq == 1)
1835 pAdapter->isLinkLayerStatsSet = 0;
1836 return cfg80211_vendor_cmd_reply(temp_skbuff);
1837 }
1838 return -ENOMEM;
1839 }
1840 vos_mem_free(pLinkLayerStatsClearReq);
1841 return -EINVAL;
1842}
1843#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1844
1845const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
1846{
1847#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1848 {
1849 .info.vendor_id = QCA_NL80211_VENDOR_ID,
1850 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
1851 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
1852 WIPHY_VENDOR_CMD_NEED_NETDEV |
1853 WIPHY_VENDOR_CMD_NEED_RUNNING,
1854 .doit = wlan_hdd_cfg80211_ll_stats_clear
1855 },
1856
1857 {
1858 .info.vendor_id = QCA_NL80211_VENDOR_ID,
1859 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
1860 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
1861 WIPHY_VENDOR_CMD_NEED_NETDEV |
1862 WIPHY_VENDOR_CMD_NEED_RUNNING,
1863 .doit = wlan_hdd_cfg80211_ll_stats_set
1864 },
1865
1866 {
1867 .info.vendor_id = QCA_NL80211_VENDOR_ID,
1868 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
1869 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
1870 WIPHY_VENDOR_CMD_NEED_NETDEV |
1871 WIPHY_VENDOR_CMD_NEED_RUNNING,
1872 .doit = wlan_hdd_cfg80211_ll_stats_get
1873 }
1874#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1875};
1876
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001877/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05301878static const
1879struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001880{
1881#ifdef FEATURE_WLAN_CH_AVOID
1882 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301883 .vendor_id = QCA_NL80211_VENDOR_ID,
1884 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001885 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05301886#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
1887#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1888 {
1889 /* Index = 1*/
1890 .vendor_id = QCA_NL80211_VENDOR_ID,
1891 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
1892 },
1893 {
1894 /* Index = 2*/
1895 .vendor_id = QCA_NL80211_VENDOR_ID,
1896 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
1897 },
1898 {
1899 /* Index = 3*/
1900 .vendor_id = QCA_NL80211_VENDOR_ID,
1901 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
1902 },
1903 {
1904 /* Index = 4*/
1905 .vendor_id = QCA_NL80211_VENDOR_ID,
1906 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
1907 },
1908 {
1909 /* Index = 5*/
1910 .vendor_id = QCA_NL80211_VENDOR_ID,
1911 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
1912 },
1913 {
1914 /* Index = 6*/
1915 .vendor_id = QCA_NL80211_VENDOR_ID,
1916 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
1917 },
1918#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1919
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001920};
1921
Jeff Johnson295189b2012-06-20 16:38:30 -07001922/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05301923 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301924 * This function is called by hdd_wlan_startup()
1925 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05301926 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05301928struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07001929{
1930 struct wiphy *wiphy;
1931 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301932 /*
1933 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 */
1935 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
1936
1937 if (!wiphy)
1938 {
1939 /* Print error and jump into err label and free the memory */
1940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
1941 return NULL;
1942 }
1943
Sunil Duttc69bccb2014-05-26 21:30:20 +05301944
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 return wiphy;
1946}
1947
1948/*
1949 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301950 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 * private ioctl to change the band value
1952 */
1953int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
1954{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05301955 int i, j;
1956 eNVChannelEnabledType channelEnabledState;
1957
Jeff Johnsone7245742012-09-05 17:12:55 -07001958 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05301959
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05301960 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05301962
1963 if (NULL == wiphy->bands[i])
1964 {
1965 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
1966 __func__, i);
1967 continue;
1968 }
1969
1970 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
1971 {
1972 struct ieee80211_supported_band *band = wiphy->bands[i];
1973
1974 channelEnabledState = vos_nv_getChannelEnabledState(
1975 band->channels[j].hw_value);
1976
1977 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
1978 {
1979 // Enable Social channels for P2P
1980 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
1981 NV_CHANNEL_ENABLE == channelEnabledState)
1982 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
1983 else
1984 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
1985 continue;
1986 }
1987 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
1988 {
1989 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
1990 continue;
1991 }
1992
1993 if (NV_CHANNEL_DISABLE == channelEnabledState ||
1994 NV_CHANNEL_INVALID == channelEnabledState)
1995 {
1996 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
1997 }
1998 else if (NV_CHANNEL_DFS == channelEnabledState)
1999 {
2000 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
2001 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
2002 }
2003 else
2004 {
2005 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
2006 |IEEE80211_CHAN_RADAR);
2007 }
2008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 }
2010 return 0;
2011}
2012/*
2013 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302014 * This function is called by hdd_wlan_startup()
2015 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 * This function is used to initialize and register wiphy structure.
2017 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05302018int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 struct wiphy *wiphy,
2020 hdd_config_t *pCfg
2021 )
2022{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05302023 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05302024 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2025
Jeff Johnsone7245742012-09-05 17:12:55 -07002026 ENTER();
2027
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 /* Now bind the underlying wlan device with wiphy */
2029 set_wiphy_dev(wiphy, dev);
2030
2031 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07002032
Kiet Lam6c583332013-10-14 05:37:09 +05302033#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07002034 /* the flag for the other case would be initialzed in
2035 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07002036 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05302037#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07002038
Amar Singhalfddc28c2013-09-05 13:03:40 -07002039 /* This will disable updating of NL channels from passive to
2040 * active if a beacon is received on passive channel. */
2041 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07002042
Amar Singhalfddc28c2013-09-05 13:03:40 -07002043
Amar Singhala49cbc52013-10-08 18:37:44 -07002044
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002045#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002046 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
2047 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
2048 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07002049 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05302050 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002051#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07002052
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002053#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07002054 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08002055#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07002056 || pCfg->isFastRoamIniFeatureEnabled
2057#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002058#ifdef FEATURE_WLAN_ESE
2059 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07002060#endif
2061 )
2062 {
2063 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
2064 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08002065#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002066#ifdef FEATURE_WLAN_TDLS
2067 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
2068 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
2069#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05302070#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05302071 if (pCfg->configPNOScanSupport)
2072 {
2073 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
2074 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
2075 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
2076 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
2077 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05302078#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002079
Amar Singhalfddc28c2013-09-05 13:03:40 -07002080#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07002081 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
2082 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07002083 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07002084 driver need to determine what to do with both
2085 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07002086
2087 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07002088#else
2089 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07002090#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002091
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302092 wiphy->max_scan_ssids = MAX_SCAN_SSID;
2093
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +05302094 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07002095
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302096 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
2097
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302099 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 | BIT(NL80211_IFTYPE_P2P_CLIENT)
2102 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 | BIT(NL80211_IFTYPE_AP);
2104
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05302105 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08002106 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05302107#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
2108 if( pCfg->enableMCC )
2109 {
2110 /* Currently, supports up to two channels */
2111 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08002112
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05302113 if( !pCfg->allowMCCGODiffBI )
2114 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08002115
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05302116 }
2117 wiphy->iface_combinations = &wlan_hdd_iface_combination;
2118 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08002119#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05302120 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08002121
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 /* Before registering we need to update the ht capabilitied based
2123 * on ini values*/
2124 if( !pCfg->ShortGI20MhzEnable )
2125 {
2126 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
2127 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
2128 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
2129 }
2130
2131 if( !pCfg->ShortGI40MhzEnable )
2132 {
2133 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
2134 }
2135
2136 if( !pCfg->nChannelBondingMode5GHz )
2137 {
2138 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
2139 }
2140
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05302141 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05302142 if (true == hdd_is_5g_supported(pHddCtx))
2143 {
2144 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
2145 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05302146
2147 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
2148 {
2149
2150 if (NULL == wiphy->bands[i])
2151 {
2152 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
2153 __func__, i);
2154 continue;
2155 }
2156
2157 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
2158 {
2159 struct ieee80211_supported_band *band = wiphy->bands[i];
2160
2161 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
2162 {
2163 // Enable social channels for P2P
2164 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
2165 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
2166 else
2167 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
2168 continue;
2169 }
2170 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
2171 {
2172 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
2173 continue;
2174 }
2175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 }
2177 /*Initialise the supported cipher suite details*/
2178 wiphy->cipher_suites = hdd_cipher_suites;
2179 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
2180
2181 /*signal strength in mBm (100*dBm) */
2182 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
2183
2184#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 wiphy->max_remain_on_channel_duration = 1000;
2186#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002187
Sunil Duttc69bccb2014-05-26 21:30:20 +05302188 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
2189 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08002190 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
2191 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
2192
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05302193 EXIT();
2194 return 0;
2195}
2196
2197/* In this function we are registering wiphy. */
2198int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
2199{
2200 ENTER();
2201 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 if (0 > wiphy_register(wiphy))
2203 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05302204 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
2206 return -EIO;
2207 }
2208
2209 EXIT();
2210 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302211}
Jeff Johnson295189b2012-06-20 16:38:30 -07002212
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05302213/* In this function we are updating channel list when,
2214 regulatory domain is FCC and country code is US.
2215 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
2216 As per FCC smart phone is not a indoor device.
2217 GO should not opeate on indoor channels */
2218void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
2219{
2220 int j;
2221 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2222 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
2223 //Default counrtycode from NV at the time of wiphy initialization.
2224 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
2225 &defaultCountryCode[0]))
2226 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002227 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05302228 }
2229 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
2230 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05302231 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
2232 {
2233 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
2234 return;
2235 }
2236 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
2237 {
2238 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
2239 // Mark UNII -1 band channel as passive
2240 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
2241 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
2242 }
2243 }
2244}
2245
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05302246/* This function registers for all frame which supplicant is interested in */
2247void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002248{
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2250 /* Register for all P2P action, public action etc frames */
2251 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
2252
Jeff Johnsone7245742012-09-05 17:12:55 -07002253 ENTER();
2254
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 /* Right now we are registering these frame when driver is getting
2256 initialized. Once we will move to 2.6.37 kernel, in which we have
2257 frame register ops, we will move this code as a part of that */
2258 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302259 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
2261
2262 /* GAS Initial Response */
2263 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
2264 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302265
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 /* GAS Comeback Request */
2267 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
2268 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
2269
2270 /* GAS Comeback Response */
2271 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
2272 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
2273
2274 /* P2P Public Action */
2275 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302276 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 P2P_PUBLIC_ACTION_FRAME_SIZE );
2278
2279 /* P2P Action */
2280 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
2281 (v_U8_t*)P2P_ACTION_FRAME,
2282 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07002283
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05302284 /* WNM BSS Transition Request frame */
2285 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
2286 (v_U8_t*)WNM_BSS_ACTION_FRAME,
2287 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07002288
2289 /* WNM-Notification */
2290 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
2291 (v_U8_t*)WNM_NOTIFICATION_FRAME,
2292 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002293}
2294
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05302295void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002296{
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2298 /* Register for all P2P action, public action etc frames */
2299 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
2300
Jeff Johnsone7245742012-09-05 17:12:55 -07002301 ENTER();
2302
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 /* Right now we are registering these frame when driver is getting
2304 initialized. Once we will move to 2.6.37 kernel, in which we have
2305 frame register ops, we will move this code as a part of that */
2306 /* GAS Initial Request */
2307
2308 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
2309 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
2310
2311 /* GAS Initial Response */
2312 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
2313 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302314
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 /* GAS Comeback Request */
2316 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
2317 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
2318
2319 /* GAS Comeback Response */
2320 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
2321 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
2322
2323 /* P2P Public Action */
2324 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302325 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 P2P_PUBLIC_ACTION_FRAME_SIZE );
2327
2328 /* P2P Action */
2329 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
2330 (v_U8_t*)P2P_ACTION_FRAME,
2331 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07002332 /* WNM-Notification */
2333 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
2334 (v_U8_t*)WNM_NOTIFICATION_FRAME,
2335 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002336}
2337
2338#ifdef FEATURE_WLAN_WAPI
2339void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
2340 const u8 *mac_addr, u8 *key , int key_Len)
2341{
2342 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2343 tCsrRoamSetKey setKey;
2344 v_BOOL_t isConnected = TRUE;
2345 int status = 0;
2346 v_U32_t roamId= 0xFF;
2347 tANI_U8 *pKeyPtr = NULL;
2348 int n = 0;
2349
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302350 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
2351 __func__, hdd_device_modetoString(pAdapter->device_mode),
2352 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002353
Gopichand Nakkalae7480202013-02-11 15:24:22 +05302354 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 setKey.keyId = key_index; // Store Key ID
2356 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
2357 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
2358 setKey.paeRole = 0 ; // the PAE role
2359 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
2360 {
2361 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
2362 }
2363 else
2364 {
2365 isConnected = hdd_connIsConnected(pHddStaCtx);
2366 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
2367 }
2368 setKey.keyLength = key_Len;
2369 pKeyPtr = setKey.Key;
2370 memcpy( pKeyPtr, key, key_Len);
2371
Arif Hussain6d2a3322013-11-17 19:50:10 -08002372 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 __func__, key_Len);
2374 for (n = 0 ; n < key_Len; n++)
2375 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
2376 __func__,n,setKey.Key[n]);
2377
2378 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
2379 if ( isConnected )
2380 {
2381 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2382 pAdapter->sessionId, &setKey, &roamId );
2383 }
2384 if ( status != 0 )
2385 {
2386 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2387 "[%4d] sme_RoamSetKey returned ERROR status= %d",
2388 __LINE__, status );
2389 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2390 }
2391}
2392#endif /* FEATURE_WLAN_WAPI*/
2393
2394#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302395int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002396 beacon_data_t **ppBeacon,
2397 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002398#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302399int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002400 beacon_data_t **ppBeacon,
2401 struct cfg80211_beacon_data *params,
2402 int dtim_period)
2403#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302404{
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 int size;
2406 beacon_data_t *beacon = NULL;
2407 beacon_data_t *old = NULL;
2408 int head_len,tail_len;
2409
Jeff Johnsone7245742012-09-05 17:12:55 -07002410 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302412 {
2413 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2414 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002417
2418 old = pAdapter->sessionCtx.ap.beacon;
2419
2420 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302421 {
2422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2423 FL("session(%d) old and new heads points to NULL"),
2424 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302426 }
2427
2428 if (params->tail && !params->tail_len)
2429 {
2430 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2431 FL("tail_len is zero but tail is not NULL"));
2432 return -EINVAL;
2433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002434
Jeff Johnson295189b2012-06-20 16:38:30 -07002435#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
2436 /* Kernel 3.0 is not updating dtim_period for set beacon */
2437 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302438 {
2439 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2440 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002443#endif
2444
2445 if(params->head)
2446 head_len = params->head_len;
2447 else
2448 head_len = old->head_len;
2449
2450 if(params->tail || !old)
2451 tail_len = params->tail_len;
2452 else
2453 tail_len = old->tail_len;
2454
2455 size = sizeof(beacon_data_t) + head_len + tail_len;
2456
2457 beacon = kzalloc(size, GFP_KERNEL);
2458
2459 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302460 {
2461 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2462 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002465
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002466#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 if(params->dtim_period || !old )
2468 beacon->dtim_period = params->dtim_period;
2469 else
2470 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002471#else
2472 if(dtim_period || !old )
2473 beacon->dtim_period = dtim_period;
2474 else
2475 beacon->dtim_period = old->dtim_period;
2476#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302477
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
2479 beacon->tail = beacon->head + head_len;
2480 beacon->head_len = head_len;
2481 beacon->tail_len = tail_len;
2482
2483 if(params->head) {
2484 memcpy (beacon->head,params->head,beacon->head_len);
2485 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302486 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 if(old)
2488 memcpy (beacon->head,old->head,beacon->head_len);
2489 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302490
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 if(params->tail) {
2492 memcpy (beacon->tail,params->tail,beacon->tail_len);
2493 }
2494 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302495 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 memcpy (beacon->tail,old->tail,beacon->tail_len);
2497 }
2498
2499 *ppBeacon = beacon;
2500
2501 kfree(old);
2502
2503 return 0;
2504
2505}
Jeff Johnson295189b2012-06-20 16:38:30 -07002506
2507v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
2508{
2509 int left = length;
2510 v_U8_t *ptr = pIes;
2511 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302512
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302514 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002515 elem_id = ptr[0];
2516 elem_len = ptr[1];
2517 left -= 2;
2518 if(elem_len > left)
2519 {
2520 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002521 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 eid,elem_len,left);
2523 return NULL;
2524 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302525 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 {
2527 return ptr;
2528 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302529
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 left -= elem_len;
2531 ptr += (elem_len + 2);
2532 }
2533 return NULL;
2534}
2535
Jeff Johnson295189b2012-06-20 16:38:30 -07002536/* Check if rate is 11g rate or not */
2537static int wlan_hdd_rate_is_11g(u8 rate)
2538{
Sanjay Devnani28322e22013-06-21 16:13:40 -07002539 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 u8 i;
2541 for (i = 0; i < 8; i++)
2542 {
2543 if(rate == gRateArray[i])
2544 return TRUE;
2545 }
2546 return FALSE;
2547}
2548
2549/* Check for 11g rate and set proper 11g only mode */
2550static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
2551 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
2552{
2553 u8 i, num_rates = pIe[0];
2554
2555 pIe += 1;
2556 for ( i = 0; i < num_rates; i++)
2557 {
2558 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
2559 {
2560 /* If rate set have 11g rate than change the mode to 11G */
2561 *pSapHw_mode = eSAP_DOT11_MODE_11g;
2562 if (pIe[i] & BASIC_RATE_MASK)
2563 {
2564 /* If we have 11g rate as basic rate, it means mode
2565 is 11g only mode.
2566 */
2567 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
2568 *pCheckRatesfor11g = FALSE;
2569 }
2570 }
2571 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
2572 {
2573 *require_ht = TRUE;
2574 }
2575 }
2576 return;
2577}
2578
2579static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
2580{
2581 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
2582 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
2583 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
2584 u8 checkRatesfor11g = TRUE;
2585 u8 require_ht = FALSE;
2586 u8 *pIe=NULL;
2587
2588 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
2589
2590 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
2591 pBeacon->head_len, WLAN_EID_SUPP_RATES);
2592 if (pIe != NULL)
2593 {
2594 pIe += 1;
2595 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
2596 &pConfig->SapHw_mode);
2597 }
2598
2599 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
2600 WLAN_EID_EXT_SUPP_RATES);
2601 if (pIe != NULL)
2602 {
2603
2604 pIe += 1;
2605 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
2606 &pConfig->SapHw_mode);
2607 }
2608
2609 if( pConfig->channel > 14 )
2610 {
2611 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
2612 }
2613
2614 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
2615 WLAN_EID_HT_CAPABILITY);
2616
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302617 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 {
2619 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
2620 if(require_ht)
2621 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
2622 }
2623}
2624
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302625static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
2626 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
2627{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07002628 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302629 v_U8_t *pIe = NULL;
2630 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
2631
2632 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
2633 pBeacon->tail, pBeacon->tail_len);
2634
2635 if (pIe)
2636 {
2637 ielen = pIe[1] + 2;
2638 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
2639 {
2640 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
2641 }
2642 else
2643 {
2644 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
2645 return -EINVAL;
2646 }
2647 *total_ielen += ielen;
2648 }
2649 return 0;
2650}
2651
Arif Hussaine7f3ea52013-09-12 21:56:36 -07002652static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
2653 v_U8_t *genie, v_U8_t *total_ielen)
2654{
2655 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
2656 int left = pBeacon->tail_len;
2657 v_U8_t *ptr = pBeacon->tail;
2658 v_U8_t elem_id, elem_len;
2659 v_U16_t ielen = 0;
2660
2661 if ( NULL == ptr || 0 == left )
2662 return;
2663
2664 while (left >= 2)
2665 {
2666 elem_id = ptr[0];
2667 elem_len = ptr[1];
2668 left -= 2;
2669 if (elem_len > left)
2670 {
2671 hddLog( VOS_TRACE_LEVEL_ERROR,
2672 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
2673 elem_id, elem_len, left);
2674 return;
2675 }
2676 if (IE_EID_VENDOR == elem_id)
2677 {
2678 /* skipping the VSIE's which we don't want to include or
2679 * it will be included by existing code
2680 */
2681 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
2682#ifdef WLAN_FEATURE_WFD
2683 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
2684#endif
2685 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
2686 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
2687 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
2688 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
2689 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
2690 {
2691 ielen = ptr[1] + 2;
2692 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
2693 {
2694 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
2695 *total_ielen += ielen;
2696 }
2697 else
2698 {
2699 hddLog( VOS_TRACE_LEVEL_ERROR,
2700 "IE Length is too big "
2701 "IEs eid=%d elem_len=%d total_ie_lent=%d",
2702 elem_id, elem_len, *total_ielen);
2703 }
2704 }
2705 }
2706
2707 left -= elem_len;
2708 ptr += (elem_len + 2);
2709 }
2710 return;
2711}
2712
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002713#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002714static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
2715 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002716#else
2717static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
2718 struct cfg80211_beacon_data *params)
2719#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002720{
2721 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302722 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07002724 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002725
2726 genie = vos_mem_malloc(MAX_GENIE_LEN);
2727
2728 if(genie == NULL) {
2729
2730 return -ENOMEM;
2731 }
2732
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302733 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
2734 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302736 hddLog(LOGE,
2737 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302738 ret = -EINVAL;
2739 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 }
2741
2742#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302743 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
2744 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
2745 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302746 hddLog(LOGE,
2747 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302748 ret = -EINVAL;
2749 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 }
2751#endif
2752
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302753 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
2754 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302756 hddLog(LOGE,
2757 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302758 ret = -EINVAL;
2759 goto done;
2760 }
2761
Abhishek Singh5128c4f2014-06-04 14:48:31 +05302762 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
2763 &total_ielen, WMM_OUI_TYPE, WMM_OUI_TYPE_SIZE))
2764 {
2765 hddLog(LOGE, FL("Adding WMM IE failed"));
2766 ret = -EINVAL;
2767 goto done;
2768 }
2769
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302770 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
2771 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07002772 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002774
2775 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2776 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
2777 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
2778 {
2779 hddLog(LOGE,
2780 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002781 ret = -EINVAL;
2782 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 }
2784
2785 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2786 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
2787 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
2788 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
2789 ==eHAL_STATUS_FAILURE)
2790 {
2791 hddLog(LOGE,
2792 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002793 ret = -EINVAL;
2794 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 }
2796
2797 // Added for ProResp IE
2798 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
2799 {
2800 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
2801 u8 probe_rsp_ie_len[3] = {0};
2802 u8 counter = 0;
2803 /* Check Probe Resp Length if it is greater then 255 then Store
2804 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
2805 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
2806 Store More then 255 bytes into One Variable.
2807 */
2808 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
2809 {
2810 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
2811 {
2812 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
2813 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
2814 }
2815 else
2816 {
2817 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
2818 rem_probe_resp_ie_len = 0;
2819 }
2820 }
2821
2822 rem_probe_resp_ie_len = 0;
2823
2824 if (probe_rsp_ie_len[0] > 0)
2825 {
2826 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2827 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
2828 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
2829 probe_rsp_ie_len[0], NULL,
2830 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
2831 {
2832 hddLog(LOGE,
2833 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002834 ret = -EINVAL;
2835 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 }
2837 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
2838 }
2839
2840 if (probe_rsp_ie_len[1] > 0)
2841 {
2842 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2843 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
2844 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
2845 probe_rsp_ie_len[1], NULL,
2846 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
2847 {
2848 hddLog(LOGE,
2849 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002850 ret = -EINVAL;
2851 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 }
2853 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
2854 }
2855
2856 if (probe_rsp_ie_len[2] > 0)
2857 {
2858 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2859 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
2860 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
2861 probe_rsp_ie_len[2], NULL,
2862 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
2863 {
2864 hddLog(LOGE,
2865 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002866 ret = -EINVAL;
2867 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 }
2869 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
2870 }
2871
2872 if (probe_rsp_ie_len[1] == 0 )
2873 {
2874 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2875 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
2876 eANI_BOOLEAN_FALSE) )
2877 {
2878 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002879 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 }
2881 }
2882
2883 if (probe_rsp_ie_len[2] == 0 )
2884 {
2885 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2886 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
2887 eANI_BOOLEAN_FALSE) )
2888 {
2889 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002890 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 }
2892 }
2893
2894 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2895 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
2896 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
2897 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
2898 == eHAL_STATUS_FAILURE)
2899 {
2900 hddLog(LOGE,
2901 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002902 ret = -EINVAL;
2903 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 }
2905 }
2906 else
2907 {
2908 // Reset WNI_CFG_PROBE_RSP Flags
2909 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
2910
2911 hddLog(VOS_TRACE_LEVEL_INFO,
2912 "%s: No Probe Response IE received in set beacon",
2913 __func__);
2914 }
2915
2916 // Added for AssocResp IE
2917 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
2918 {
2919 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2920 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
2921 params->assocresp_ies_len, NULL,
2922 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
2923 {
2924 hddLog(LOGE,
2925 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002926 ret = -EINVAL;
2927 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 }
2929
2930 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2931 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
2932 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
2933 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
2934 == eHAL_STATUS_FAILURE)
2935 {
2936 hddLog(LOGE,
2937 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002938 ret = -EINVAL;
2939 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002940 }
2941 }
2942 else
2943 {
2944 hddLog(VOS_TRACE_LEVEL_INFO,
2945 "%s: No Assoc Response IE received in set beacon",
2946 __func__);
2947
2948 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2949 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2950 eANI_BOOLEAN_FALSE) )
2951 {
2952 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002953 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002954 }
2955 }
2956
Jeff Johnsone7245742012-09-05 17:12:55 -07002957done:
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302959 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002960}
Jeff Johnson295189b2012-06-20 16:38:30 -07002961
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302962/*
Jeff Johnson295189b2012-06-20 16:38:30 -07002963 * FUNCTION: wlan_hdd_validate_operation_channel
2964 * called by wlan_hdd_cfg80211_start_bss() and
2965 * wlan_hdd_cfg80211_set_channel()
2966 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302967 * channel list.
2968 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07002969VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07002970{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302971
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 v_U32_t num_ch = 0;
2973 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2974 u32 indx = 0;
2975 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05302976 v_U8_t fValidChannel = FALSE, count = 0;
2977 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302978
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2980
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05302981 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05302983 /* Validate the channel */
2984 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05302986 if ( channel == rfChannels[count].channelNum )
2987 {
2988 fValidChannel = TRUE;
2989 break;
2990 }
2991 }
2992 if (fValidChannel != TRUE)
2993 {
2994 hddLog(VOS_TRACE_LEVEL_ERROR,
2995 "%s: Invalid Channel [%d]", __func__, channel);
2996 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 }
2998 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05302999 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003000 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05303001 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
3002 valid_ch, &num_ch))
3003 {
3004 hddLog(VOS_TRACE_LEVEL_ERROR,
3005 "%s: failed to get valid channel list", __func__);
3006 return VOS_STATUS_E_FAILURE;
3007 }
3008 for (indx = 0; indx < num_ch; indx++)
3009 {
3010 if (channel == valid_ch[indx])
3011 {
3012 break;
3013 }
3014 }
3015
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05303016 if (indx >= num_ch)
3017 {
3018 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
3019 {
3020 eCsrBand band;
3021 unsigned int freq;
3022
3023 sme_GetFreqBand(hHal, &band);
3024
3025 if (eCSR_BAND_5G == band)
3026 {
3027#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
3028 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
3029 {
3030 freq = ieee80211_channel_to_frequency(channel,
3031 IEEE80211_BAND_2GHZ);
3032 }
3033 else
3034 {
3035 freq = ieee80211_channel_to_frequency(channel,
3036 IEEE80211_BAND_5GHZ);
3037 }
3038#else
3039 freq = ieee80211_channel_to_frequency(channel);
3040#endif
3041 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
3042 return VOS_STATUS_SUCCESS;
3043 }
3044 }
3045
3046 hddLog(VOS_TRACE_LEVEL_ERROR,
3047 "%s: Invalid Channel [%d]", __func__, channel);
3048 return VOS_STATUS_E_FAILURE;
3049 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05303051
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303053
Jeff Johnson295189b2012-06-20 16:38:30 -07003054}
3055
Viral Modi3a32cc52013-02-08 11:14:52 -08003056/**
3057 * FUNCTION: wlan_hdd_cfg80211_set_channel
3058 * This function is used to set the channel number
3059 */
3060static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
3061 struct ieee80211_channel *chan,
3062 enum nl80211_channel_type channel_type
3063 )
3064{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303065 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08003066 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07003067 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08003068 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303069 hdd_context_t *pHddCtx;
3070 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08003071
3072 ENTER();
3073
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303074
Viral Modi3a32cc52013-02-08 11:14:52 -08003075 if( NULL == dev )
3076 {
3077 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003078 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08003079 return -ENODEV;
3080 }
3081 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
3082
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303083 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3084 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
3085 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08003086 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303087 "%s: device_mode = %s (%d) freq = %d", __func__,
3088 hdd_device_modetoString(pAdapter->device_mode),
3089 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303090
3091 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3092 status = wlan_hdd_validate_context(pHddCtx);
3093
3094 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08003095 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303096 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3097 "%s: HDD context is not valid", __func__);
3098 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08003099 }
3100
3101 /*
3102 * Do freq to chan conversion
3103 * TODO: for 11a
3104 */
3105
3106 channel = ieee80211_frequency_to_channel(freq);
3107
3108 /* Check freq range */
3109 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
3110 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
3111 {
3112 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003113 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08003114 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
3115 WNI_CFG_CURRENT_CHANNEL_STAMAX);
3116 return -EINVAL;
3117 }
3118
3119 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3120
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05303121 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
3122 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08003123 {
3124 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
3125 {
3126 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003127 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08003128 return -EINVAL;
3129 }
3130 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3131 "%s: set channel to [%d] for device mode =%d",
3132 __func__, channel,pAdapter->device_mode);
3133 }
3134 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08003135 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08003136 )
3137 {
3138 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3139 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
3140 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3141
3142 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
3143 {
3144 /* Link is up then return cant set channel*/
3145 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003146 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08003147 return -EINVAL;
3148 }
3149
3150 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
3151 pHddStaCtx->conn_info.operationChannel = channel;
3152 pRoamProfile->ChannelInfo.ChannelList =
3153 &pHddStaCtx->conn_info.operationChannel;
3154 }
3155 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08003156 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08003157 )
3158 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05303159 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
3160 {
3161 if(VOS_STATUS_SUCCESS !=
3162 wlan_hdd_validate_operation_channel(pAdapter,channel))
3163 {
3164 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003165 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05303166 return -EINVAL;
3167 }
3168 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
3169 }
3170 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08003171 {
3172 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
3173
3174 /* If auto channel selection is configured as enable/ 1 then ignore
3175 channel set by supplicant
3176 */
3177 if ( cfg_param->apAutoChannelSelection )
3178 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05303179 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
3180 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08003181 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303182 "%s: set channel to auto channel (0) for device mode =%s (%d)",
3183 __func__, hdd_device_modetoString(pAdapter->device_mode),
3184 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08003185 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05303186 else
3187 {
3188 if(VOS_STATUS_SUCCESS !=
3189 wlan_hdd_validate_operation_channel(pAdapter,channel))
3190 {
3191 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003192 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05303193 return -EINVAL;
3194 }
3195 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
3196 }
Viral Modi3a32cc52013-02-08 11:14:52 -08003197 }
3198 }
3199 else
3200 {
3201 hddLog(VOS_TRACE_LEVEL_FATAL,
3202 "%s: Invalid device mode failed to set valid channel", __func__);
3203 return -EINVAL;
3204 }
3205 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303206 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08003207}
3208
Jeff Johnson295189b2012-06-20 16:38:30 -07003209#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
3210static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
3211 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003212#else
3213static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
3214 struct cfg80211_beacon_data *params,
3215 const u8 *ssid, size_t ssid_len,
3216 enum nl80211_hidden_ssid hidden_ssid)
3217#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003218{
3219 tsap_Config_t *pConfig;
3220 beacon_data_t *pBeacon = NULL;
3221 struct ieee80211_mgmt *pMgmt_frame;
3222 v_U8_t *pIe=NULL;
3223 v_U16_t capab_info;
3224 eCsrAuthType RSNAuthType;
3225 eCsrEncryptionType RSNEncryptType;
3226 eCsrEncryptionType mcRSNEncryptType;
3227 int status = VOS_STATUS_SUCCESS;
3228 tpWLAN_SAPEventCB pSapEventCallback;
3229 hdd_hostapd_state_t *pHostapdState;
3230 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
3231 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05303232 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05303234 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003235 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003236 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Chet Lanctot40142442014-05-20 13:39:25 -07003237 v_BOOL_t MFPCapable = VOS_FALSE;
3238 v_BOOL_t MFPRequired = VOS_FALSE;
Abhishek Singhf0ac1752014-03-05 17:47:09 +05303239 eHddDot11Mode sapDot11Mode =
3240 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003241
3242 ENTER();
3243
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05303244 iniConfig = pHddCtx->cfg_ini;
3245
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3247
3248 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
3249
3250 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
3251
3252 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
3253
3254 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
3255
3256 //channel is already set in the set_channel Call back
3257 //pConfig->channel = pCommitConfig->channel;
3258
3259 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303260 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
3262
3263 pConfig->dtim_period = pBeacon->dtim_period;
3264
Arif Hussain6d2a3322013-11-17 19:50:10 -08003265 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 pConfig->dtim_period);
3267
3268
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08003269 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07003270 {
3271 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05303273 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
3274 {
3275 tANI_BOOLEAN restartNeeded;
3276 pConfig->ieee80211d = 1;
3277 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
3278 sme_setRegInfo(hHal, pConfig->countryCode);
3279 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
3280 }
3281 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003283 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003284 pConfig->ieee80211d = 1;
3285 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
3286 sme_setRegInfo(hHal, pConfig->countryCode);
3287 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07003289 else
3290 {
3291 pConfig->ieee80211d = 0;
3292 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05303293 /*
3294 * If auto channel is configured i.e. channel is 0,
3295 * so skip channel validation.
3296 */
3297 if( AUTO_CHANNEL_SELECT != pConfig->channel )
3298 {
3299 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
3300 {
3301 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003302 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05303303 return -EINVAL;
3304 }
3305 }
3306 else
3307 {
3308 if(1 != pHddCtx->is_dynamic_channel_range_set)
3309 {
3310 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
3311 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
3312 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
3313 }
3314 pHddCtx->is_dynamic_channel_range_set = 0;
3315 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07003317 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 {
3319 pConfig->ieee80211d = 0;
3320 }
3321 pConfig->authType = eSAP_AUTO_SWITCH;
3322
3323 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303324
3325 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
3327
3328 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
3329
3330 /*Set wps station to configured*/
3331 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
3332
3333 if(pIe)
3334 {
3335 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
3336 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003337 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 return -EINVAL;
3339 }
3340 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
3341 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003342 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 /* Check 15 bit of WPS IE as it contain information for wps state
3344 * WPS state
3345 */
3346 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
3347 {
3348 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
3349 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
3350 {
3351 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
3352 }
3353 }
3354 }
3355 else
3356 {
3357 pConfig->wps_state = SAP_WPS_DISABLED;
3358 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303359 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07003360
c_hpothufe599e92014-06-16 11:38:55 +05303361 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
3362 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
3363 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
3364 eCSR_ENCRYPT_TYPE_NONE;
3365
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 pConfig->RSNWPAReqIELength = 0;
3367 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303368 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 WLAN_EID_RSN);
3370 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303371 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 pConfig->RSNWPAReqIELength = pIe[1] + 2;
3373 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
3374 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303375 /* The actual processing may eventually be more extensive than
3376 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 * by the app.
3378 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303379 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
3381 &RSNEncryptType,
3382 &mcRSNEncryptType,
3383 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08003384 &MFPCapable,
3385 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 pConfig->pRSNWPAReqIE[1]+2,
3387 pConfig->pRSNWPAReqIE );
3388
3389 if( VOS_STATUS_SUCCESS == status )
3390 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303391 /* Now copy over all the security attributes you have
3392 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07003393 * */
3394 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
3395 pConfig->mcRSNEncryptType = mcRSNEncryptType;
3396 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
3397 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303398 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003399 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
3401 }
3402 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303403
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
3405 pBeacon->tail, pBeacon->tail_len);
3406
3407 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
3408 {
3409 if (pConfig->pRSNWPAReqIE)
3410 {
3411 /*Mixed mode WPA/WPA2*/
3412 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
3413 pConfig->RSNWPAReqIELength += pIe[1] + 2;
3414 }
3415 else
3416 {
3417 pConfig->RSNWPAReqIELength = pIe[1] + 2;
3418 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
3419 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303420 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
3422 &RSNEncryptType,
3423 &mcRSNEncryptType,
3424 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08003425 &MFPCapable,
3426 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07003427 pConfig->pRSNWPAReqIE[1]+2,
3428 pConfig->pRSNWPAReqIE );
3429
3430 if( VOS_STATUS_SUCCESS == status )
3431 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303432 /* Now copy over all the security attributes you have
3433 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07003434 * */
3435 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
3436 pConfig->mcRSNEncryptType = mcRSNEncryptType;
3437 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
3438 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303439 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003440 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
3442 }
3443 }
3444 }
3445
Jeff Johnson4416a782013-03-25 14:17:50 -07003446 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
3447 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
3448 return -EINVAL;
3449 }
3450
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
3452
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003453#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 if (params->ssid != NULL)
3455 {
3456 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
3457 pConfig->SSIDinfo.ssid.length = params->ssid_len;
3458 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
3459 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
3460 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003461#else
3462 if (ssid != NULL)
3463 {
3464 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
3465 pConfig->SSIDinfo.ssid.length = ssid_len;
3466 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
3467 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
3468 }
3469#endif
3470
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303471 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303473
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 /* default value */
3475 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
3476 pConfig->num_accept_mac = 0;
3477 pConfig->num_deny_mac = 0;
3478
3479 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
3480 pBeacon->tail, pBeacon->tail_len);
3481
3482 /* pIe for black list is following form:
3483 type : 1 byte
3484 length : 1 byte
3485 OUI : 4 bytes
3486 acl type : 1 byte
3487 no of mac addr in black list: 1 byte
3488 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303489 */
3490 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 {
3492 pConfig->SapMacaddr_acl = pIe[6];
3493 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08003494 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05303496 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
3497 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
3499 for (i = 0; i < pConfig->num_deny_mac; i++)
3500 {
3501 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
3502 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 }
3505 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
3506 pBeacon->tail, pBeacon->tail_len);
3507
3508 /* pIe for white list is following form:
3509 type : 1 byte
3510 length : 1 byte
3511 OUI : 4 bytes
3512 acl type : 1 byte
3513 no of mac addr in white list: 1 byte
3514 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303515 */
3516 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07003517 {
3518 pConfig->SapMacaddr_acl = pIe[6];
3519 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08003520 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05303522 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
3523 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
3525 for (i = 0; i < pConfig->num_accept_mac; i++)
3526 {
3527 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
3528 acl_entry++;
3529 }
3530 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05303531
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 wlan_hdd_set_sapHwmode(pHostapdAdapter);
3533
Jeff Johnsone7245742012-09-05 17:12:55 -07003534#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08003535 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05303536 * This is valid only if mode is set to 11n in hostapd, either AUTO or
3537 * 11ac in .ini and 11ac is supported by both host and firmware.
3538 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
3539 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08003540 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
3541 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Abhishek Singhf0ac1752014-03-05 17:47:09 +05303542 (( sapDot11Mode == eHDD_DOT11_MODE_AUTO ) ||
3543 ( sapDot11Mode == eHDD_DOT11_MODE_11ac ) ||
3544 ( sapDot11Mode == eHDD_DOT11_MODE_11ac_ONLY ) ) &&
3545 (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
3546 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07003547 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05303548 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07003549 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05303550 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07003551
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05303552 /* If ACS disable and selected channel <= 14
3553 * OR
3554 * ACS enabled and ACS operating band is choosen as 2.4
3555 * AND
3556 * VHT in 2.4G Disabled
3557 * THEN
3558 * Fallback to 11N mode
3559 */
3560 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
3561 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Siddharth Bhalf42f8592014-05-15 13:39:07 +05303562 operatingBand == RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05303563 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07003564 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05303565 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
3566 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07003567 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
3568 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003569 }
3570#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303571
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003572 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
3573 {
3574 sme_SelectCBMode(hHal,
3575 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
3576 pConfig->channel);
3577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 // ht_capab is not what the name conveys,this is used for protection bitmap
3579 pConfig->ht_capab =
3580 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
3581
3582 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
3583 {
3584 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
3585 return -EINVAL;
3586 }
3587
3588 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303589 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
3591 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303592 pConfig->obssProtEnabled =
3593 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003594
Chet Lanctot8cecea22014-02-11 19:09:36 -08003595#ifdef WLAN_FEATURE_11W
3596 pConfig->mfpCapable = MFPCapable;
3597 pConfig->mfpRequired = MFPRequired;
3598 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
3599 pConfig->mfpCapable, pConfig->mfpRequired);
3600#endif
3601
Arif Hussain6d2a3322013-11-17 19:50:10 -08003602 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08003604 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
3605 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
3606 (int)pConfig->channel);
3607 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
3608 pConfig->SapHw_mode, pConfig->privacy,
3609 pConfig->authType);
3610 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
3611 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
3612 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
3613 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07003614
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303615 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 {
3617 //Bss already started. just return.
3618 //TODO Probably it should update some beacon params.
3619 hddLog( LOGE, "Bss Already started...Ignore the request");
3620 EXIT();
3621 return 0;
3622 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303623
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 pConfig->persona = pHostapdAdapter->device_mode;
3625
3626 pSapEventCallback = hdd_hostapd_SAPEventCB;
3627 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
3628 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
3629 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003630 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 return -EINVAL;
3632 }
3633
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303634 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003635 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
3636
3637 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303638
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303640 {
3641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003642 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07003643 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 VOS_ASSERT(0);
3645 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303646
Jeff Johnson295189b2012-06-20 16:38:30 -07003647 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
3648
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07003649#ifdef WLAN_FEATURE_P2P_DEBUG
3650 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
3651 {
3652 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
3653 {
3654 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
3655 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08003656 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07003657 }
3658 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
3659 {
3660 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
3661 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08003662 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07003663 }
3664 }
3665#endif
3666
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 pHostapdState->bCommit = TRUE;
3668 EXIT();
3669
3670 return 0;
3671}
3672
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003673#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303674static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
3675 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 struct beacon_parameters *params)
3677{
3678 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303679 hdd_context_t *pHddCtx;
3680 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003681
3682 ENTER();
3683
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303684 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3685 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
3686 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303687 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
3688 hdd_device_modetoString(pAdapter->device_mode),
3689 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003690
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303691 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3692 status = wlan_hdd_validate_context(pHddCtx);
3693
3694 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003695 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303696 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3697 "%s: HDD context is not valid", __func__);
3698 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003699 }
3700
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303701 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 )
3704 {
3705 beacon_data_t *old,*new;
3706
3707 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303708
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303710 {
3711 hddLog(VOS_TRACE_LEVEL_WARN,
3712 FL("already beacon info added to session(%d)"),
3713 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003716
3717 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
3718
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303719 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 {
3721 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003722 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 return -EINVAL;
3724 }
3725
3726 pAdapter->sessionCtx.ap.beacon = new;
3727
3728 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
3729 }
3730
3731 EXIT();
3732 return status;
3733}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303734
3735static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 struct net_device *dev,
3737 struct beacon_parameters *params)
3738{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303739 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303740 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303741 hdd_context_t *pHddCtx;
3742 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003743
3744 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303745 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3746 TRACE_CODE_HDD_CFG80211_SET_BEACON,
3747 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303748 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
3749 __func__, hdd_device_modetoString(pAdapter->device_mode),
3750 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003751
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303752 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3753 status = wlan_hdd_validate_context(pHddCtx);
3754
3755 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003756 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303757 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3758 "%s: HDD context is not valid", __func__);
3759 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003760 }
3761
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303762 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303764 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 {
3766 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303767
Jeff Johnson295189b2012-06-20 16:38:30 -07003768 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303769
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303771 {
3772 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3773 FL("session(%d) old and new heads points to NULL"),
3774 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003777
3778 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
3779
3780 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303781 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003782 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 return -EINVAL;
3784 }
3785
3786 pAdapter->sessionCtx.ap.beacon = new;
3787
3788 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
3789 }
3790
3791 EXIT();
3792 return status;
3793}
3794
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003795#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
3796
3797#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07003798static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
3799 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003800#else
3801static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
3802 struct net_device *dev)
3803#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003804{
3805 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07003806 hdd_context_t *pHddCtx = NULL;
3807 hdd_scaninfo_t *pScanInfo = NULL;
3808 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303809 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303810 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07003811
3812 ENTER();
3813
3814 if (NULL == pAdapter)
3815 {
3816 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003817 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 return -ENODEV;
3819 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003820
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303821 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3822 TRACE_CODE_HDD_CFG80211_STOP_AP,
3823 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303824 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3825 status = wlan_hdd_validate_context(pHddCtx);
3826
3827 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003828 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303829 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3830 "%s: HDD context is not valid", __func__);
3831 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07003832 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003833
3834 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
3835 if (NULL == staAdapter)
3836 {
3837 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
3838 if (NULL == staAdapter)
3839 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07003840 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3841 "%s: HDD adapter context for STA/P2P-CLI is Null",
3842 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003843 }
3844 }
3845
3846 pScanInfo = &pHddCtx->scan_info;
3847
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303848 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
3849 __func__, hdd_device_modetoString(pAdapter->device_mode),
3850 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003851
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303852 ret = wlan_hdd_scan_abort(pAdapter);
3853
Girish Gowli4bf7a632014-06-12 13:42:11 +05303854 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07003855 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303856 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3857 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303858
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303859 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07003860 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3862 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08003863
Jeff Johnsone7245742012-09-05 17:12:55 -07003864 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303865 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07003866 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303867 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07003868 }
3869
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05303870 hdd_hostapd_stop(dev);
3871
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 )
3875 {
3876 beacon_data_t *old;
3877
3878 old = pAdapter->sessionCtx.ap.beacon;
3879
3880 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303881 {
3882 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3883 FL("session(%d) beacon data points to NULL"),
3884 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003887
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003889
3890 mutex_lock(&pHddCtx->sap_lock);
3891 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
3892 {
Jeff Johnson4416a782013-03-25 14:17:50 -07003893 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 {
3895 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3896
3897 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
3898
3899 if (!VOS_IS_STATUS_SUCCESS(status))
3900 {
3901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003902 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303904 }
3905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
3907 }
3908 mutex_unlock(&pHddCtx->sap_lock);
3909
3910 if(status != VOS_STATUS_SUCCESS)
3911 {
3912 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003913 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 return -EINVAL;
3915 }
3916
Jeff Johnson4416a782013-03-25 14:17:50 -07003917 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
3919 ==eHAL_STATUS_FAILURE)
3920 {
3921 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003922 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 }
3924
Jeff Johnson4416a782013-03-25 14:17:50 -07003925 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
3927 eANI_BOOLEAN_FALSE) )
3928 {
3929 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003930 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07003931 }
3932
3933 // Reset WNI_CFG_PROBE_RSP Flags
3934 wlan_hdd_reset_prob_rspies(pAdapter);
3935
3936 pAdapter->sessionCtx.ap.beacon = NULL;
3937 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07003938#ifdef WLAN_FEATURE_P2P_DEBUG
3939 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
3940 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
3941 {
3942 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
3943 "GO got removed");
3944 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
3945 }
3946#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 }
3948 EXIT();
3949 return status;
3950}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003951
3952#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
3953
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303954static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
3955 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003956 struct cfg80211_ap_settings *params)
3957{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303958 hdd_adapter_t *pAdapter;
3959 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303960 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003961
3962 ENTER();
3963
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303964 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07003965 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303966 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303967 "%s: Device is Null", __func__);
3968 return -ENODEV;
3969 }
3970
3971 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3972 if (NULL == pAdapter)
3973 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303974 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303975 "%s: HDD adapter is Null", __func__);
3976 return -ENODEV;
3977 }
3978
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303979 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3980 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
3981 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303982 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
3983 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303984 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303985 "%s: HDD adapter magic is invalid", __func__);
3986 return -ENODEV;
3987 }
3988
3989 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303990 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303991
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303992 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303993 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303994 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3995 "%s: HDD context is not valid", __func__);
3996 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303997 }
3998
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303999 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
4000 __func__, hdd_device_modetoString(pAdapter->device_mode),
4001 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05304002
4003 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004004 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004005 )
4006 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05304007 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004008
4009 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05304010
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004011 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304012 {
4013 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4014 FL("already beacon info added to session(%d)"),
4015 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004016 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304017 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004018
4019 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
4020
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05304021 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004022 {
4023 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05304024 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004025 return -EINVAL;
4026 }
4027 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08004028#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07004029 wlan_hdd_cfg80211_set_channel(wiphy, dev,
4030#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
4031 params->channel, params->channel_type);
4032#else
4033 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
4034#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08004035#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004036 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
4037 params->ssid_len, params->hidden_ssid);
4038 }
4039
4040 EXIT();
4041 return status;
4042}
4043
4044
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304045static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004046 struct net_device *dev,
4047 struct cfg80211_beacon_data *params)
4048{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304049 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304050 hdd_context_t *pHddCtx;
4051 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004052
4053 ENTER();
4054
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304055 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4056 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
4057 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004058 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004059 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304060
4061 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4062 status = wlan_hdd_validate_context(pHddCtx);
4063
4064 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07004065 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304066 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4067 "%s: HDD context is not valid", __func__);
4068 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07004069 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004070
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304071 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004072 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304073 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004074 {
4075 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304076
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004077 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304078
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004079 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304080 {
4081 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4082 FL("session(%d) beacon data points to NULL"),
4083 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004084 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304085 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004086
4087 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
4088
4089 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304090 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004091 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004092 return -EINVAL;
4093 }
4094
4095 pAdapter->sessionCtx.ap.beacon = new;
4096
4097 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
4098 }
4099
4100 EXIT();
4101 return status;
4102}
4103
4104#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
4105
Jeff Johnson295189b2012-06-20 16:38:30 -07004106
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05304107static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 struct net_device *dev,
4109 struct bss_parameters *params)
4110{
4111 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4112
4113 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304114
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304115 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4116 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
4117 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05304118 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
4119 __func__, hdd_device_modetoString(pAdapter->device_mode),
4120 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004121
4122 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304124 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 {
4126 /* ap_isolate == -1 means that in change bss, upper layer doesn't
4127 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304128 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07004129 {
4130 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 }
4133
4134 EXIT();
4135 return 0;
4136}
4137
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05304138static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
4139 struct net_device *dev,
4140 struct bss_parameters *params)
4141{
4142 int ret;
4143
4144 vos_ssr_protect(__func__);
4145 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
4146 vos_ssr_unprotect(__func__);
4147
4148 return ret;
4149}
Kiet Lam10841362013-11-01 11:36:50 +05304150/* FUNCTION: wlan_hdd_change_country_code_cd
4151* to wait for contry code completion
4152*/
4153void* wlan_hdd_change_country_code_cb(void *pAdapter)
4154{
4155 hdd_adapter_t *call_back_pAdapter = pAdapter;
4156 complete(&call_back_pAdapter->change_country_code);
4157 return NULL;
4158}
4159
Jeff Johnson295189b2012-06-20 16:38:30 -07004160/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05304161 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
4163 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05304164int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 struct net_device *ndev,
4166 enum nl80211_iftype type,
4167 u32 *flags,
4168 struct vif_params *params
4169 )
4170{
4171 struct wireless_dev *wdev;
4172 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08004173 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07004174 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 tCsrRoamProfile *pRoamProfile = NULL;
4176 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304177 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 eMib_dot11DesiredBssType connectedBssType;
4179 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304180 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07004181
4182 ENTER();
4183
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304184 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08004185 {
4186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4187 "%s: Adapter context is null", __func__);
4188 return VOS_STATUS_E_FAILURE;
4189 }
4190
4191 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4192 if (!pHddCtx)
4193 {
4194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4195 "%s: HDD context is null", __func__);
4196 return VOS_STATUS_E_FAILURE;
4197 }
4198
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304199 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4200 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
4201 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304202 status = wlan_hdd_validate_context(pHddCtx);
4203
4204 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304206 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4207 "%s: HDD context is not valid", __func__);
4208 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 }
4210
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05304211 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
4212 __func__, hdd_device_modetoString(pAdapter->device_mode),
4213 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004214
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304215 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 wdev = ndev->ieee80211_ptr;
4217
4218#ifdef WLAN_BTAMP_FEATURE
4219 if((NL80211_IFTYPE_P2P_CLIENT == type)||
4220 (NL80211_IFTYPE_ADHOC == type)||
4221 (NL80211_IFTYPE_AP == type)||
4222 (NL80211_IFTYPE_P2P_GO == type))
4223 {
4224 pHddCtx->isAmpAllowed = VOS_FALSE;
4225 // stop AMP traffic
4226 status = WLANBAP_StopAmp();
4227 if(VOS_STATUS_SUCCESS != status )
4228 {
4229 pHddCtx->isAmpAllowed = VOS_TRUE;
4230 hddLog(VOS_TRACE_LEVEL_FATAL,
4231 "%s: Failed to stop AMP", __func__);
4232 return -EINVAL;
4233 }
4234 }
4235#endif //WLAN_BTAMP_FEATURE
4236 /* Reset the current device mode bit mask*/
4237 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
4238
4239 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07004241 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 )
4243 {
4244 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08004245 if (!pWextState)
4246 {
4247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4248 "%s: pWextState is null", __func__);
4249 return VOS_STATUS_E_FAILURE;
4250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 pRoamProfile = &pWextState->roamProfile;
4252 LastBSSType = pRoamProfile->BSSType;
4253
4254 switch (type)
4255 {
4256 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 hddLog(VOS_TRACE_LEVEL_INFO,
4259 "%s: setting interface Type to INFRASTRUCTURE", __func__);
4260 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004261#ifdef WLAN_FEATURE_11AC
4262 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
4263 {
4264 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
4265 }
4266#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304267 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07004268 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08004270 //Check for sub-string p2p to confirm its a p2p interface
4271 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304272 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08004273 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
4274 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
4275 }
4276 else
4277 {
4278 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07004279 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08004280 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05304281#ifdef FEATURE_WLAN_TDLS
4282 /* The open adapter for the p2p shall skip initializations in
4283 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
4284 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
4285 * tdls_init when the change_iface sets the device mode to
4286 * WLAN_HDD_P2P_CLIENT.
4287 */
4288
4289 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
4290 {
4291 if (0 != wlan_hdd_tdls_init (pAdapter))
4292 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304293 hddLog(VOS_TRACE_LEVEL_ERROR,
4294 "%s: tdls initialization failed", __func__);
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05304295 return -EINVAL;
4296 }
4297 }
4298#endif
4299
Jeff Johnson295189b2012-06-20 16:38:30 -07004300 break;
4301 case NL80211_IFTYPE_ADHOC:
4302 hddLog(VOS_TRACE_LEVEL_INFO,
4303 "%s: setting interface Type to ADHOC", __func__);
4304 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
4305 pRoamProfile->phyMode =
4306 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004307 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 wdev->iftype = type;
4309 break;
4310
4311 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 {
4314 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4315 "%s: setting interface Type to %s", __func__,
4316 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
4317
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08004318 //Cancel any remain on channel for GO mode
4319 if (NL80211_IFTYPE_P2P_GO == type)
4320 {
4321 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
4322 }
Mohit Khanna0f232092012-09-11 14:46:08 -07004323 if (NL80211_IFTYPE_AP == type)
4324 {
4325 /* As Loading WLAN Driver one interface being created for p2p device
4326 * address. This will take one HW STA and the max number of clients
4327 * that can connect to softAP will be reduced by one. so while changing
4328 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
4329 * interface as it is not required in SoftAP mode.
4330 */
4331
4332 // Get P2P Adapter
4333 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
4334
4335 if (pP2pAdapter)
4336 {
4337 hdd_stop_adapter(pHddCtx, pP2pAdapter);
4338 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
4339 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
4340 }
4341 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05304342 //Disable IMPS & BMPS for SAP/GO
4343 if(VOS_STATUS_E_FAILURE ==
4344 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
4345 {
4346 //Fail to Exit BMPS
4347 VOS_ASSERT(0);
4348 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304349#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07004350
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304351 /* A Mutex Lock is introduced while changing the mode to
4352 * protect the concurrent access for the Adapters by TDLS
4353 * module.
4354 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05304355 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304356#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 //De-init the adapter.
4358 hdd_stop_adapter( pHddCtx, pAdapter );
4359 hdd_deinit_adapter( pHddCtx, pAdapter );
4360 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07004361 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
4362 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304363#ifdef FEATURE_WLAN_TDLS
4364 mutex_unlock(&pHddCtx->tdls_lock);
4365#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07004366 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
4367 (pConfig->apRandomBssidEnabled))
4368 {
4369 /* To meet Android requirements create a randomized
4370 MAC address of the form 02:1A:11:Fx:xx:xx */
4371 get_random_bytes(&ndev->dev_addr[3], 3);
4372 ndev->dev_addr[0] = 0x02;
4373 ndev->dev_addr[1] = 0x1A;
4374 ndev->dev_addr[2] = 0x11;
4375 ndev->dev_addr[3] |= 0xF0;
4376 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
4377 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08004378 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
4379 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07004380 }
4381
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 hdd_set_ap_ops( pAdapter->dev );
4383
Kiet Lam10841362013-11-01 11:36:50 +05304384 /* This is for only SAP mode where users can
4385 * control country through ini.
4386 * P2P GO follows station country code
4387 * acquired during the STA scanning. */
4388 if((NL80211_IFTYPE_AP == type) &&
4389 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
4390 {
4391 int status = 0;
4392 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
4393 "%s: setting country code from INI ", __func__);
4394 init_completion(&pAdapter->change_country_code);
4395 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
4396 (void *)(tSmeChangeCountryCallback)
4397 wlan_hdd_change_country_code_cb,
4398 pConfig->apCntryCode, pAdapter,
4399 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304400 eSIR_FALSE,
4401 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05304402 if (eHAL_STATUS_SUCCESS == status)
4403 {
4404 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304405 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05304406 &pAdapter->change_country_code,
4407 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304408 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05304409 {
4410 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304411 FL("SME Timed out while setting country code %ld"),
4412 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08004413
4414 if (pHddCtx->isLogpInProgress)
4415 {
4416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4417 "%s: LOGP in Progress. Ignore!!!", __func__);
4418 return -EAGAIN;
4419 }
Kiet Lam10841362013-11-01 11:36:50 +05304420 }
4421 }
4422 else
4423 {
4424 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004425 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05304426 return -EINVAL;
4427 }
4428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 status = hdd_init_ap_mode(pAdapter);
4430 if(status != VOS_STATUS_SUCCESS)
4431 {
4432 hddLog(VOS_TRACE_LEVEL_FATAL,
4433 "%s: Error initializing the ap mode", __func__);
4434 return -EINVAL;
4435 }
4436 hdd_set_conparam(1);
4437
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 /*interface type changed update in wiphy structure*/
4439 if(wdev)
4440 {
4441 wdev->iftype = type;
4442 pHddCtx->change_iface = type;
4443 }
4444 else
4445 {
4446 hddLog(VOS_TRACE_LEVEL_ERROR,
4447 "%s: ERROR !!!! Wireless dev is NULL", __func__);
4448 return -EINVAL;
4449 }
4450 goto done;
4451 }
4452
4453 default:
4454 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
4455 __func__);
4456 return -EOPNOTSUPP;
4457 }
4458 }
4459 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 )
4462 {
4463 switch(type)
4464 {
4465 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304468#ifdef FEATURE_WLAN_TDLS
4469
4470 /* A Mutex Lock is introduced while changing the mode to
4471 * protect the concurrent access for the Adapters by TDLS
4472 * module.
4473 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05304474 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304475#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004476 hdd_stop_adapter( pHddCtx, pAdapter );
4477 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08004479 //Check for sub-string p2p to confirm its a p2p interface
4480 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08004481 {
4482 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
4483 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
4484 }
4485 else
4486 {
4487 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08004489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 hdd_set_conparam(0);
4491 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
4493 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304494#ifdef FEATURE_WLAN_TDLS
4495 mutex_unlock(&pHddCtx->tdls_lock);
4496#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05304497 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 if( VOS_STATUS_SUCCESS != status )
4499 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07004500 /* In case of JB, for P2P-GO, only change interface will be called,
4501 * This is the right place to enable back bmps_imps()
4502 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05304503 if (pHddCtx->hdd_wlan_suspended)
4504 {
4505 hdd_set_pwrparams(pHddCtx);
4506 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004507 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 goto done;
4509 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
4513 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 goto done;
4515 default:
4516 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
4517 __func__);
4518 return -EOPNOTSUPP;
4519
4520 }
4521
4522 }
4523 else
4524 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05304525 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
4526 __func__, hdd_device_modetoString(pAdapter->device_mode),
4527 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 return -EOPNOTSUPP;
4529 }
4530
4531
4532 if(pRoamProfile)
4533 {
4534 if ( LastBSSType != pRoamProfile->BSSType )
4535 {
4536 /*interface type changed update in wiphy structure*/
4537 wdev->iftype = type;
4538
4539 /*the BSS mode changed, We need to issue disconnect
4540 if connected or in IBSS disconnect state*/
4541 if ( hdd_connGetConnectedBssType(
4542 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
4543 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
4544 {
4545 /*need to issue a disconnect to CSR.*/
4546 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4547 if( eHAL_STATUS_SUCCESS ==
4548 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
4549 pAdapter->sessionId,
4550 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
4551 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304552 ret = wait_for_completion_interruptible_timeout(
4553 &pAdapter->disconnect_comp_var,
4554 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4555 if (ret <= 0)
4556 {
4557 hddLog(VOS_TRACE_LEVEL_ERROR,
4558 FL("wait on disconnect_comp_var failed %ld"), ret);
4559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 }
4561 }
4562 }
4563 }
4564
4565done:
4566 /*set bitmask based on updated value*/
4567 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07004568
4569 /* Only STA mode support TM now
4570 * all other mode, TM feature should be disabled */
4571 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
4572 (~VOS_STA & pHddCtx->concurrency_mode) )
4573 {
4574 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
4575 }
4576
Jeff Johnson295189b2012-06-20 16:38:30 -07004577#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304578 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
4580 {
4581 //we are ok to do AMP
4582 pHddCtx->isAmpAllowed = VOS_TRUE;
4583 }
4584#endif //WLAN_BTAMP_FEATURE
4585 EXIT();
4586 return 0;
4587}
4588
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05304589/*
4590 * FUNCTION: wlan_hdd_cfg80211_change_iface
4591 * wrapper function to protect the actual implementation from SSR.
4592 */
4593int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
4594 struct net_device *ndev,
4595 enum nl80211_iftype type,
4596 u32 *flags,
4597 struct vif_params *params
4598 )
4599{
4600 int ret;
4601
4602 vos_ssr_protect(__func__);
4603 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
4604 vos_ssr_unprotect(__func__);
4605
4606 return ret;
4607}
4608
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004609#ifdef FEATURE_WLAN_TDLS
4610static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
4611 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
4612{
4613 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4614 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4615 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004616 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304617 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05304618 tANI_U16 numCurrTdlsPeers;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004619
4620 ENTER();
4621
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05304622 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004623 {
4624 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4625 "Invalid arguments");
4626 return -EINVAL;
4627 }
Hoonki Lee27511902013-03-14 18:19:06 -07004628
4629 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
4630 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
4631 {
4632 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4633 "%s: TDLS mode is disabled OR not enabled in FW."
4634 MAC_ADDRESS_STR " Request declined.",
4635 __func__, MAC_ADDR_ARRAY(mac));
4636 return -ENOTSUPP;
4637 }
4638
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004639 if (pHddCtx->isLogpInProgress)
4640 {
4641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4642 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07004643 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004644 return -EBUSY;
4645 }
4646
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05304647 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004648
4649 if ( NULL == pTdlsPeer ) {
4650 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4651 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
4652 __func__, MAC_ADDR_ARRAY(mac), update);
4653 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07004654 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004655
4656 /* in add station, we accept existing valid staId if there is */
4657 if ((0 == update) &&
4658 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
4659 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004660 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004661 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004662 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004663 " link_status %d. staId %d. add station ignored.",
4664 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
4665 return 0;
4666 }
4667 /* in change station, we accept only when staId is valid */
4668 if ((1 == update) &&
4669 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
4670 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
4671 {
4672 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4673 "%s: " MAC_ADDRESS_STR
4674 " link status %d. staId %d. change station %s.",
4675 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
4676 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
4677 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004678 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07004679
4680 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304681 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004682 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07004683 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4684 "%s: " MAC_ADDRESS_STR
4685 " TDLS setup is ongoing. Request declined.",
4686 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07004687 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004688 }
4689
4690 /* first to check if we reached to maximum supported TDLS peer.
4691 TODO: for now, return -EPERM looks working fine,
4692 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05304693 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
4694 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004695 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07004696 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4697 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05304698 " TDLS Max peer already connected. Request declined."
4699 " Num of peers (%d), Max allowed (%d).",
4700 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
4701 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07004702 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004703 }
4704 else
4705 {
4706 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304707 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004708 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004709 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07004710 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4711 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
4712 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004713 return -EPERM;
4714 }
4715 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004716 if (0 == update)
4717 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004718
Jeff Johnsond75fe012013-04-06 10:53:06 -07004719 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05304720 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004721 {
4722 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4723 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07004724 if(StaParams->htcap_present)
4725 {
4726 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4727 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
4728 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4729 "ht_capa->extended_capabilities: %0x",
4730 StaParams->HTCap.extendedHtCapInfo);
4731 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004732 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4733 "params->capability: %0x",StaParams->capability);
4734 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004735 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07004736 if(StaParams->vhtcap_present)
4737 {
4738 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4739 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
4740 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
4741 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
4742 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004743 {
4744 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004745 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004746 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
4747 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4748 "[%d]: %x ", i, StaParams->supported_rates[i]);
4749 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07004750 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05304751 else if ((1 == update) && (NULL == StaParams))
4752 {
4753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4754 "%s : update is true, but staParams is NULL. Error!", __func__);
4755 return -EPERM;
4756 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004757
4758 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
4759
4760 if (!update)
4761 {
4762 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
4763 pAdapter->sessionId, mac);
4764 }
4765 else
4766 {
4767 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
4768 pAdapter->sessionId, mac, StaParams);
4769 }
4770
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304771 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004772 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
4773
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304774 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004775 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07004776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304777 "%s: timeout waiting for tdls add station indication %ld",
4778 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07004779 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004780 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304781
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004782 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
4783 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07004784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004785 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07004786 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004787 }
4788
4789 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07004790
4791error:
4792 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
4793 return -EPERM;
4794
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004795}
4796#endif
4797
Jeff Johnson295189b2012-06-20 16:38:30 -07004798static int wlan_hdd_change_station(struct wiphy *wiphy,
4799 struct net_device *dev,
4800 u8 *mac,
4801 struct station_parameters *params)
4802{
4803 VOS_STATUS status = VOS_STATUS_SUCCESS;
4804 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05304805 hdd_context_t *pHddCtx;
4806 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004807 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07004808#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004809 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004810 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05304811 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07004812#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07004813 ENTER();
4814
Gopichand Nakkala29149562013-05-10 21:43:41 +05304815 if ((NULL == pAdapter))
4816 {
4817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4818 "invalid adapter ");
4819 return -EINVAL;
4820 }
4821
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304822 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4823 TRACE_CODE_HDD_CHANGE_STATION,
4824 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05304825 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4826 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4827
4828 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
4829 {
4830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4831 "invalid HDD state or HDD station context");
4832 return -EINVAL;
4833 }
4834
4835 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004836 {
4837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4838 "%s:LOGP in Progress. Ignore!!!", __func__);
4839 return -EAGAIN;
4840 }
4841
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
4843
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004844 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
4845 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07004846 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004847 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304849 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07004850 WLANTL_STA_AUTHENTICATED);
4851
Gopichand Nakkala29149562013-05-10 21:43:41 +05304852 if (status != VOS_STATUS_SUCCESS)
4853 {
4854 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4855 "%s: Not able to change TL state to AUTHENTICATED", __func__);
4856 return -EINVAL;
4857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 }
4859 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07004860 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
4861 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05304862#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004863 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
4864 StaParams.capability = params->capability;
4865 StaParams.uapsd_queues = params->uapsd_queues;
4866 StaParams.max_sp = params->max_sp;
4867
Naresh Jayaram3180aa42014-02-12 21:47:26 +05304868 /* Convert (first channel , number of channels) tuple to
4869 * the total list of channels. This goes with the assumption
4870 * that if the first channel is < 14, then the next channels
4871 * are an incremental of 1 else an incremental of 4 till the number
4872 * of channels.
4873 */
4874 if (0 != params->supported_channels_len) {
4875 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
4876 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
4877 {
4878 int wifi_chan_index;
4879 StaParams.supported_channels[j] = params->supported_channels[i];
4880 wifi_chan_index =
4881 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
4882 no_of_channels = params->supported_channels[i+1];
4883 for(k=1; k <= no_of_channels; k++)
4884 {
4885 StaParams.supported_channels[j+1] =
4886 StaParams.supported_channels[j] + wifi_chan_index;
4887 j+=1;
4888 }
4889 }
4890 StaParams.supported_channels_len = j;
4891 }
4892 vos_mem_copy(StaParams.supported_oper_classes,
4893 params->supported_oper_classes,
4894 params->supported_oper_classes_len);
4895 StaParams.supported_oper_classes_len =
4896 params->supported_oper_classes_len;
4897
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004898 if (0 != params->ext_capab_len)
4899 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
4900 sizeof(StaParams.extn_capability));
4901
4902 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07004903 {
4904 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004905 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07004906 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004907
4908 StaParams.supported_rates_len = params->supported_rates_len;
4909
4910 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
4911 * The supported_rates array , for all the structures propogating till Add Sta
4912 * to the firmware has to be modified , if the supplicant (ieee80211) is
4913 * modified to send more rates.
4914 */
4915
4916 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
4917 */
4918 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
4919 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
4920
4921 if (0 != StaParams.supported_rates_len) {
4922 int i = 0;
4923 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
4924 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004925 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004926 "Supported Rates with Length %d", StaParams.supported_rates_len);
4927 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004928 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004929 "[%d]: %0x", i, StaParams.supported_rates[i]);
4930 }
4931
4932 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07004933 {
4934 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004935 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07004936 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004937
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004938 if (0 != params->ext_capab_len ) {
4939 /*Define A Macro : TODO Sunil*/
4940 if ((1<<4) & StaParams.extn_capability[3]) {
4941 isBufSta = 1;
4942 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05304943 /* TDLS Channel Switching Support */
4944 if ((1<<6) & StaParams.extn_capability[3]) {
4945 isOffChannelSupported = 1;
4946 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004947 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05304948 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
4949 &StaParams, isBufSta,
4950 isOffChannelSupported);
4951
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05304952 if (VOS_STATUS_SUCCESS != status) {
4953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4954 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
4955 return -EINVAL;
4956 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004957 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
4958
4959 if (VOS_STATUS_SUCCESS != status) {
4960 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4961 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
4962 return -EINVAL;
4963 }
4964 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07004965#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05304966 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004967 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 return status;
4969}
4970
4971/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05304972 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 * This function is used to initialize the key information
4974 */
4975#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05304976static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 struct net_device *ndev,
4978 u8 key_index, bool pairwise,
4979 const u8 *mac_addr,
4980 struct key_params *params
4981 )
4982#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05304983static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 struct net_device *ndev,
4985 u8 key_index, const u8 *mac_addr,
4986 struct key_params *params
4987 )
4988#endif
4989{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07004990 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 tCsrRoamSetKey setKey;
4992 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304993 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07004994 v_U32_t roamId= 0xFF;
4995 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 hdd_hostapd_state_t *pHostapdState;
4997 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07004998 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304999 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005000
5001 ENTER();
5002
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305003 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5004 TRACE_CODE_HDD_CFG80211_ADD_KEY,
5005 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305006 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5007 status = wlan_hdd_validate_context(pHddCtx);
5008
5009 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005010 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305011 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5012 "%s: HDD context is not valid", __func__);
5013 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005014 }
5015
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305016 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
5017 __func__, hdd_device_modetoString(pAdapter->device_mode),
5018 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005019
5020 if (CSR_MAX_NUM_KEY <= key_index)
5021 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005022 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005023 key_index);
5024
5025 return -EINVAL;
5026 }
5027
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005028 if (CSR_MAX_KEY_LEN < params->key_len)
5029 {
5030 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
5031 params->key_len);
5032
5033 return -EINVAL;
5034 }
5035
5036 hddLog(VOS_TRACE_LEVEL_INFO,
5037 "%s: called with key index = %d & key length %d",
5038 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005039
5040 /*extract key idx, key len and key*/
5041 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5042 setKey.keyId = key_index;
5043 setKey.keyLength = params->key_len;
5044 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
5045
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005046 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 {
5048 case WLAN_CIPHER_SUITE_WEP40:
5049 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5050 break;
5051
5052 case WLAN_CIPHER_SUITE_WEP104:
5053 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5054 break;
5055
5056 case WLAN_CIPHER_SUITE_TKIP:
5057 {
5058 u8 *pKey = &setKey.Key[0];
5059 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5060
5061 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5062
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005063 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07005064
5065 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005066 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 |--------------|----------|----------|
5068 <---16bytes---><--8bytes--><--8bytes-->
5069
5070 */
5071 /*Sme expects the 32 bytes key to be in the below order
5072
5073 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005074 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07005075 |--------------|----------|----------|
5076 <---16bytes---><--8bytes--><--8bytes-->
5077 */
5078 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005079 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07005080
5081 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005082 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07005083
5084 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005085 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07005086
5087
5088 break;
5089 }
5090
5091 case WLAN_CIPHER_SUITE_CCMP:
5092 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5093 break;
5094
5095#ifdef FEATURE_WLAN_WAPI
5096 case WLAN_CIPHER_SUITE_SMS4:
5097 {
5098 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5099 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
5100 params->key, params->key_len);
5101 return 0;
5102 }
5103#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005105#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005106 case WLAN_CIPHER_SUITE_KRK:
5107 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5108 break;
5109#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005110
5111#ifdef WLAN_FEATURE_11W
5112 case WLAN_CIPHER_SUITE_AES_CMAC:
5113 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07005114 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07005115#endif
5116
Jeff Johnson295189b2012-06-20 16:38:30 -07005117 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005118 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 __func__, params->cipher);
5120 return -EOPNOTSUPP;
5121 }
5122
5123 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
5124 __func__, setKey.encType);
5125
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005126 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07005127#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5128 (!pairwise)
5129#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005130 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07005131#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005132 )
5133 {
5134 /* set group key*/
5135 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5136 "%s- %d: setting Broadcast key",
5137 __func__, __LINE__);
5138 setKey.keyDirection = eSIR_RX_ONLY;
5139 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5140 }
5141 else
5142 {
5143 /* set pairwise key*/
5144 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5145 "%s- %d: setting pairwise key",
5146 __func__, __LINE__);
5147 setKey.keyDirection = eSIR_TX_RX;
5148 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
5149 }
5150 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
5151 {
5152 setKey.keyDirection = eSIR_TX_RX;
5153 /*Set the group key*/
5154 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
5155 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005156
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005157 if ( 0 != status )
5158 {
5159 hddLog(VOS_TRACE_LEVEL_ERROR,
5160 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
5161 return -EINVAL;
5162 }
5163 /*Save the keys here and call sme_RoamSetKey for setting
5164 the PTK after peer joins the IBSS network*/
5165 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
5166 &setKey, sizeof(tCsrRoamSetKey));
5167 return status;
5168 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05305169 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
5170 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
5171 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005172 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005173 if( pHostapdState->bssState == BSS_START )
5174 {
c_hpothu7c55da62014-01-23 18:34:02 +05305175 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5176 vos_status = wlan_hdd_check_ula_done(pAdapter);
5177
5178 if ( vos_status != VOS_STATUS_SUCCESS )
5179 {
5180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5181 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5182 __LINE__, vos_status );
5183
5184 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5185
5186 return -EINVAL;
5187 }
5188
Jeff Johnson295189b2012-06-20 16:38:30 -07005189 status = WLANSAP_SetKeySta( pVosContext, &setKey);
5190
5191 if ( status != eHAL_STATUS_SUCCESS )
5192 {
5193 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5194 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
5195 __LINE__, status );
5196 }
5197 }
5198
5199 /* Saving WEP keys */
5200 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
5201 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
5202 {
5203 //Save the wep key in ap context. Issue setkey after the BSS is started.
5204 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5205 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
5206 }
5207 else
5208 {
5209 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005210 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
5212 }
5213 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005214 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
5215 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 {
5217 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5218 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5219
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305220#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5221 if (!pairwise)
5222#else
5223 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
5224#endif
5225 {
5226 /* set group key*/
5227 if (pHddStaCtx->roam_info.deferKeyComplete)
5228 {
5229 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5230 "%s- %d: Perform Set key Complete",
5231 __func__, __LINE__);
5232 hdd_PerformRoamSetKeyComplete(pAdapter);
5233 }
5234 }
5235
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
5237
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08005238 pWextState->roamProfile.Keys.defaultIndex = key_index;
5239
5240
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005241 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07005242 params->key, params->key_len);
5243
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305244
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5246
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305247 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305249 __func__, setKey.peerMac[0], setKey.peerMac[1],
5250 setKey.peerMac[2], setKey.peerMac[3],
5251 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07005252 setKey.keyDirection);
5253
5254 vos_status = wlan_hdd_check_ula_done(pAdapter);
5255
5256 if ( vos_status != VOS_STATUS_SUCCESS )
5257 {
5258 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5259 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5260 __LINE__, vos_status );
5261
5262 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5263
5264 return -EINVAL;
5265
5266 }
5267
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005268#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305269 /* The supplicant may attempt to set the PTK once pre-authentication
5270 is done. Save the key in the UMAC and include it in the ADD BSS
5271 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005272 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305273 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005274 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305275 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5276 "%s: Update PreAuth Key success", __func__);
5277 return 0;
5278 }
5279 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5280 {
5281 hddLog(VOS_TRACE_LEVEL_ERROR,
5282 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05305283 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005284 }
5285#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07005286
5287 /* issue set key request to SME*/
5288 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
5289 pAdapter->sessionId, &setKey, &roamId );
5290
5291 if ( 0 != status )
5292 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305293 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
5295 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5296 return -EINVAL;
5297 }
5298
5299
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305300 /* in case of IBSS as there was no information available about WEP keys during
5301 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305303 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
5304 !( ( IW_AUTH_KEY_MGMT_802_1X
5305 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07005306 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
5307 )
5308 &&
5309 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
5310 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
5311 )
5312 )
5313 {
5314 setKey.keyDirection = eSIR_RX_ONLY;
5315 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5316
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305317 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07005318 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305319 __func__, setKey.peerMac[0], setKey.peerMac[1],
5320 setKey.peerMac[2], setKey.peerMac[3],
5321 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07005322 setKey.keyDirection);
5323
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305324 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 pAdapter->sessionId, &setKey, &roamId );
5326
5327 if ( 0 != status )
5328 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305329 hddLog(VOS_TRACE_LEVEL_ERROR,
5330 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 __func__, status);
5332 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5333 return -EINVAL;
5334 }
5335 }
5336 }
5337
5338 return 0;
5339}
5340
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05305341#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5342static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
5343 struct net_device *ndev,
5344 u8 key_index, bool pairwise,
5345 const u8 *mac_addr,
5346 struct key_params *params
5347 )
5348#else
5349static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
5350 struct net_device *ndev,
5351 u8 key_index, const u8 *mac_addr,
5352 struct key_params *params
5353 )
5354#endif
5355{
5356 int ret;
5357 vos_ssr_protect(__func__);
5358#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5359 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
5360 mac_addr, params);
5361#else
5362 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
5363 params);
5364#endif
5365 vos_ssr_unprotect(__func__);
5366
5367 return ret;
5368}
5369
Jeff Johnson295189b2012-06-20 16:38:30 -07005370/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05305371 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 * This function is used to get the key information
5373 */
5374#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05305375static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305376 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005377 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305378 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 const u8 *mac_addr, void *cookie,
5380 void (*callback)(void *cookie, struct key_params*)
5381 )
5382#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05305383static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305384 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 struct net_device *ndev,
5386 u8 key_index, const u8 *mac_addr, void *cookie,
5387 void (*callback)(void *cookie, struct key_params*)
5388 )
5389#endif
5390{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305391 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5393 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5394 struct key_params params;
5395
5396 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305397
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305398 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
5399 __func__, hdd_device_modetoString(pAdapter->device_mode),
5400 pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305401
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 memset(&params, 0, sizeof(params));
5403
5404 if (CSR_MAX_NUM_KEY <= key_index)
5405 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305406 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07005407 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305408 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005409
5410 switch(pRoamProfile->EncryptionType.encryptionType[0])
5411 {
5412 case eCSR_ENCRYPT_TYPE_NONE:
5413 params.cipher = IW_AUTH_CIPHER_NONE;
5414 break;
5415
5416 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5417 case eCSR_ENCRYPT_TYPE_WEP40:
5418 params.cipher = WLAN_CIPHER_SUITE_WEP40;
5419 break;
5420
5421 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5422 case eCSR_ENCRYPT_TYPE_WEP104:
5423 params.cipher = WLAN_CIPHER_SUITE_WEP104;
5424 break;
5425
5426 case eCSR_ENCRYPT_TYPE_TKIP:
5427 params.cipher = WLAN_CIPHER_SUITE_TKIP;
5428 break;
5429
5430 case eCSR_ENCRYPT_TYPE_AES:
5431 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
5432 break;
5433
5434 default:
5435 params.cipher = IW_AUTH_CIPHER_NONE;
5436 break;
5437 }
5438
c_hpothuaaf19692014-05-17 17:01:48 +05305439 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5440 TRACE_CODE_HDD_CFG80211_GET_KEY,
5441 pAdapter->sessionId, params.cipher));
5442
Jeff Johnson295189b2012-06-20 16:38:30 -07005443 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
5444 params.seq_len = 0;
5445 params.seq = NULL;
5446 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
5447 callback(cookie, &params);
5448 return 0;
5449}
5450
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05305451#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5452static int wlan_hdd_cfg80211_get_key(
5453 struct wiphy *wiphy,
5454 struct net_device *ndev,
5455 u8 key_index, bool pairwise,
5456 const u8 *mac_addr, void *cookie,
5457 void (*callback)(void *cookie, struct key_params*)
5458 )
5459#else
5460static int wlan_hdd_cfg80211_get_key(
5461 struct wiphy *wiphy,
5462 struct net_device *ndev,
5463 u8 key_index, const u8 *mac_addr, void *cookie,
5464 void (*callback)(void *cookie, struct key_params*)
5465 )
5466#endif
5467{
5468 int ret;
5469
5470 vos_ssr_protect(__func__);
5471#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5472 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
5473 mac_addr, cookie, callback);
5474#else
5475 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
5476 callback);
5477#endif
5478 vos_ssr_unprotect(__func__);
5479
5480 return ret;
5481}
5482
Jeff Johnson295189b2012-06-20 16:38:30 -07005483/*
5484 * FUNCTION: wlan_hdd_cfg80211_del_key
5485 * This function is used to delete the key information
5486 */
5487#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305488static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305490 u8 key_index,
5491 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 const u8 *mac_addr
5493 )
5494#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305495static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 struct net_device *ndev,
5497 u8 key_index,
5498 const u8 *mac_addr
5499 )
5500#endif
5501{
5502 int status = 0;
5503
5504 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305505 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07005506 //it is observed that this is invalidating peer
5507 //key index whenever re-key is done. This is affecting data link.
5508 //It should be ok to ignore del_key.
5509#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305510 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
5511 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07005512 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5513 tCsrRoamSetKey setKey;
5514 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305515
Jeff Johnson295189b2012-06-20 16:38:30 -07005516 ENTER();
5517
5518 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
5519 __func__,pAdapter->device_mode);
5520
5521 if (CSR_MAX_NUM_KEY <= key_index)
5522 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305523 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 key_index);
5525
5526 return -EINVAL;
5527 }
5528
5529 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5530 setKey.keyId = key_index;
5531
5532 if (mac_addr)
5533 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
5534 else
5535 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
5536
5537 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5538
5539 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305541 )
5542 {
5543
5544 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
5546 if( pHostapdState->bssState == BSS_START)
5547 {
5548 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305549
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 if ( status != eHAL_STATUS_SUCCESS )
5551 {
5552 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5553 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
5554 __LINE__, status );
5555 }
5556 }
5557 }
5558 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305559 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07005560 )
5561 {
5562 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5563
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305564 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5565
5566 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305568 __func__, setKey.peerMac[0], setKey.peerMac[1],
5569 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305571 if(pAdapter->sessionCtx.station.conn_info.connState ==
5572 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305574 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005575 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305576
Jeff Johnson295189b2012-06-20 16:38:30 -07005577 if ( 0 != status )
5578 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305579 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 "%s: sme_RoamSetKey failure, returned %d",
5581 __func__, status);
5582 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5583 return -EINVAL;
5584 }
5585 }
5586 }
5587#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07005588 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 return status;
5590}
5591
5592/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05305593 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 * This function is used to set the default tx key index
5595 */
5596#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05305597static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 struct net_device *ndev,
5599 u8 key_index,
5600 bool unicast, bool multicast)
5601#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05305602static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 struct net_device *ndev,
5604 u8 key_index)
5605#endif
5606{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305607 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305608 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05305609 hdd_wext_state_t *pWextState;
5610 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305611 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005612
5613 ENTER();
5614
Gopichand Nakkala29149562013-05-10 21:43:41 +05305615 if ((NULL == pAdapter))
5616 {
5617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5618 "invalid adapter");
5619 return -EINVAL;
5620 }
5621
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305622 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5623 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
5624 pAdapter->sessionId, key_index));
5625
Gopichand Nakkala29149562013-05-10 21:43:41 +05305626 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5627 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5628
5629 if ((NULL == pWextState) || (NULL == pHddStaCtx))
5630 {
5631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5632 "invalid Wext state or HDD context");
5633 return -EINVAL;
5634 }
5635
Arif Hussain6d2a3322013-11-17 19:50:10 -08005636 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305638
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 if (CSR_MAX_NUM_KEY <= key_index)
5640 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305641 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 key_index);
5643
5644 return -EINVAL;
5645 }
5646
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305647 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5648 status = wlan_hdd_validate_context(pHddCtx);
5649
5650 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005651 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305652 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5653 "%s: HDD context is not valid", __func__);
5654 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005655 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305656
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305659 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05305661 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08005662 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305663 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08005664 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305666 {
5667 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305669
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 tCsrRoamSetKey setKey;
5671 v_U32_t roamId= 0xFF;
5672 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305673
5674 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005675 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305676
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 Keys->defaultIndex = (u8)key_index;
5678 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5679 setKey.keyId = key_index;
5680 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305681
5682 vos_mem_copy(&setKey.Key[0],
5683 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305685
Gopichand Nakkala29149562013-05-10 21:43:41 +05305686 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305687
5688 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 &pHddStaCtx->conn_info.bssId[0],
5690 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305691
Gopichand Nakkala29149562013-05-10 21:43:41 +05305692 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
5693 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
5694 eCSR_ENCRYPT_TYPE_WEP104)
5695 {
5696 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
5697 even though ap is configured for WEP-40 encryption. In this canse the key length
5698 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
5699 type(104) and switching encryption type to 40*/
5700 pWextState->roamProfile.EncryptionType.encryptionType[0] =
5701 eCSR_ENCRYPT_TYPE_WEP40;
5702 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5703 eCSR_ENCRYPT_TYPE_WEP40;
5704 }
5705
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305706 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07005707 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305708
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305710 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305712
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 if ( 0 != status )
5714 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305715 hddLog(VOS_TRACE_LEVEL_ERROR,
5716 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 status);
5718 return -EINVAL;
5719 }
5720 }
5721 }
5722
5723 /* In SoftAp mode setting key direction for default mode */
5724 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
5725 {
5726 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
5727 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
5728 (eCSR_ENCRYPT_TYPE_AES !=
5729 pWextState->roamProfile.EncryptionType.encryptionType[0])
5730 )
5731 {
5732 /* Saving key direction for default key index to TX default */
5733 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5734 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
5735 }
5736 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305737
Jeff Johnson295189b2012-06-20 16:38:30 -07005738 return status;
5739}
5740
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05305741#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5742static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
5743 struct net_device *ndev,
5744 u8 key_index,
5745 bool unicast, bool multicast)
5746#else
5747static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
5748 struct net_device *ndev,
5749 u8 key_index)
5750#endif
5751{
5752 int ret;
5753 vos_ssr_protect(__func__);
5754#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5755 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
5756 multicast);
5757#else
5758 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
5759#endif
5760 vos_ssr_unprotect(__func__);
5761
5762 return ret;
5763}
5764
Jeff Johnson295189b2012-06-20 16:38:30 -07005765/*
5766 * FUNCTION: wlan_hdd_cfg80211_inform_bss
5767 * This function is used to inform the BSS details to nl80211 interface.
5768 */
5769static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
5770 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
5771{
5772 struct net_device *dev = pAdapter->dev;
5773 struct wireless_dev *wdev = dev->ieee80211_ptr;
5774 struct wiphy *wiphy = wdev->wiphy;
5775 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
5776 int chan_no;
5777 int ie_length;
5778 const char *ie;
5779 unsigned int freq;
5780 struct ieee80211_channel *chan;
5781 int rssi = 0;
5782 struct cfg80211_bss *bss = NULL;
5783
5784 ENTER();
5785
5786 if( NULL == pBssDesc )
5787 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005788 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 return bss;
5790 }
5791
5792 chan_no = pBssDesc->channelId;
5793 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
5794 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
5795
5796 if( NULL == ie )
5797 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005798 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 return bss;
5800 }
5801
5802#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
5803 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
5804 {
5805 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
5806 }
5807 else
5808 {
5809 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
5810 }
5811#else
5812 freq = ieee80211_channel_to_frequency(chan_no);
5813#endif
5814
5815 chan = __ieee80211_get_channel(wiphy, freq);
5816
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05305817 if (!chan) {
5818 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
5819 return NULL;
5820 }
5821
Abhishek Singhaee43942014-06-16 18:55:47 +05305822 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07005823
Abhishek Singhaee43942014-06-16 18:55:47 +05305824 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305825 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 pBssDesc->capabilityInfo,
5827 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05305828 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07005829}
5830
5831
5832
5833/*
5834 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
5835 * This function is used to inform the BSS details to nl80211 interface.
5836 */
5837struct cfg80211_bss*
5838wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
5839 tSirBssDescription *bss_desc
5840 )
5841{
5842 /*
5843 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
5844 already exists in bss data base of cfg80211 for that particular BSS ID.
5845 Using cfg80211_inform_bss_frame to update the bss entry instead of
5846 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
5847 now there is no possibility to get the mgmt(probe response) frame from PE,
5848 converting bss_desc to ieee80211_mgmt(probe response) and passing to
5849 cfg80211_inform_bss_frame.
5850 */
5851 struct net_device *dev = pAdapter->dev;
5852 struct wireless_dev *wdev = dev->ieee80211_ptr;
5853 struct wiphy *wiphy = wdev->wiphy;
5854 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08005855#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
5856 qcom_ie_age *qie_age = NULL;
5857 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
5858#else
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08005860#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 const char *ie =
5862 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
5863 unsigned int freq;
5864 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05305865 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 struct cfg80211_bss *bss_status = NULL;
5867 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
5868 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07005869 hdd_context_t *pHddCtx;
5870 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07005871#ifdef WLAN_OPEN_SOURCE
5872 struct timespec ts;
5873#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005874
Wilson Yangf80a0542013-10-07 13:02:37 -07005875 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5876 status = wlan_hdd_validate_context(pHddCtx);
5877
5878 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05305879 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07005880 {
5881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5882 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
5883 return NULL;
5884 }
5885
5886
5887 if (0 != status)
5888 {
5889 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5890 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07005891 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07005892 }
5893
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05305894 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07005895 if (!mgmt)
5896 {
5897 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5898 "%s: memory allocation failed ", __func__);
5899 return NULL;
5900 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07005901
Jeff Johnson295189b2012-06-20 16:38:30 -07005902 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07005903
5904#ifdef WLAN_OPEN_SOURCE
5905 /* Android does not want the timestamp from the frame.
5906 Instead it wants a monotonic increasing value */
5907 get_monotonic_boottime(&ts);
5908 mgmt->u.probe_resp.timestamp =
5909 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
5910#else
5911 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
5913 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07005914
5915#endif
5916
Jeff Johnson295189b2012-06-20 16:38:30 -07005917 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
5918 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08005919
5920#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
5921 /* GPS Requirement: need age ie per entry. Using vendor specific. */
5922 /* Assuming this is the last IE, copy at the end */
5923 ie_length -=sizeof(qcom_ie_age);
5924 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
5925 qie_age->element_id = QCOM_VENDOR_IE_ID;
5926 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
5927 qie_age->oui_1 = QCOM_OUI1;
5928 qie_age->oui_2 = QCOM_OUI2;
5929 qie_age->oui_3 = QCOM_OUI3;
5930 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
5931 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
5932#endif
5933
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05305935 if (bss_desc->fProbeRsp)
5936 {
5937 mgmt->frame_control |=
5938 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
5939 }
5940 else
5941 {
5942 mgmt->frame_control |=
5943 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
5944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005945
5946#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305947 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
5949 {
5950 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
5951 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305952 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
5954
5955 {
5956 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
5957 }
5958 else
5959 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305960 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
5961 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 kfree(mgmt);
5963 return NULL;
5964 }
5965#else
5966 freq = ieee80211_channel_to_frequency(chan_no);
5967#endif
5968 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08005969 /*when the band is changed on the fly using the GUI, three things are done
5970 * 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)
5971 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
5972 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
5973 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
5974 * and discards the channels correponding to previous band and calls back with zero bss results.
5975 * 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
5976 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
5977 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
5978 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
5979 * So drop the bss and continue to next bss.
5980 */
5981 if(chan == NULL)
5982 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305983 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07005984 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08005985 return NULL;
5986 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305988 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 * */
5990 if (( eConnectionState_Associated ==
5991 pAdapter->sessionCtx.station.conn_info.connState ) &&
5992 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
5993 pAdapter->sessionCtx.station.conn_info.bssId,
5994 WNI_CFG_BSSID_LEN)))
5995 {
5996 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
5997 rssi = (pAdapter->rssi * 100);
5998 }
5999 else
6000 {
6001 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
6002 }
6003
Nirav Shah20ac06f2013-12-12 18:14:06 +05306004 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
6005 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
6006 chan->center_freq, (int)(rssi/100));
6007
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
6009 frame_len, rssi, GFP_KERNEL);
6010 kfree(mgmt);
6011 return bss_status;
6012}
6013
6014/*
6015 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
6016 * This function is used to update the BSS data base of CFG8011
6017 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306018struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 tCsrRoamInfo *pRoamInfo
6020 )
6021{
6022 tCsrRoamConnectedProfile roamProfile;
6023 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6024 struct cfg80211_bss *bss = NULL;
6025
6026 ENTER();
6027
6028 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
6029 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
6030
6031 if (NULL != roamProfile.pBssDesc)
6032 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306033 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 &roamProfile);
6035
6036 if (NULL == bss)
6037 {
6038 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
6039 __func__);
6040 }
6041
6042 sme_RoamFreeConnectProfile(hHal, &roamProfile);
6043 }
6044 else
6045 {
6046 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
6047 __func__);
6048 }
6049 return bss;
6050}
6051
6052/*
6053 * FUNCTION: wlan_hdd_cfg80211_update_bss
6054 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306055static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
6056 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07006057 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306058{
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6060 tCsrScanResultInfo *pScanResult;
6061 eHalStatus status = 0;
6062 tScanResultHandle pResult;
6063 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07006064 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006065
6066 ENTER();
6067
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306068 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6069 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
6070 NO_SESSION, pAdapter->sessionId));
6071
Wilson Yangf80a0542013-10-07 13:02:37 -07006072 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6073
6074 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 {
Wilson Yangf80a0542013-10-07 13:02:37 -07006076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6077 "%s:LOGP in Progress. Ignore!!!",__func__);
6078 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07006079 }
6080
Wilson Yangf80a0542013-10-07 13:02:37 -07006081
6082 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05306083 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07006084 {
6085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6086 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
6087 return VOS_STATUS_E_PERM;
6088 }
6089
6090
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 /*
6092 * start getting scan results and populate cgf80211 BSS database
6093 */
6094 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
6095
6096 /* no scan results */
6097 if (NULL == pResult)
6098 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05306099 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
6100 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 return status;
6102 }
6103
6104 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
6105
6106 while (pScanResult)
6107 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306108 /*
6109 * cfg80211_inform_bss() is not updating ie field of bss entry, if
6110 * entry already exists in bss data base of cfg80211 for that
6111 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
6112 * bss entry instead of cfg80211_inform_bss, But this call expects
6113 * mgmt packet as input. As of now there is no possibility to get
6114 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 * ieee80211_mgmt(probe response) and passing to c
6116 * fg80211_inform_bss_frame.
6117 * */
6118
6119 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
6120 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306121
Jeff Johnson295189b2012-06-20 16:38:30 -07006122
6123 if (NULL == bss_status)
6124 {
6125 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006126 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 }
6128 else
6129 {
Yue Maf49ba872013-08-19 12:04:25 -07006130 cfg80211_put_bss(
6131#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
6132 wiphy,
6133#endif
6134 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006135 }
6136
6137 pScanResult = sme_ScanResultGetNext(hHal, pResult);
6138 }
6139
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306140 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07006141
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306142 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006143}
6144
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006145void
6146hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
6147{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306148 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08006149 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006150} /****** end hddPrintMacAddr() ******/
6151
6152void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006153hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006154{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306155 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006156 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006157 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
6158 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
6159 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006160} /****** end hddPrintPmkId() ******/
6161
6162//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
6163//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
6164
6165//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
6166//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
6167
6168#define dump_bssid(bssid) \
6169 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07006170 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
6171 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006172 }
6173
6174#define dump_pmkid(pMac, pmkid) \
6175 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07006176 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
6177 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006178 }
6179
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07006180#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006181/*
6182 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
6183 * This function is used to notify the supplicant of a new PMKSA candidate.
6184 */
6185int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306186 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006187 int index, bool preauth )
6188{
Jeff Johnsone7245742012-09-05 17:12:55 -07006189#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006190 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07006191 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006192
6193 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07006194 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006195
6196 if( NULL == pRoamInfo )
6197 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006198 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006199 return -EINVAL;
6200 }
6201
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07006202 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
6203 {
6204 dump_bssid(pRoamInfo->bssid);
6205 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006206 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07006207 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006208#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306209 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006210}
6211#endif //FEATURE_WLAN_LFR
6212
Yue Maef608272013-04-08 23:09:17 -07006213#ifdef FEATURE_WLAN_LFR_METRICS
6214/*
6215 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
6216 * 802.11r/LFR metrics reporting function to report preauth initiation
6217 *
6218 */
6219#define MAX_LFR_METRICS_EVENT_LENGTH 100
6220VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
6221 tCsrRoamInfo *pRoamInfo)
6222{
6223 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
6224 union iwreq_data wrqu;
6225
6226 ENTER();
6227
6228 if (NULL == pAdapter)
6229 {
6230 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
6231 return VOS_STATUS_E_FAILURE;
6232 }
6233
6234 /* create the event */
6235 memset(&wrqu, 0, sizeof(wrqu));
6236 memset(metrics_notification, 0, sizeof(metrics_notification));
6237
6238 wrqu.data.pointer = metrics_notification;
6239 wrqu.data.length = scnprintf(metrics_notification,
6240 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
6241 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
6242
6243 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
6244
6245 EXIT();
6246
6247 return VOS_STATUS_SUCCESS;
6248}
6249
6250/*
6251 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
6252 * 802.11r/LFR metrics reporting function to report preauth completion
6253 * or failure
6254 */
6255VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
6256 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
6257{
6258 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
6259 union iwreq_data wrqu;
6260
6261 ENTER();
6262
6263 if (NULL == pAdapter)
6264 {
6265 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
6266 return VOS_STATUS_E_FAILURE;
6267 }
6268
6269 /* create the event */
6270 memset(&wrqu, 0, sizeof(wrqu));
6271 memset(metrics_notification, 0, sizeof(metrics_notification));
6272
6273 scnprintf(metrics_notification, sizeof(metrics_notification),
6274 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
6275 MAC_ADDR_ARRAY(pRoamInfo->bssid));
6276
6277 if (1 == preauth_status)
6278 strncat(metrics_notification, " TRUE", 5);
6279 else
6280 strncat(metrics_notification, " FALSE", 6);
6281
6282 wrqu.data.pointer = metrics_notification;
6283 wrqu.data.length = strlen(metrics_notification);
6284
6285 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
6286
6287 EXIT();
6288
6289 return VOS_STATUS_SUCCESS;
6290}
6291
6292/*
6293 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
6294 * 802.11r/LFR metrics reporting function to report handover initiation
6295 *
6296 */
6297VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
6298 tCsrRoamInfo *pRoamInfo)
6299{
6300 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
6301 union iwreq_data wrqu;
6302
6303 ENTER();
6304
6305 if (NULL == pAdapter)
6306 {
6307 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
6308 return VOS_STATUS_E_FAILURE;
6309 }
6310
6311 /* create the event */
6312 memset(&wrqu, 0, sizeof(wrqu));
6313 memset(metrics_notification, 0, sizeof(metrics_notification));
6314
6315 wrqu.data.pointer = metrics_notification;
6316 wrqu.data.length = scnprintf(metrics_notification,
6317 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
6318 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
6319
6320 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
6321
6322 EXIT();
6323
6324 return VOS_STATUS_SUCCESS;
6325}
6326#endif
6327
Jeff Johnson295189b2012-06-20 16:38:30 -07006328/*
6329 * FUNCTION: hdd_cfg80211_scan_done_callback
6330 * scanning callback function, called after finishing scan
6331 *
6332 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306333static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07006334 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
6335{
6336 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306337 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006339 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6340 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07006341 struct cfg80211_scan_request *req = NULL;
6342 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306343 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306344 long waitRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006345
6346 ENTER();
6347
6348 hddLog(VOS_TRACE_LEVEL_INFO,
6349 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -08006350 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 __func__, halHandle, pContext, (int) scanId, (int) status);
6352
Kiet Lamac06e2c2013-10-23 16:25:07 +05306353 pScanInfo->mScanPendingCounter = 0;
6354
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306356 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 &pScanInfo->scan_req_completion_event,
6358 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306359 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306361 hddLog(VOS_TRACE_LEVEL_ERROR,
6362 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07006364 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 }
6366
Yue Maef608272013-04-08 23:09:17 -07006367 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 {
6369 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07006370 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 }
6372
6373 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306374 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 {
6376 hddLog(VOS_TRACE_LEVEL_INFO,
6377 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006378 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006379 (int) scanId);
6380 }
6381
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306382 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 pAdapter);
6384
6385 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306386 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006387
6388
6389 /* If any client wait scan result through WEXT
6390 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006391 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 {
6393 /* The other scan request waiting for current scan finish
6394 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006395 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006397 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 }
6399 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006400 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 {
6402 struct net_device *dev = pAdapter->dev;
6403 union iwreq_data wrqu;
6404 int we_event;
6405 char *msg;
6406
6407 memset(&wrqu, '\0', sizeof(wrqu));
6408 we_event = SIOCGIWSCAN;
6409 msg = NULL;
6410 wireless_send_event(dev, we_event, &wrqu, msg);
6411 }
6412 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006413 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006414
6415 /* Get the Scan Req */
6416 req = pAdapter->request;
6417
6418 if (!req)
6419 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006420 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07006421 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07006422 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07006423 }
6424
6425 /*
6426 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306427 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006428 req->n_ssids = 0;
6429 req->n_channels = 0;
6430 req->ie = 0;
6431
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07006433 /* Scan is no longer pending */
6434 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006435
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07006436 /*
6437 * cfg80211_scan_done informing NL80211 about completion
6438 * of scanning
6439 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306440 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
6441 {
6442 aborted = true;
6443 }
6444 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08006445 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07006446
Jeff Johnsone7245742012-09-05 17:12:55 -07006447allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07006448 /* release the wake lock at the end of the scan*/
6449 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07006450
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07006451 /* Acquire wakelock to handle the case where APP's tries to suspend
6452 * immediatly after the driver gets connect request(i.e after scan)
6453 * from supplicant, this result in app's is suspending and not able
6454 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05306455 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07006456
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07006457#ifdef FEATURE_WLAN_TDLS
c_hpothu3c8f8e82014-06-02 18:01:50 +05306458 if (!(eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode))
6459 {
6460 wlan_hdd_tdls_scan_done_callback(pAdapter);
6461 }
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07006462#endif
6463
Jeff Johnson295189b2012-06-20 16:38:30 -07006464 EXIT();
6465 return 0;
6466}
6467
6468/*
Rashmi Ramannab1429032014-04-26 14:59:09 +05306469 * FUNCTION: hdd_isConnectionInProgress
6470 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006471 *
6472 */
Rashmi Ramannab1429032014-04-26 14:59:09 +05306473v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx )
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006474{
6475 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
6476 hdd_station_ctx_t *pHddStaCtx = NULL;
6477 hdd_adapter_t *pAdapter = NULL;
6478 VOS_STATUS status = 0;
6479 v_U8_t staId = 0;
6480 v_U8_t *staMac = NULL;
6481
c_hpothu9b781ba2013-12-30 20:57:45 +05306482 if (TRUE == pHddCtx->btCoexModeSet)
6483 {
6484 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +05306485 FL("BTCoex Mode operation in progress"));
6486 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +05306487 }
6488
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006489 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
6490
6491 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
6492 {
6493 pAdapter = pAdapterNode->pAdapter;
6494
6495 if( pAdapter )
6496 {
6497 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306498 "%s: Adapter with device mode %s (%d) exists",
6499 __func__, hdd_device_modetoString(pAdapter->device_mode),
6500 pAdapter->device_mode);
Rashmi Ramannab1429032014-04-26 14:59:09 +05306501 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
6502 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
6503 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
6504 (eConnectionState_Connecting ==
6505 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6506 {
6507 hddLog(VOS_TRACE_LEVEL_ERROR,
6508 "%s: %p(%d) Connection is in progress", __func__,
6509 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
6510 return VOS_TRUE;
6511 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006512 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306513 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
6514 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006515 {
6516 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6517 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306518 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006519 {
6520 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
6521 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08006522 "%s: client " MAC_ADDRESS_STR
6523 " is in the middle of WPS/EAPOL exchange.", __func__,
6524 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05306525 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006526 }
6527 }
6528 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
6529 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
6530 {
6531 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
6532 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306533 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006534 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
6535 {
6536 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
6537
6538 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08006539 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
6540 "middle of WPS/EAPOL exchange.", __func__,
6541 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05306542 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006543 }
6544 }
6545 }
6546 }
6547 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6548 pAdapterNode = pNext;
6549 }
Rashmi Ramannab1429032014-04-26 14:59:09 +05306550 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306551}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006552
6553/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05306554 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -07006555 * this scan respond to scan trigger and update cfg80211 scan database
6556 * later, scan dump command can be used to recieve scan results
6557 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05306558int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08006559#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
6560 struct net_device *dev,
6561#endif
6562 struct cfg80211_scan_request *request)
6563{
Siddharth Bhal0c162d02014-05-06 19:50:42 +05306564 hdd_adapter_t *pAdapter = NULL;
6565 hdd_context_t *pHddCtx = NULL;
6566 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306567 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 tCsrScanRequest scanRequest;
6569 tANI_U8 *channelList = NULL, i;
6570 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306571 int status;
6572 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006573 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006574
Siddharth Bhal0c162d02014-05-06 19:50:42 +05306575#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
6576 struct net_device *dev = NULL;
6577 if (NULL == request)
6578 {
6579 hddLog(VOS_TRACE_LEVEL_ERROR,
6580 "%s: scan req param null", __func__);
6581 return -EINVAL;
6582 }
6583 dev = request->wdev->netdev;
6584#endif
6585
6586 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6587 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6588 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6589
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 ENTER();
6591
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306592
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306593 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6594 __func__, hdd_device_modetoString(pAdapter->device_mode),
6595 pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08006596
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306597 status = wlan_hdd_validate_context(pHddCtx);
6598
6599 if (0 != status)
6600 {
6601 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6602 "%s: HDD context is not valid", __func__);
6603 return status;
6604 }
6605
Siddharth Bhal0c162d02014-05-06 19:50:42 +05306606 if (NULL == pwextBuf)
6607 {
6608 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
6609 __func__);
6610 return -EIO;
6611 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306612 cfg_param = pHddCtx->cfg_ini;
6613 pScanInfo = &pHddCtx->scan_info;
6614
Jeff Johnson295189b2012-06-20 16:38:30 -07006615#ifdef WLAN_BTAMP_FEATURE
6616 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006617 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08006619 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 "%s: No scanning when AMP is on", __func__);
6621 return -EOPNOTSUPP;
6622 }
6623#endif
6624 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006625 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006627 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306628 "%s: Not scanning on device_mode = %s (%d)",
6629 __func__, hdd_device_modetoString(pAdapter->device_mode),
6630 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 return -EOPNOTSUPP;
6632 }
6633
6634 if (TRUE == pScanInfo->mScanPending)
6635 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05306636 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
6637 {
6638 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
6639 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006640 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 }
6642
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306643 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07006644 //Channel and action frame is pending
6645 //Otherwise Cancel Remain On Channel and allow Scan
6646 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006647 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07006648 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05306649 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07006650 return -EBUSY;
6651 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006652#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07006653 /* if tdls disagree scan right now, return immediately.
6654 tdls will schedule the scan when scan is allowed. (return SUCCESS)
6655 or will reject the scan if any TDLS is in progress. (return -EBUSY)
6656 */
6657 status = wlan_hdd_tdls_scan_callback (pAdapter,
6658 wiphy,
6659#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
6660 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07006661#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07006662 request);
6663 if(status <= 0)
6664 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05306665 if(!status)
6666 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
6667 "scan rejected %d", __func__, status);
6668 else
6669 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
6670 __func__, status);
6671
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07006672 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006673 }
6674#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07006675
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
6677 {
6678 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08006679 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
6683 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05306684 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006685 "%s: MAX TM Level Scan not allowed", __func__);
6686 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306687 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 }
6689 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
6690
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006691 /* Check if scan is allowed at this point of time.
6692 */
Rashmi Ramannab1429032014-04-26 14:59:09 +05306693 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006694 {
6695 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
6696 return -EBUSY;
6697 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306698
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 vos_mem_zero( &scanRequest, sizeof(scanRequest));
6700
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306701 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
6702 (int)request->n_ssids);
6703
6704 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
6705 * Becasue of this, driver is assuming that this is not wildcard scan and so
6706 * is not aging out the scan results.
6707 */
6708 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306710 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006711 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306712
6713 if ((request->ssids) && (0 < request->n_ssids))
6714 {
6715 tCsrSSIDInfo *SsidInfo;
6716 int j;
6717 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
6718 /* Allocate num_ssid tCsrSSIDInfo structure */
6719 SsidInfo = scanRequest.SSIDs.SSIDList =
6720 ( tCsrSSIDInfo *)vos_mem_malloc(
6721 request->n_ssids*sizeof(tCsrSSIDInfo));
6722
6723 if(NULL == scanRequest.SSIDs.SSIDList)
6724 {
6725 hddLog(VOS_TRACE_LEVEL_ERROR,
6726 "%s: memory alloc failed SSIDInfo buffer", __func__);
6727 return -ENOMEM;
6728 }
6729
6730 /* copy all the ssid's and their length */
6731 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
6732 {
6733 /* get the ssid length */
6734 SsidInfo->SSID.length = request->ssids[j].ssid_len;
6735 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
6736 SsidInfo->SSID.length);
6737 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
6738 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
6739 j, SsidInfo->SSID.ssId);
6740 }
6741 /* set the scan type to active */
6742 scanRequest.scanType = eSIR_ACTIVE_SCAN;
6743 }
6744 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07006745 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +05306746 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6747 TRACE_CODE_HDD_CFG80211_SCAN,
6748 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 /* set the scan type to active */
6750 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306752 else
6753 {
6754 /*Set the scan type to default type, in this case it is ACTIVE*/
6755 scanRequest.scanType = pScanInfo->scan_mode;
6756 }
6757 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
6758 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07006759
6760 /* set BSSType to default type */
6761 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
6762
6763 /*TODO: scan the requested channels only*/
6764
6765 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306766 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -07006767 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306768 hddLog(VOS_TRACE_LEVEL_WARN,
6769 "No of Scan Channels exceeded limit: %d", request->n_channels);
6770 request->n_channels = MAX_CHANNEL;
6771 }
6772
6773 hddLog(VOS_TRACE_LEVEL_INFO,
6774 "No of Scan Channels: %d", request->n_channels);
6775
6776
6777 if( request->n_channels )
6778 {
6779 char chList [(request->n_channels*5)+1];
6780 int len;
6781 channelList = vos_mem_malloc( request->n_channels );
6782 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +05306783 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306784 hddLog(VOS_TRACE_LEVEL_ERROR,
6785 "%s: memory alloc failed channelList", __func__);
6786 status = -ENOMEM;
6787 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +05306788 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306789
6790 for( i = 0, len = 0; i < request->n_channels ; i++ )
6791 {
6792 channelList[i] = request->channels[i]->hw_value;
6793 len += snprintf(chList+len, 5, "%d ", channelList[i]);
6794 }
6795
Nirav Shah20ac06f2013-12-12 18:14:06 +05306796 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306797 "Channel-List: %s ", chList);
6798 }
c_hpothu53512302014-04-15 18:49:53 +05306799
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306800 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
6801 scanRequest.ChannelInfo.ChannelList = channelList;
6802
6803 /* set requestType to full scan */
6804 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
6805
6806 /* Flush the scan results(only p2p beacons) for STA scan and P2P
6807 * search (Flush on both full scan and social scan but not on single
6808 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
6809 */
6810
6811 /* Supplicant does single channel scan after 8-way handshake
6812 * and in that case driver shoudnt flush scan results. If
6813 * driver flushes the scan results here and unfortunately if
6814 * the AP doesnt respond to our probe req then association
6815 * fails which is not desired
6816 */
6817
6818 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
6819 {
6820 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
6821 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
6822 pAdapter->sessionId );
6823 }
6824
6825 if( request->ie_len )
6826 {
6827 /* save this for future association (join requires this) */
6828 /*TODO: Array needs to be converted to dynamic allocation,
6829 * as multiple ie.s can be sent in cfg80211_scan_request structure
6830 * CR 597966
6831 */
6832 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
6833 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
6834 pScanInfo->scanAddIE.length = request->ie_len;
6835
6836 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
6837 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
6838 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07006839 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306840 if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -07006841 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306842 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
6843 memcpy( pwextBuf->roamProfile.addIEScan,
6844 request->ie, request->ie_len);
6845 }
6846 else
6847 {
6848 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
6849 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 }
6851
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306852 }
6853 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
6854 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
6855
6856 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
6857 request->ie_len);
6858 if (pP2pIe != NULL)
6859 {
6860#ifdef WLAN_FEATURE_P2P_DEBUG
6861 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
6862 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
6863 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +05306864 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306865 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
6866 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
6867 "Go nego completed to Connection is started");
6868 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
6869 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +05306870 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306871 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
6872 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07006873 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306874 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
6875 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
6876 "Disconnected state to Connection is started");
6877 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
6878 "for 4way Handshake");
6879 }
6880#endif
6881
6882 /* no_cck will be set during p2p find to disable 11b rates */
6883 if(TRUE == request->no_cck)
6884 {
6885 hddLog(VOS_TRACE_LEVEL_INFO,
6886 "%s: This is a P2P Search", __func__);
6887 scanRequest.p2pSearch = 1;
6888
6889 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +05306890 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306891 /* set requestType to P2P Discovery */
6892 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
6893 }
6894
6895 /*
6896 Skip Dfs Channel in case of P2P Search
6897 if it is set in ini file
6898 */
6899 if(cfg_param->skipDfsChnlInP2pSearch)
6900 {
6901 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +05306902 }
6903 else
6904 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306905 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05306906 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006907
Agarwal Ashish4f616132013-12-30 23:32:50 +05306908 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006909 }
6910 }
6911
6912 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
6913
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07006914 /* acquire the wakelock to avoid the apps suspend during the scan. To
6915 * address the following issues.
6916 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
6917 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
6918 * for long time, this result in apps running at full power for long time.
6919 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
6920 * be stuck in full power because of resume BMPS
6921 */
6922 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07006923
Nirav Shah20ac06f2013-12-12 18:14:06 +05306924 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6925 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306926 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
6927 scanRequest.requestType, scanRequest.scanType,
6928 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +05306929 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
6930
Jeff Johnsone7245742012-09-05 17:12:55 -07006931 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07006932 pAdapter->sessionId, &scanRequest, &scanId,
6933 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07006934
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 if (eHAL_STATUS_SUCCESS != status)
6936 {
6937 hddLog(VOS_TRACE_LEVEL_ERROR,
6938 "%s: sme_ScanRequest returned error %d", __func__, status);
6939 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07006940 if(eHAL_STATUS_RESOURCES == status)
6941 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05306942 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
6943 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07006944 status = -EBUSY;
6945 } else {
6946 status = -EIO;
6947 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07006948 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07006949 goto free_mem;
6950 }
6951
6952 pScanInfo->mScanPending = TRUE;
6953 pAdapter->request = request;
6954 pScanInfo->scanId = scanId;
6955
6956 complete(&pScanInfo->scan_req_completion_event);
6957
6958free_mem:
6959 if( scanRequest.SSIDs.SSIDList )
6960 {
6961 vos_mem_free(scanRequest.SSIDs.SSIDList);
6962 }
6963
6964 if( channelList )
6965 vos_mem_free( channelList );
6966
6967 EXIT();
6968
6969 return status;
6970}
6971
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05306972int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
6973#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
6974 struct net_device *dev,
6975#endif
6976 struct cfg80211_scan_request *request)
6977{
6978 int ret;
6979
6980 vos_ssr_protect(__func__);
6981 ret = __wlan_hdd_cfg80211_scan(wiphy,
6982#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
6983 dev,
6984#endif
6985 request);
6986 vos_ssr_unprotect(__func__);
6987
6988 return ret;
6989}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006990
6991void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
6992{
6993 v_U8_t iniDot11Mode =
6994 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
6995 eHddDot11Mode hddDot11Mode = iniDot11Mode;
6996
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05306997 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
6998 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006999 switch ( iniDot11Mode )
7000 {
7001 case eHDD_DOT11_MODE_AUTO:
7002 case eHDD_DOT11_MODE_11ac:
7003 case eHDD_DOT11_MODE_11ac_ONLY:
7004#ifdef WLAN_FEATURE_11AC
7005 hddDot11Mode = eHDD_DOT11_MODE_11ac;
7006#else
7007 hddDot11Mode = eHDD_DOT11_MODE_11n;
7008#endif
7009 break;
7010 case eHDD_DOT11_MODE_11n:
7011 case eHDD_DOT11_MODE_11n_ONLY:
7012 hddDot11Mode = eHDD_DOT11_MODE_11n;
7013 break;
7014 default:
7015 hddDot11Mode = iniDot11Mode;
7016 break;
7017 }
7018 /* This call decides required channel bonding mode */
7019 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
7020 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
7021 operationChannel);
7022}
7023
Jeff Johnson295189b2012-06-20 16:38:30 -07007024/*
7025 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307026 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307028int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07007029 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07007030{
7031 int status = 0;
7032 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -08007033 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 v_U32_t roamId;
7035 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07007036 eCsrAuthType RSNAuthType;
7037
7038 ENTER();
7039
7040 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -08007041 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7042
7043 status = wlan_hdd_validate_context(pHddCtx);
7044 if (status)
7045 {
7046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7047 "%s: HDD context is not valid!", __func__);
7048 return status;
7049 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307050
Jeff Johnson295189b2012-06-20 16:38:30 -07007051 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
7052 {
7053 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
7054 return -EINVAL;
7055 }
7056
7057 pRoamProfile = &pWextState->roamProfile;
7058
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307059 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007061 hdd_station_ctx_t *pHddStaCtx;
7062 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007063
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307064 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
7066 {
7067 /*QoS not enabled in cfg file*/
7068 pRoamProfile->uapsd_mask = 0;
7069 }
7070 else
7071 {
7072 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307073 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07007074 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
7075 }
7076
7077 pRoamProfile->SSIDs.numOfSSIDs = 1;
7078 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
7079 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307080 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007081 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
7082 ssid, ssid_len);
7083
7084 if (bssid)
7085 {
7086 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
7087 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
7088 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307089 /* Save BSSID in seperate variable as well, as RoamProfile
7090 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07007091 case of join failure we should send valid BSSID to supplicant
7092 */
7093 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
7094 WNI_CFG_BSSID_LEN);
7095 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07007096 else
7097 {
7098 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
7099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007100
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05307101 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
7102 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
7104 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307105 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007106 /*set gen ie*/
7107 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
7108 /*set auth*/
7109 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
7110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007111#ifdef FEATURE_WLAN_WAPI
7112 if (pAdapter->wapi_info.nWapiMode)
7113 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007114 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 switch (pAdapter->wapi_info.wapiAuthMode)
7116 {
7117 case WAPI_AUTH_MODE_PSK:
7118 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007119 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 pAdapter->wapi_info.wapiAuthMode);
7121 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
7122 break;
7123 }
7124 case WAPI_AUTH_MODE_CERT:
7125 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007126 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007127 pAdapter->wapi_info.wapiAuthMode);
7128 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
7129 break;
7130 }
7131 } // End of switch
7132 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
7133 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
7134 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007135 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 pRoamProfile->AuthType.numEntries = 1;
7137 pRoamProfile->EncryptionType.numEntries = 1;
7138 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
7139 pRoamProfile->mcEncryptionType.numEntries = 1;
7140 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
7141 }
7142 }
7143#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307144#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307145 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307146 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
7147 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
7148 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307149 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
7150 sizeof (tSirGtkOffloadParams));
7151 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307152 }
7153#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 pRoamProfile->csrPersona = pAdapter->device_mode;
7155
Jeff Johnson32d95a32012-09-10 13:15:23 -07007156 if( operatingChannel )
7157 {
7158 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
7159 pRoamProfile->ChannelInfo.numOfChannels = 1;
7160 }
Chet Lanctot186b5732013-03-18 10:26:30 -07007161 else
7162 {
7163 pRoamProfile->ChannelInfo.ChannelList = NULL;
7164 pRoamProfile->ChannelInfo.numOfChannels = 0;
7165 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007166 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
7167 {
7168 hdd_select_cbmode(pAdapter,operatingChannel);
7169 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05307170
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08007171 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
7172 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307173 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08007174 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08007175 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
7176 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307177 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
7178 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +05307179 {
7180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7181 "%s: Set HDD connState to eConnectionState_Connecting",
7182 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08007183 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
7184 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +05307185 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307186 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07007187 pAdapter->sessionId, pRoamProfile, &roamId);
7188
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307189 if ((eHAL_STATUS_SUCCESS != status) &&
7190 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
7191 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05307192
7193 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08007194 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
7195 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
7196 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05307197 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08007198 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05307199 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08007200
7201 pRoamProfile->ChannelInfo.ChannelList = NULL;
7202 pRoamProfile->ChannelInfo.numOfChannels = 0;
7203
Jeff Johnson295189b2012-06-20 16:38:30 -07007204 }
7205 else
7206 {
7207 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
7208 return -EINVAL;
7209 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08007210 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 return status;
7212}
7213
7214/*
7215 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
7216 * This function is used to set the authentication type (OPEN/SHARED).
7217 *
7218 */
7219static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
7220 enum nl80211_auth_type auth_type)
7221{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307222 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007223 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7224
7225 ENTER();
7226
7227 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307228 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07007229 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007230 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05307231 hddLog(VOS_TRACE_LEVEL_INFO,
7232 "%s: set authentication type to AUTOSWITCH", __func__);
7233 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
7234 break;
7235
7236 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007237#ifdef WLAN_FEATURE_VOWIFI_11R
7238 case NL80211_AUTHTYPE_FT:
7239#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307240 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 "%s: set authentication type to OPEN", __func__);
7242 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
7243 break;
7244
7245 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307246 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 "%s: set authentication type to SHARED", __func__);
7248 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
7249 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007250#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007251 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307252 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007253 "%s: set authentication type to CCKM WPA", __func__);
7254 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
7255 break;
7256#endif
7257
7258
7259 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307260 hddLog(VOS_TRACE_LEVEL_ERROR,
7261 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 auth_type);
7263 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
7264 return -EINVAL;
7265 }
7266
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307267 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 pHddStaCtx->conn_info.authType;
7269 return 0;
7270}
7271
7272/*
7273 * FUNCTION: wlan_hdd_set_akm_suite
7274 * This function is used to set the key mgmt type(PSK/8021x).
7275 *
7276 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307277static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07007278 u32 key_mgmt
7279 )
7280{
7281 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7282 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307283
Jeff Johnson295189b2012-06-20 16:38:30 -07007284 /*set key mgmt type*/
7285 switch(key_mgmt)
7286 {
7287 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307288#ifdef WLAN_FEATURE_VOWIFI_11R
7289 case WLAN_AKM_SUITE_FT_PSK:
7290#endif
7291 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 __func__);
7293 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
7294 break;
7295
7296 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307297#ifdef WLAN_FEATURE_VOWIFI_11R
7298 case WLAN_AKM_SUITE_FT_8021X:
7299#endif
7300 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07007301 __func__);
7302 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
7303 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007304#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007305#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
7306#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
7307 case WLAN_AKM_SUITE_CCKM:
7308 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
7309 __func__);
7310 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
7311 break;
7312#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07007313#ifndef WLAN_AKM_SUITE_OSEN
7314#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
7315 case WLAN_AKM_SUITE_OSEN:
7316 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
7317 __func__);
7318 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
7319 break;
7320#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007321
7322 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307323 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007324 __func__, key_mgmt);
7325 return -EINVAL;
7326
7327 }
7328 return 0;
7329}
7330
7331/*
7332 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307333 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 * (NONE/WEP40/WEP104/TKIP/CCMP).
7335 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307336static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
7337 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 bool ucast
7339 )
7340{
7341 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307342 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007343 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7344
7345 ENTER();
7346
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307347 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307349 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07007350 __func__, cipher);
7351 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
7352 }
7353 else
7354 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307355
Jeff Johnson295189b2012-06-20 16:38:30 -07007356 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307357 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07007358 {
7359 case IW_AUTH_CIPHER_NONE:
7360 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
7361 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307362
Jeff Johnson295189b2012-06-20 16:38:30 -07007363 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05307364 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07007365 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307366
Jeff Johnson295189b2012-06-20 16:38:30 -07007367 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05307368 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07007369 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307370
Jeff Johnson295189b2012-06-20 16:38:30 -07007371 case WLAN_CIPHER_SUITE_TKIP:
7372 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
7373 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307374
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 case WLAN_CIPHER_SUITE_CCMP:
7376 encryptionType = eCSR_ENCRYPT_TYPE_AES;
7377 break;
7378#ifdef FEATURE_WLAN_WAPI
7379 case WLAN_CIPHER_SUITE_SMS4:
7380 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
7381 break;
7382#endif
7383
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007384#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 case WLAN_CIPHER_SUITE_KRK:
7386 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
7387 break;
7388#endif
7389 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307390 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007391 __func__, cipher);
7392 return -EOPNOTSUPP;
7393 }
7394 }
7395
7396 if (ucast)
7397 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307398 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 __func__, encryptionType);
7400 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
7401 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307402 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 encryptionType;
7404 }
7405 else
7406 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307407 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007408 __func__, encryptionType);
7409 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
7410 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
7411 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
7412 }
7413
7414 return 0;
7415}
7416
7417
7418/*
7419 * FUNCTION: wlan_hdd_cfg80211_set_ie
7420 * This function is used to parse WPA/RSN IE's.
7421 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307422int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
7423 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07007424 size_t ie_len
7425 )
7426{
7427 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7428 u8 *genie = ie;
7429 v_U16_t remLen = ie_len;
7430#ifdef FEATURE_WLAN_WAPI
7431 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
7432 u16 *tmp;
7433 v_U16_t akmsuiteCount;
7434 int *akmlist;
7435#endif
7436 ENTER();
7437
7438 /* clear previous assocAddIE */
7439 pWextState->assocAddIE.length = 0;
7440 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007441 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007442
7443 while (remLen >= 2)
7444 {
7445 v_U16_t eLen = 0;
7446 v_U8_t elementId;
7447 elementId = *genie++;
7448 eLen = *genie++;
7449 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307450
Arif Hussain6d2a3322013-11-17 19:50:10 -08007451 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07007452 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307453
7454 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07007455 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307456 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007457 if (4 > eLen) /* should have at least OUI which is 4 bytes so extra 2 bytes not needed */
Jeff Johnson295189b2012-06-20 16:38:30 -07007458 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307459 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007460 "%s: Invalid WPA IE", __func__);
7461 return -EINVAL;
7462 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307463 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07007464 {
7465 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307466 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07007467 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307468
Jeff Johnson295189b2012-06-20 16:38:30 -07007469 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
7470 {
Jeff Johnson902c9832012-12-10 14:28:09 -08007471 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
7472 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07007473 VOS_ASSERT(0);
7474 return -ENOMEM;
7475 }
7476 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
7477 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
7478 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307479
Jeff Johnson295189b2012-06-20 16:38:30 -07007480 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
7481 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
7482 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
7483 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307484 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
7485 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
7487 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
7488 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
7489 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
7490 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
7491 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307492 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +05307493 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007494 {
7495 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307496 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307498
Jeff Johnson295189b2012-06-20 16:38:30 -07007499 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
7500 {
Jeff Johnson902c9832012-12-10 14:28:09 -08007501 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
7502 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07007503 VOS_ASSERT(0);
7504 return -ENOMEM;
7505 }
7506 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
7507 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
7508 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307509
Jeff Johnson295189b2012-06-20 16:38:30 -07007510 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
7511 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
7512 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007513#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307514 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
7515 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007516 /*Consider WFD IE, only for P2P Client */
7517 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
7518 {
7519 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307520 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307522
Jeff Johnson295189b2012-06-20 16:38:30 -07007523 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
7524 {
Jeff Johnson902c9832012-12-10 14:28:09 -08007525 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
7526 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07007527 VOS_ASSERT(0);
7528 return -ENOMEM;
7529 }
7530 // WFD IE is saved to Additional IE ; it should be accumulated to handle
7531 // WPS IE + P2P IE + WFD IE
7532 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
7533 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307534
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
7536 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
7537 }
7538#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007539 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307540 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007541 HS20_OUI_TYPE_SIZE)) )
7542 {
7543 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307544 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007545 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007546
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007547 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
7548 {
Jeff Johnson902c9832012-12-10 14:28:09 -08007549 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
7550 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007551 VOS_ASSERT(0);
7552 return -ENOMEM;
7553 }
7554 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
7555 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007556
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007557 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
7558 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
7559 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007560 /* Appending OSEN Information Element in Assiciation Request */
7561 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
7562 OSEN_OUI_TYPE_SIZE)) )
7563 {
7564 v_U16_t curAddIELen = pWextState->assocAddIE.length;
7565 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
7566 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007567
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007568 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
7569 {
7570 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
7571 "Need bigger buffer space");
7572 VOS_ASSERT(0);
7573 return -ENOMEM;
7574 }
7575 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
7576 pWextState->assocAddIE.length += eLen + 2;
7577
7578 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
7579 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
7580 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
7581 }
7582
7583 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07007584 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
7585
7586 /* populating as ADDIE in beacon frames */
7587 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
7588 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
7589 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
7590 {
7591 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
7592 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
7593 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
7594 {
7595 hddLog(LOGE,
7596 "Coldn't pass "
7597 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
7598 }
7599 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
7600 else
7601 hddLog(LOGE,
7602 "Could not pass on "
7603 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
7604
7605 /* IBSS mode doesn't contain params->proberesp_ies still
7606 beaconIE's need to be populated in probe response frames */
7607 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
7608 {
7609 u16 rem_probe_resp_ie_len = eLen + 2;
7610 u8 probe_rsp_ie_len[3] = {0};
7611 u8 counter = 0;
7612
7613 /* Check Probe Resp Length if it is greater then 255 then
7614 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
7615 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
7616 not able Store More then 255 bytes into One Variable */
7617
7618 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
7619 {
7620 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
7621 {
7622 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
7623 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
7624 }
7625 else
7626 {
7627 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
7628 rem_probe_resp_ie_len = 0;
7629 }
7630 }
7631
7632 rem_probe_resp_ie_len = 0;
7633
7634 if (probe_rsp_ie_len[0] > 0)
7635 {
7636 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
7637 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
7638 (tANI_U8*)(genie - 2),
7639 probe_rsp_ie_len[0], NULL,
7640 eANI_BOOLEAN_FALSE)
7641 == eHAL_STATUS_FAILURE)
7642 {
7643 hddLog(LOGE,
7644 "Could not pass"
7645 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
7646 }
7647 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
7648 }
7649
7650 if (probe_rsp_ie_len[1] > 0)
7651 {
7652 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
7653 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
7654 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
7655 probe_rsp_ie_len[1], NULL,
7656 eANI_BOOLEAN_FALSE)
7657 == eHAL_STATUS_FAILURE)
7658 {
7659 hddLog(LOGE,
7660 "Could not pass"
7661 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
7662 }
7663 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
7664 }
7665
7666 if (probe_rsp_ie_len[2] > 0)
7667 {
7668 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
7669 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
7670 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
7671 probe_rsp_ie_len[2], NULL,
7672 eANI_BOOLEAN_FALSE)
7673 == eHAL_STATUS_FAILURE)
7674 {
7675 hddLog(LOGE,
7676 "Could not pass"
7677 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
7678 }
7679 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
7680 }
7681
7682 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
7683 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
7684 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
7685 {
7686 hddLog(LOGE,
7687 "Could not pass"
7688 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
7689 }
7690 }
7691 else
7692 {
7693 // Reset WNI_CFG_PROBE_RSP Flags
7694 wlan_hdd_reset_prob_rspies(pAdapter);
7695
7696 hddLog(VOS_TRACE_LEVEL_INFO,
7697 "%s: No Probe Response IE received in set beacon",
7698 __func__);
7699 }
7700 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 break;
7702 case DOT11F_EID_RSN:
7703 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
7704 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
7705 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
7706 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
7707 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
7708 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007709 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
7710 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307711 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007712 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307713 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007714 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307715
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007716 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
7717 {
Jeff Johnson902c9832012-12-10 14:28:09 -08007718 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
7719 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007720 VOS_ASSERT(0);
7721 return -ENOMEM;
7722 }
7723 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
7724 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307725
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007726 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
7727 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
7728 break;
7729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007730#ifdef FEATURE_WLAN_WAPI
7731 case WLAN_EID_WAPI:
7732 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007733 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07007734 pAdapter->wapi_info.nWapiMode);
7735 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307736 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07007737 akmsuiteCount = WPA_GET_LE16(tmp);
7738 tmp = tmp + 1;
7739 akmlist = (int *)(tmp);
7740 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
7741 {
7742 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
7743 }
7744 else
7745 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007746 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -07007747 VOS_ASSERT(0);
7748 return -EINVAL;
7749 }
7750
7751 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
7752 {
7753 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007754 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007755 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007757 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307758 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007759 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007760 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007761 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
7762 }
7763 break;
7764#endif
7765 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307766 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007767 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007768 /* when Unknown IE is received we should break and continue
7769 * to the next IE in the buffer instead we were returning
7770 * so changing this to break */
7771 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007772 }
7773 genie += eLen;
7774 remLen -= eLen;
7775 }
7776 EXIT();
7777 return 0;
7778}
7779
7780/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05307781 * FUNCTION: hdd_isWPAIEPresent
7782 * Parse the received IE to find the WPA IE
7783 *
7784 */
7785static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
7786{
7787 v_U8_t eLen = 0;
7788 v_U16_t remLen = ie_len;
7789 v_U8_t elementId = 0;
7790
7791 while (remLen >= 2)
7792 {
7793 elementId = *ie++;
7794 eLen = *ie++;
7795 remLen -= 2;
7796 if (eLen > remLen)
7797 {
7798 hddLog(VOS_TRACE_LEVEL_ERROR,
7799 "%s: IE length is wrong %d", __func__, eLen);
7800 return FALSE;
7801 }
7802 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
7803 {
7804 /* OUI - 0x00 0X50 0XF2
7805 WPA Information Element - 0x01
7806 WPA version - 0x01*/
7807 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
7808 return TRUE;
7809 }
7810 ie += eLen;
7811 remLen -= eLen;
7812 }
7813 return FALSE;
7814}
7815
7816/*
Jeff Johnson295189b2012-06-20 16:38:30 -07007817 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307818 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07007819 * parameters during connect operation.
7820 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307821int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07007822 struct cfg80211_connect_params *req
7823 )
7824{
7825 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307826 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 ENTER();
7828
7829 /*set wpa version*/
7830 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
7831
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307832 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05307834 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07007835 {
7836 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
7837 }
7838 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
7839 {
7840 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
7841 }
7842 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307843
7844 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 pWextState->wpaVersion);
7846
7847 /*set authentication type*/
7848 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
7849
7850 if (0 > status)
7851 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307852 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007853 "%s: failed to set authentication type ", __func__);
7854 return status;
7855 }
7856
7857 /*set key mgmt type*/
7858 if (req->crypto.n_akm_suites)
7859 {
7860 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
7861 if (0 > status)
7862 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307863 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07007864 __func__);
7865 return status;
7866 }
7867 }
7868
7869 /*set pairwise cipher type*/
7870 if (req->crypto.n_ciphers_pairwise)
7871 {
7872 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
7873 req->crypto.ciphers_pairwise[0], true);
7874 if (0 > status)
7875 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307876 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007877 "%s: failed to set unicast cipher type", __func__);
7878 return status;
7879 }
7880 }
7881 else
7882 {
7883 /*Reset previous cipher suite to none*/
7884 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
7885 if (0 > status)
7886 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307887 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007888 "%s: failed to set unicast cipher type", __func__);
7889 return status;
7890 }
7891 }
7892
7893 /*set group cipher type*/
7894 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
7895 false);
7896
7897 if (0 > status)
7898 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307899 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07007900 __func__);
7901 return status;
7902 }
7903
Chet Lanctot186b5732013-03-18 10:26:30 -07007904#ifdef WLAN_FEATURE_11W
7905 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
7906#endif
7907
Jeff Johnson295189b2012-06-20 16:38:30 -07007908 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
7909 if (req->ie_len)
7910 {
7911 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
7912 if ( 0 > status)
7913 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307914 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07007915 __func__);
7916 return status;
7917 }
7918 }
7919
7920 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307921 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 {
7923 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
7924 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
7925 )
7926 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307927 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
7929 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307930 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 __func__);
7932 return -EOPNOTSUPP;
7933 }
7934 else
7935 {
7936 u8 key_len = req->key_len;
7937 u8 key_idx = req->key_idx;
7938
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307939 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07007940 && (CSR_MAX_NUM_KEY > key_idx)
7941 )
7942 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307943 hddLog(VOS_TRACE_LEVEL_INFO,
7944 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007945 __func__, key_idx, key_len);
7946 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307947 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07007948 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307949 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07007950 (u8)key_len;
7951 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
7952 }
7953 }
7954 }
7955 }
7956
7957 return status;
7958}
7959
7960/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05307961 * FUNCTION: wlan_hdd_try_disconnect
7962 * This function is used to disconnect from previous
7963 * connection
7964 */
7965static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
7966{
7967 long ret = 0;
7968 hdd_station_ctx_t *pHddStaCtx;
7969 eMib_dot11DesiredBssType connectedBssType;
7970
7971 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7972
7973 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
7974
7975 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
7976 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
7977 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
7978 {
7979 /* Issue disconnect to CSR */
7980 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7981 if( eHAL_STATUS_SUCCESS ==
7982 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7983 pAdapter->sessionId,
7984 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
7985 {
7986 ret = wait_for_completion_interruptible_timeout(
7987 &pAdapter->disconnect_comp_var,
7988 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7989 if (0 >= ret)
7990 {
7991 hddLog(LOGE, FL("Failed to receive disconnect event"));
7992 return -EALREADY;
7993 }
7994 }
7995 }
7996 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
7997 {
7998 ret = wait_for_completion_interruptible_timeout(
7999 &pAdapter->disconnect_comp_var,
8000 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8001 if (0 >= ret)
8002 {
8003 hddLog(LOGE, FL("Failed to receive disconnect event"));
8004 return -EALREADY;
8005 }
8006 }
8007
8008 return 0;
8009}
8010
8011/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05308012 * FUNCTION: __wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308013 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07008014 * parameters during connect operation.
8015 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05308016static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 struct net_device *ndev,
8018 struct cfg80211_connect_params *req
8019 )
8020{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308021 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308022 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008023 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008024 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008025
8026 ENTER();
8027
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308028 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8029 TRACE_CODE_HDD_CFG80211_CONNECT,
8030 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308031 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308032 "%s: device_mode = %s (%d)", __func__,
8033 hdd_device_modetoString(pAdapter->device_mode),
8034 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008035
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308036 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008037 if (!pHddCtx)
8038 {
8039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8040 "%s: HDD context is null", __func__);
8041 return VOS_STATUS_E_FAILURE;
8042 }
8043
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308044 status = wlan_hdd_validate_context(pHddCtx);
8045
8046 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008047 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308048 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8049 "%s: HDD context is not valid", __func__);
8050 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008051 }
8052
8053#ifdef WLAN_BTAMP_FEATURE
8054 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308055 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308057 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008058 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08008059 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07008060 }
8061#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05308062
8063 //If Device Mode is Station Concurrent Sessions Exit BMps
8064 //P2P Mode will be taken care in Open/close adapter
8065 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
8066 (vos_concurrent_sessions_running()))
8067 {
8068 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8069 }
8070
8071 /*Try disconnecting if already in connected state*/
8072 status = wlan_hdd_try_disconnect(pAdapter);
8073 if ( 0 > status)
8074 {
8075 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
8076 " connection"));
8077 return -EALREADY;
8078 }
8079
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308081 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07008082
8083 if ( 0 > status)
8084 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308085 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07008086 __func__);
8087 return status;
8088 }
8089
Mohit Khanna765234a2012-09-11 15:08:35 -07008090 if ( req->channel )
8091 {
8092 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
8093 req->ssid_len, req->bssid,
8094 req->channel->hw_value);
8095 }
8096 else
8097 {
8098 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308099 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07008100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008101
8102 if (0 > status)
8103 {
8104 //ReEnable BMPS if disabled
8105 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
8106 (NULL != pHddCtx))
8107 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308108 if (pHddCtx->hdd_wlan_suspended)
8109 {
8110 hdd_set_pwrparams(pHddCtx);
8111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 //ReEnable Bmps and Imps back
8113 hdd_enable_bmps_imps(pHddCtx);
8114 }
8115
8116 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
8117 return status;
8118 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308119 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008120 EXIT();
8121 return status;
8122}
8123
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05308124static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
8125 struct net_device *ndev,
8126 struct cfg80211_connect_params *req)
8127{
8128 int ret;
8129 vos_ssr_protect(__func__);
8130 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
8131 vos_ssr_unprotect(__func__);
8132
8133 return ret;
8134}
Jeff Johnson295189b2012-06-20 16:38:30 -07008135
8136/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308137 * FUNCTION: wlan_hdd_disconnect
8138 * This function is used to issue a disconnect request to SME
8139 */
8140int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
8141{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308142 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308143 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308144 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8145
8146 status = wlan_hdd_validate_context(pHddCtx);
8147
8148 if (0 != status)
8149 {
8150 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8151 "%s: HDD context is not valid", __func__);
8152 return status;
8153 }
8154
8155 pHddCtx->isAmpAllowed = VOS_TRUE;
Abhishek Singhf4669da2014-05-26 15:07:49 +05308156 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8157 "%s: Set HDD connState to eConnectionState_Disconnecting",
8158 __func__);
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05308159 pHddStaCtx->conn_info.connState = eConnectionState_Disconnecting;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308160 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308161
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308162 /*issue disconnect*/
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05308163
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308164 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8165 pAdapter->sessionId, reason);
8166
8167 if ( 0 != status )
8168 {
8169 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008170 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308171 __func__, (int)status );
8172 return -EINVAL;
8173 }
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05308174 status = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308175 &pAdapter->disconnect_comp_var,
8176 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05308177 if (!status)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308178 {
8179 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05308180 "%s: Failed to disconnect, timed out", __func__);
8181 return -ETIMEDOUT;
8182 }
8183 else if (status == -ERESTARTSYS)
8184 {
8185 hddLog(VOS_TRACE_LEVEL_ERROR,
8186 "%s: Failed to disconnect, wait interrupted", __func__);
8187 return status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308188 }
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308189 /*stop tx queues*/
8190 netif_tx_disable(pAdapter->dev);
8191 netif_carrier_off(pAdapter->dev);
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05308192 return 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308193}
8194
8195
8196/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05308197 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07008198 * This function is used to issue a disconnect request to SME
8199 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05308200static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 struct net_device *dev,
8202 u16 reason
8203 )
8204{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308205 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
8206 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07008207 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308208 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008209 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008210 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05308211#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08008212 tANI_U8 staIdx;
8213#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308214
Jeff Johnson295189b2012-06-20 16:38:30 -07008215 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308216
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308217 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8218 TRACE_CODE_HDD_CFG80211_DISCONNECT,
8219 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308220 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
8221 __func__, hdd_device_modetoString(pAdapter->device_mode),
8222 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008223
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308224 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
8225 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07008226
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308227 status = wlan_hdd_validate_context(pHddCtx);
8228
8229 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008230 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308231 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8232 "%s: HDD context is not valid", __func__);
8233 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008234 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308235
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 if (NULL != pRoamProfile)
8237 {
8238 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +05308239 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
8240 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -07008241 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308242 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05308244 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 switch(reason)
8246 {
8247 case WLAN_REASON_MIC_FAILURE:
8248 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
8249 break;
8250
8251 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
8252 case WLAN_REASON_DISASSOC_AP_BUSY:
8253 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
8254 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
8255 break;
8256
8257 case WLAN_REASON_PREV_AUTH_NOT_VALID:
8258 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +05308259 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -07008260 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
8261 break;
8262
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 default:
8264 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
8265 break;
8266 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05308267 pScanInfo = &pHddCtx->scan_info;
8268 if (pScanInfo->mScanPending)
8269 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05308270 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05308271 "Aborting Scan");
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05308272 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
8273 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05308274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008275
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08008276#ifdef FEATURE_WLAN_TDLS
8277 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008278 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08008279 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008280 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
8281 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08008282 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008283 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008284 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008285 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008286 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008287 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008288 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08008289 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008290 pAdapter->sessionId,
8291 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08008292 }
8293 }
8294#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05308295 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308296 status = wlan_hdd_disconnect(pAdapter, reasonCode);
8297 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 {
8299 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008300 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008301 __func__, (int)status );
8302 return -EINVAL;
8303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008304 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +05308305 else
8306 {
8307 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
8308 "called while in %d state", __func__,
8309 pHddStaCtx->conn_info.connState);
8310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008311 }
8312 else
8313 {
8314 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
8315 }
8316
8317 return status;
8318}
8319
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05308320static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
8321 struct net_device *dev,
8322 u16 reason
8323 )
8324{
8325 int ret;
8326 vos_ssr_protect(__func__);
8327 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
8328 vos_ssr_unprotect(__func__);
8329
8330 return ret;
8331}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308332
Jeff Johnson295189b2012-06-20 16:38:30 -07008333/*
8334 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308335 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07008336 * settings in IBSS mode.
8337 */
8338static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308339 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008340 struct cfg80211_ibss_params *params
8341 )
8342{
8343 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308344 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008345 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
8346 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308347
Jeff Johnson295189b2012-06-20 16:38:30 -07008348 ENTER();
8349
8350 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -07008351 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008352
8353 if (params->ie_len && ( NULL != params->ie) )
8354 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07008355 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
8356 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07008357 {
8358 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
8359 encryptionType = eCSR_ENCRYPT_TYPE_AES;
8360 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07008361 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008363 tDot11fIEWPA dot11WPAIE;
8364 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07008365 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008366
Wilson Yang00256342013-10-10 23:13:38 -07008367 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07008368 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
8369 params->ie_len, DOT11F_EID_WPA);
8370 if ( NULL != ie )
8371 {
8372 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
8373 // Unpack the WPA IE
8374 //Skip past the EID byte and length byte - and four byte WiFi OUI
8375 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
8376 &ie[2+4],
8377 ie[1] - 4,
8378 &dot11WPAIE);
8379 /*Extract the multicast cipher, the encType for unicast
8380 cipher for wpa-none is none*/
8381 encryptionType =
8382 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
8383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008384 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07008385
Jeff Johnson295189b2012-06-20 16:38:30 -07008386 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
8387
8388 if (0 > status)
8389 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308390 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 __func__);
8392 return status;
8393 }
8394 }
8395
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308396 pWextState->roamProfile.AuthType.authType[0] =
8397 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 eCSR_AUTH_TYPE_OPEN_SYSTEM;
8399
8400 if (params->privacy)
8401 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308402 /* Security enabled IBSS, At this time there is no information available
8403 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308405 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07008406 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308407 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07008408 *enable privacy bit in beacons */
8409
8410 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8411 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008412 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8413 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
8415 pWextState->roamProfile.EncryptionType.numEntries = 1;
8416 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07008417 return status;
8418}
8419
8420/*
8421 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308422 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07008423 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308424static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008425 struct net_device *dev,
8426 struct cfg80211_ibss_params *params
8427 )
8428{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308429 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8431 tCsrRoamProfile *pRoamProfile;
8432 int status;
krunal sonie9002db2013-11-25 14:24:17 -08008433 bool alloc_bssid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308435 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008436
8437 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308438
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308439 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8440 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
8441 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308442 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308443 "%s: device_mode = %s (%d)", __func__,
8444 hdd_device_modetoString(pAdapter->device_mode),
8445 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008446
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308447 status = wlan_hdd_validate_context(pHddCtx);
8448
8449 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008450 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308451 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8452 "%s: HDD context is not valid", __func__);
8453 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 }
8455
8456 if (NULL == pWextState)
8457 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008458 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -07008459 __func__);
8460 return -EIO;
8461 }
8462
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05308463 /*Try disconnecting if already in connected state*/
8464 status = wlan_hdd_try_disconnect(pAdapter);
8465 if ( 0 > status)
8466 {
8467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
8468 " IBSS connection"));
8469 return -EALREADY;
8470 }
8471
Jeff Johnson295189b2012-06-20 16:38:30 -07008472 pRoamProfile = &pWextState->roamProfile;
8473
8474 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
8475 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308476 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008477 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 return -EINVAL;
8479 }
8480
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07008481 /* BSSID is provided by upper layers hence no need to AUTO generate */
8482 if (NULL != params->bssid) {
8483 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
8484 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
8485 hddLog (VOS_TRACE_LEVEL_ERROR,
8486 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
8487 return -EIO;
8488 }
8489 }
krunal sonie9002db2013-11-25 14:24:17 -08008490 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
8491 {
8492 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
8493 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
8494 {
8495 hddLog (VOS_TRACE_LEVEL_ERROR,
8496 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
8497 return -EIO;
8498 }
8499 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
8500 if (!params->bssid)
8501 {
8502 hddLog (VOS_TRACE_LEVEL_ERROR,
8503 "%s:Failed memory allocation", __func__);
8504 return -EIO;
8505 }
8506 vos_mem_copy((v_U8_t *)params->bssid,
8507 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
8508 VOS_MAC_ADDR_SIZE);
8509 alloc_bssid = VOS_TRUE;
8510 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07008511
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07008513 if (NULL !=
8514#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
8515 params->chandef.chan)
8516#else
8517 params->channel)
8518#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 {
8520 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008521 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8522 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
8523 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8524 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008525
8526 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308527 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07008528 ieee80211_frequency_to_channel(
8529#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
8530 params->chandef.chan->center_freq);
8531#else
8532 params->channel->center_freq);
8533#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008534
8535 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8536 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008538 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
8539 __func__);
8540 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008542
8543 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008544 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008545 if (channelNum == validChan[indx])
8546 {
8547 break;
8548 }
8549 }
8550 if (indx >= numChans)
8551 {
8552 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008553 __func__, channelNum);
8554 return -EINVAL;
8555 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008556 /* Set the Operational Channel */
8557 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
8558 channelNum);
8559 pRoamProfile->ChannelInfo.numOfChannels = 1;
8560 pHddStaCtx->conn_info.operationChannel = channelNum;
8561 pRoamProfile->ChannelInfo.ChannelList =
8562 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07008563 }
8564
8565 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308566 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07008567 if (status < 0)
8568 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308569 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07008570 __func__);
8571 return status;
8572 }
8573
8574 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308575 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008576 params->ssid_len, params->bssid,
8577 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07008578
8579 if (0 > status)
8580 {
8581 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
8582 return status;
8583 }
8584
krunal sonie9002db2013-11-25 14:24:17 -08008585 if (NULL != params->bssid &&
8586 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
8587 alloc_bssid == VOS_TRUE)
8588 {
8589 vos_mem_free(params->bssid);
8590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008591 return 0;
8592}
8593
8594/*
8595 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308596 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07008597 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308598static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008599 struct net_device *dev
8600 )
8601{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308602 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8604 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308605 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8606 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008607
8608 ENTER();
8609
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308610 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8611 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
8612 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308613 status = wlan_hdd_validate_context(pHddCtx);
8614
8615 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008616 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308617 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8618 "%s: HDD context is not valid", __func__);
8619 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008620 }
8621
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308622 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
8623 hdd_device_modetoString(pAdapter->device_mode),
8624 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008625 if (NULL == pWextState)
8626 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008627 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -07008628 __func__);
8629 return -EIO;
8630 }
8631
8632 pRoamProfile = &pWextState->roamProfile;
8633
8634 /* Issue disconnect only if interface type is set to IBSS */
8635 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
8636 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308637 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07008638 __func__);
8639 return -EINVAL;
8640 }
8641
8642 /* Issue Disconnect request */
8643 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8644 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
8645 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
8646
8647 return 0;
8648}
8649
8650/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308651 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -07008652 * This function is used to set the phy parameters
8653 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
8654 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308655static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008656 u32 changed)
8657{
8658 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8659 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308660 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008661
8662 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308663 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8664 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
8665 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308666 status = wlan_hdd_validate_context(pHddCtx);
8667
8668 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008669 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308670 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8671 "%s: HDD context is not valid", __func__);
8672 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008673 }
8674
Jeff Johnson295189b2012-06-20 16:38:30 -07008675 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
8676 {
8677 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
8678 WNI_CFG_RTS_THRESHOLD_STAMAX :
8679 wiphy->rts_threshold;
8680
8681 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308682 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07008683 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308684 hddLog(VOS_TRACE_LEVEL_ERROR,
8685 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008686 __func__, rts_threshold);
8687 return -EINVAL;
8688 }
8689
8690 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
8691 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308692 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308694 hddLog(VOS_TRACE_LEVEL_ERROR,
8695 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 __func__, rts_threshold);
8697 return -EIO;
8698 }
8699
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308700 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008701 rts_threshold);
8702 }
8703
8704 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
8705 {
8706 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
8707 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
8708 wiphy->frag_threshold;
8709
8710 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308711 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008712 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308713 hddLog(VOS_TRACE_LEVEL_ERROR,
8714 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 frag_threshold);
8716 return -EINVAL;
8717 }
8718
8719 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
8720 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308721 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008722 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308723 hddLog(VOS_TRACE_LEVEL_ERROR,
8724 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008725 __func__, frag_threshold);
8726 return -EIO;
8727 }
8728
8729 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
8730 frag_threshold);
8731 }
8732
8733 if ((changed & WIPHY_PARAM_RETRY_SHORT)
8734 || (changed & WIPHY_PARAM_RETRY_LONG))
8735 {
8736 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
8737 wiphy->retry_short :
8738 wiphy->retry_long;
8739
8740 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
8741 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
8742 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308743 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008744 __func__, retry_value);
8745 return -EINVAL;
8746 }
8747
8748 if (changed & WIPHY_PARAM_RETRY_SHORT)
8749 {
8750 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
8751 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308752 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008753 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308754 hddLog(VOS_TRACE_LEVEL_ERROR,
8755 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008756 __func__, retry_value);
8757 return -EIO;
8758 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308759 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008760 __func__, retry_value);
8761 }
8762 else if (changed & WIPHY_PARAM_RETRY_SHORT)
8763 {
8764 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
8765 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308766 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308768 hddLog(VOS_TRACE_LEVEL_ERROR,
8769 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008770 __func__, retry_value);
8771 return -EIO;
8772 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308773 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008774 __func__, retry_value);
8775 }
8776 }
8777
8778 return 0;
8779}
8780
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308781static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
8782 u32 changed)
8783{
8784 int ret;
8785
8786 vos_ssr_protect(__func__);
8787 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
8788 vos_ssr_unprotect(__func__);
8789
8790 return ret;
8791}
8792
Jeff Johnson295189b2012-06-20 16:38:30 -07008793/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308794 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 * This function is used to set the txpower
8796 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308797static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07008798#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
8799 struct wireless_dev *wdev,
8800#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008801#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308802 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07008803#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308804 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07008805#endif
8806 int dbm)
8807{
8808 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308809 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008810 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
8811 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308812 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008813
8814 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308815 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8816 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
8817 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308818 status = wlan_hdd_validate_context(pHddCtx);
8819
8820 if (0 != status)
8821 {
8822 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8823 "%s: HDD context is not valid", __func__);
8824 return status;
8825 }
8826
8827 hHal = pHddCtx->hHal;
8828
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308829 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
8830 dbm, ccmCfgSetCallback,
8831 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008832 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308833 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008834 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
8835 return -EIO;
8836 }
8837
8838 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
8839 dbm);
8840
8841 switch(type)
8842 {
8843 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
8844 /* Fall through */
8845 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
8846 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
8847 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308848 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
8849 __func__);
8850 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008851 }
8852 break;
8853 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308854 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07008855 __func__);
8856 return -EOPNOTSUPP;
8857 break;
8858 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308859 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
8860 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008861 return -EIO;
8862 }
8863
8864 return 0;
8865}
8866
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05308867static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
8868#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
8869 struct wireless_dev *wdev,
8870#endif
8871#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
8872 enum tx_power_setting type,
8873#else
8874 enum nl80211_tx_power_setting type,
8875#endif
8876 int dbm)
8877{
8878 int ret;
8879 vos_ssr_protect(__func__);
8880 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
8881#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
8882 wdev,
8883#endif
8884#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
8885 type,
8886#else
8887 type,
8888#endif
8889 dbm);
8890 vos_ssr_unprotect(__func__);
8891
8892 return ret;
8893}
8894
Jeff Johnson295189b2012-06-20 16:38:30 -07008895/*
8896 * FUNCTION: wlan_hdd_cfg80211_get_txpower
8897 * This function is used to read the txpower
8898 */
Yue Maf49ba872013-08-19 12:04:25 -07008899static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
8900#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
8901 struct wireless_dev *wdev,
8902#endif
8903 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07008904{
8905
8906 hdd_adapter_t *pAdapter;
8907 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308908 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008909
Jeff Johnsone7245742012-09-05 17:12:55 -07008910 ENTER();
8911
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308912 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008913
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308914 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008915 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308916 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8917 "%s: HDD context is not valid", __func__);
8918 *dbm = 0;
8919 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008920 }
8921
Jeff Johnson295189b2012-06-20 16:38:30 -07008922 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
8923 if (NULL == pAdapter)
8924 {
8925 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
8926 return -ENOENT;
8927 }
8928
8929 wlan_hdd_get_classAstats(pAdapter);
8930 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
8931
Jeff Johnsone7245742012-09-05 17:12:55 -07008932 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008933 return 0;
8934}
8935
8936static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
8937 u8* mac, struct station_info *sinfo)
8938{
8939 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
8940 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8941 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +05308942 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07008943
8944 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
8945 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008946
8947 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
8948 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
8949 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
8950 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
8951 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
8952 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
8953 tANI_U16 maxRate = 0;
8954 tANI_U16 myRate;
8955 tANI_U16 currentRate = 0;
8956 tANI_U8 maxSpeedMCS = 0;
8957 tANI_U8 maxMCSIdx = 0;
8958 tANI_U8 rateFlag = 1;
8959 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07008960 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308961 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008962
Leo Chang6f8870f2013-03-26 18:11:36 -07008963#ifdef WLAN_FEATURE_11AC
8964 tANI_U32 vht_mcs_map;
8965 eDataRate11ACMaxMcs vhtMaxMcs;
8966#endif /* WLAN_FEATURE_11AC */
8967
Jeff Johnsone7245742012-09-05 17:12:55 -07008968 ENTER();
8969
Jeff Johnson295189b2012-06-20 16:38:30 -07008970 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
8971 (0 == ssidlen))
8972 {
8973 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
8974 " Invalid ssidlen, %d", __func__, ssidlen);
8975 /*To keep GUI happy*/
8976 return 0;
8977 }
8978
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308979 status = wlan_hdd_validate_context(pHddCtx);
8980
8981 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008982 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308983 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8984 "%s: HDD context is not valid", __func__);
8985 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008986 }
8987
Jeff Johnson295189b2012-06-20 16:38:30 -07008988
Kiet Lam3b17fc82013-09-27 05:24:08 +05308989 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
8990 sinfo->filled |= STATION_INFO_SIGNAL;
8991
c_hpothu09f19542014-05-30 21:53:31 +05308992 wlan_hdd_get_station_stats(pAdapter);
8993 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
8994
8995 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +05308996 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
8997 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
8998 sinfo->signal >= pCfg->linkSpeedRssiHigh))
8999 {
9000 rate_flags = pAdapter->maxRateFlags;
9001 }
c_hpothu44ff4e02014-05-08 00:13:57 +05309002
Jeff Johnson295189b2012-06-20 16:38:30 -07009003 //convert to the UI units of 100kbps
9004 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
9005
9006#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07009007 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 Johnson295189b2012-06-20 16:38:30 -07009008 sinfo->signal,
9009 pCfg->reportMaxLinkSpeed,
9010 myRate,
9011 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07009012 (int) pCfg->linkSpeedRssiMid,
9013 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07009014 (int) rate_flags,
9015 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009016#endif //LINKSPEED_DEBUG_ENABLED
9017
9018 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
9019 {
9020 // we do not want to necessarily report the current speed
9021 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
9022 {
9023 // report the max possible speed
9024 rssidx = 0;
9025 }
9026 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
9027 {
9028 // report the max possible speed with RSSI scaling
9029 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
9030 {
9031 // report the max possible speed
9032 rssidx = 0;
9033 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07009034 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07009035 {
9036 // report middle speed
9037 rssidx = 1;
9038 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07009039 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
9040 {
9041 // report middle speed
9042 rssidx = 2;
9043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009044 else
9045 {
9046 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07009047 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07009048 }
9049 }
9050 else
9051 {
9052 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
9053 hddLog(VOS_TRACE_LEVEL_ERROR,
9054 "%s: Invalid value for reportMaxLinkSpeed: %u",
9055 __func__, pCfg->reportMaxLinkSpeed);
9056 rssidx = 0;
9057 }
9058
9059 maxRate = 0;
9060
9061 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05309062 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
9063 OperationalRates, &ORLeng))
9064 {
9065 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
9066 /*To keep GUI happy*/
9067 return 0;
9068 }
9069
Jeff Johnson295189b2012-06-20 16:38:30 -07009070 for (i = 0; i < ORLeng; i++)
9071 {
Jeff Johnsone7245742012-09-05 17:12:55 -07009072 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07009073 {
9074 /* Validate Rate Set */
9075 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
9076 {
9077 currentRate = supported_data_rate[j].supported_rate[rssidx];
9078 break;
9079 }
9080 }
9081 /* Update MAX rate */
9082 maxRate = (currentRate > maxRate)?currentRate:maxRate;
9083 }
9084
9085 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05309086 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
9087 ExtendedRates, &ERLeng))
9088 {
9089 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
9090 /*To keep GUI happy*/
9091 return 0;
9092 }
9093
Jeff Johnson295189b2012-06-20 16:38:30 -07009094 for (i = 0; i < ERLeng; i++)
9095 {
Jeff Johnsone7245742012-09-05 17:12:55 -07009096 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07009097 {
9098 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
9099 {
9100 currentRate = supported_data_rate[j].supported_rate[rssidx];
9101 break;
9102 }
9103 }
9104 /* Update MAX rate */
9105 maxRate = (currentRate > maxRate)?currentRate:maxRate;
9106 }
Kiet Lamb69f8dc2013-11-15 15:34:27 +05309107 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +05309108 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +05309109 if we have good rssi */
Kaushik, Sushantdc304d82014-01-22 10:58:37 +05309110 if ((0 == rssidx) ||
Kiet Lamb69f8dc2013-11-15 15:34:27 +05309111 (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed))
Jeff Johnson295189b2012-06-20 16:38:30 -07009112 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05309113 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
9114 MCSRates, &MCSLeng))
9115 {
9116 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
9117 /*To keep GUI happy*/
9118 return 0;
9119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009120 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07009121#ifdef WLAN_FEATURE_11AC
9122 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309123 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07009124 {
Leo Chang6f8870f2013-03-26 18:11:36 -07009125 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309126 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07009127 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07009128 {
Leo Chang6f8870f2013-03-26 18:11:36 -07009129 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009130 }
Leo Chang6f8870f2013-03-26 18:11:36 -07009131 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07009132 {
Leo Chang6f8870f2013-03-26 18:11:36 -07009133 maxMCSIdx = 7;
9134 }
9135 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
9136 {
9137 maxMCSIdx = 8;
9138 }
9139 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
9140 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309141 //VHT20 is supporting 0~8
9142 if (rate_flags & eHAL_TX_RATE_VHT20)
9143 maxMCSIdx = 8;
9144 else
9145 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07009146 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309147
9148 if (rate_flags & eHAL_TX_RATE_VHT80)
9149 {
9150 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
9151 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
9152 }
9153 else if (rate_flags & eHAL_TX_RATE_VHT40)
9154 {
9155 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
9156 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
9157 }
9158 else if (rate_flags & eHAL_TX_RATE_VHT20)
9159 {
9160 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
9161 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
9162 }
9163
Leo Chang6f8870f2013-03-26 18:11:36 -07009164 maxSpeedMCS = 1;
9165 if (currentRate > maxRate)
9166 {
9167 maxRate = currentRate;
9168 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309169
Leo Chang6f8870f2013-03-26 18:11:36 -07009170 }
9171 else
9172#endif /* WLAN_FEATURE_11AC */
9173 {
9174 if (rate_flags & eHAL_TX_RATE_HT40)
9175 {
9176 rateFlag |= 1;
9177 }
9178 if (rate_flags & eHAL_TX_RATE_SGI)
9179 {
9180 rateFlag |= 2;
9181 }
9182
9183 for (i = 0; i < MCSLeng; i++)
9184 {
9185 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
9186 for (j = 0; j < temp; j++)
9187 {
9188 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
9189 {
9190 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
9191 break;
9192 }
9193 }
9194 if ((j < temp) && (currentRate > maxRate))
9195 {
9196 maxRate = currentRate;
9197 maxSpeedMCS = 1;
9198 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
9199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009200 }
9201 }
9202 }
9203
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309204 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
9205 {
9206 maxRate = myRate;
9207 maxSpeedMCS = 1;
9208 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
9209 }
9210
Jeff Johnson295189b2012-06-20 16:38:30 -07009211 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07009212 if (((maxRate < myRate) && (0 == rssidx)) ||
9213 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07009214 {
9215 maxRate = myRate;
9216 if (rate_flags & eHAL_TX_RATE_LEGACY)
9217 {
9218 maxSpeedMCS = 0;
9219 }
9220 else
9221 {
9222 maxSpeedMCS = 1;
9223 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
9224 }
9225 }
9226
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309227 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07009228 {
9229 sinfo->txrate.legacy = maxRate;
9230#ifdef LINKSPEED_DEBUG_ENABLED
9231 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
9232#endif //LINKSPEED_DEBUG_ENABLED
9233 }
9234 else
9235 {
9236 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07009237#ifdef WLAN_FEATURE_11AC
9238 sinfo->txrate.nss = 1;
9239 if (rate_flags & eHAL_TX_RATE_VHT80)
9240 {
9241 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309242 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07009243 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309244 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07009245 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309246 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
9247 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
9248 }
9249 else if (rate_flags & eHAL_TX_RATE_VHT20)
9250 {
9251 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
9252 }
9253#endif /* WLAN_FEATURE_11AC */
9254 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
9255 {
9256 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
9257 if (rate_flags & eHAL_TX_RATE_HT40)
9258 {
9259 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
9260 }
Leo Chang6f8870f2013-03-26 18:11:36 -07009261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 if (rate_flags & eHAL_TX_RATE_SGI)
9263 {
9264 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
9265 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309266
Jeff Johnson295189b2012-06-20 16:38:30 -07009267#ifdef LINKSPEED_DEBUG_ENABLED
9268 pr_info("Reporting MCS rate %d flags %x\n",
9269 sinfo->txrate.mcs,
9270 sinfo->txrate.flags );
9271#endif //LINKSPEED_DEBUG_ENABLED
9272 }
9273 }
9274 else
9275 {
9276 // report current rate instead of max rate
9277
9278 if (rate_flags & eHAL_TX_RATE_LEGACY)
9279 {
9280 //provide to the UI in units of 100kbps
9281 sinfo->txrate.legacy = myRate;
9282#ifdef LINKSPEED_DEBUG_ENABLED
9283 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
9284#endif //LINKSPEED_DEBUG_ENABLED
9285 }
9286 else
9287 {
9288 //must be MCS
9289 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07009290#ifdef WLAN_FEATURE_11AC
9291 sinfo->txrate.nss = 1;
9292 if (rate_flags & eHAL_TX_RATE_VHT80)
9293 {
9294 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
9295 }
9296 else
9297#endif /* WLAN_FEATURE_11AC */
9298 {
9299 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
9300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009301 if (rate_flags & eHAL_TX_RATE_SGI)
9302 {
9303 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
9304 }
9305 if (rate_flags & eHAL_TX_RATE_HT40)
9306 {
9307 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
9308 }
Leo Chang6f8870f2013-03-26 18:11:36 -07009309#ifdef WLAN_FEATURE_11AC
9310 else if (rate_flags & eHAL_TX_RATE_VHT80)
9311 {
9312 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
9313 }
9314#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07009315#ifdef LINKSPEED_DEBUG_ENABLED
9316 pr_info("Reporting actual MCS rate %d flags %x\n",
9317 sinfo->txrate.mcs,
9318 sinfo->txrate.flags );
9319#endif //LINKSPEED_DEBUG_ENABLED
9320 }
9321 }
9322 sinfo->filled |= STATION_INFO_TX_BITRATE;
9323
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07009324 sinfo->tx_packets =
9325 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
9326 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
9327 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
9328 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
9329
9330 sinfo->tx_retries =
9331 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
9332 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
9333 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
9334 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
9335
9336 sinfo->tx_failed =
9337 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
9338 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
9339 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
9340 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
9341
9342 sinfo->filled |=
9343 STATION_INFO_TX_PACKETS |
9344 STATION_INFO_TX_RETRIES |
9345 STATION_INFO_TX_FAILED;
9346
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309347 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9348 TRACE_CODE_HDD_CFG80211_GET_STA,
9349 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07009350 EXIT();
9351 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009352}
9353
9354static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07009355 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07009356{
9357 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05309358 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009359 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309360 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009361
Jeff Johnsone7245742012-09-05 17:12:55 -07009362 ENTER();
9363
Jeff Johnson295189b2012-06-20 16:38:30 -07009364 if (NULL == pAdapter)
9365 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009366 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009367 return -ENODEV;
9368 }
9369
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309370 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9371 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
9372 pAdapter->sessionId, timeout));
9373
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05309374 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309375 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05309376
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309377 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309378 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309379 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9380 "%s: HDD context is not valid", __func__);
9381 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309382 }
9383
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05309384 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
9385 (TRUE == pHddCtx->hdd_wlan_suspended) &&
9386 (pHddCtx->cfg_ini->fhostArpOffload) &&
9387 (eConnectionState_Associated ==
9388 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9389 {
Amar Singhald53568e2013-09-26 11:03:45 -07009390
9391 hddLog(VOS_TRACE_LEVEL_INFO,
9392 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05309393 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05309394 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9395 {
9396 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009397 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05309398 __func__, vos_status);
9399 }
9400 }
9401
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 /**The get power cmd from the supplicant gets updated by the nl only
9403 *on successful execution of the function call
9404 *we are oppositely mapped w.r.t mode in the driver
9405 **/
9406 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
9407
Kiet Lam94fd2922014-06-18 19:12:43 -07009408 if (!mode)
9409 {
9410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG,
9411 "%s: DHCP start indicated through power save", __func__);
9412
9413 pHddCtx->btCoexModeSet = TRUE;
9414 sme_DHCPStartInd(pHddCtx->hHal, pAdapter->device_mode,
9415 pAdapter->sessionId);
9416 }
9417 else
9418 {
9419 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_DEBUG,
9420 "%s: DHCP stop indicated through power save", __func__);
9421
9422 pHddCtx->btCoexModeSet = FALSE;
9423 sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode,
9424 pAdapter->sessionId);
9425 }
9426
Jeff Johnsone7245742012-09-05 17:12:55 -07009427 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009428 if (VOS_STATUS_E_FAILURE == vos_status)
9429 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309430 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9431 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 return -EINVAL;
9433 }
9434 return 0;
9435}
9436
9437
9438#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9439static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
9440 struct net_device *netdev,
9441 u8 key_index)
9442{
Jeff Johnsone7245742012-09-05 17:12:55 -07009443 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009444 return 0;
9445}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309446#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07009447
9448#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
9449static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
9450 struct net_device *dev,
9451 struct ieee80211_txq_params *params)
9452{
Jeff Johnsone7245742012-09-05 17:12:55 -07009453 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009454 return 0;
9455}
9456#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9457static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
9458 struct ieee80211_txq_params *params)
9459{
Jeff Johnsone7245742012-09-05 17:12:55 -07009460 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 return 0;
9462}
9463#endif //LINUX_VERSION_CODE
9464
9465static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
9466 struct net_device *dev, u8 *mac)
9467{
9468 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309469 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009470 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309471 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009472 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009473
Jeff Johnsone7245742012-09-05 17:12:55 -07009474 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309475
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309476 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309478 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009479 return -EINVAL;
9480 }
9481
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309482 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9483 TRACE_CODE_HDD_CFG80211_DEL_STA,
9484 pAdapter->sessionId, pAdapter->device_mode));
9485
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309486 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9487 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07009488
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309489 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009490 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309491 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9492 "%s: HDD context is not valid", __func__);
9493 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009494 }
9495
Jeff Johnson295189b2012-06-20 16:38:30 -07009496 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07009498 )
9499 {
9500 if( NULL == mac )
9501 {
9502 v_U16_t i;
9503 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
9504 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07009505 if ((pAdapter->aStaInfo[i].isUsed) &&
9506 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 {
9508 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
9509 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08009510 "%s: Delete STA with MAC::"
9511 MAC_ADDRESS_STR,
9512 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07009513 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
9514 if (VOS_IS_STATUS_SUCCESS(vos_status))
9515 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009516 }
9517 }
9518 }
9519 else
9520 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009521
9522 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
9523 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9524 {
9525 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08009526 "%s: Skip this DEL STA as this is not used::"
9527 MAC_ADDRESS_STR,
9528 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009529 return -ENOENT;
9530 }
9531
9532 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
9533 {
9534 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08009535 "%s: Skip this DEL STA as deauth is in progress::"
9536 MAC_ADDRESS_STR,
9537 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009538 return -ENOENT;
9539 }
9540
9541 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
9542
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 hddLog(VOS_TRACE_LEVEL_INFO,
9544 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -08009545 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009546 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08009547 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009548
9549 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
9550 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9551 {
9552 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
9553 hddLog(VOS_TRACE_LEVEL_INFO,
9554 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -08009555 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009556 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08009557 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009558 return -ENOENT;
9559 }
9560
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 }
9562 }
9563
9564 EXIT();
9565
9566 return 0;
9567}
9568
Hoonki Lee11f7dda2013-02-14 16:55:44 -08009569static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
9570 struct net_device *dev, u8 *mac, struct station_parameters *params)
9571{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309572 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009573 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08009574#ifdef FEATURE_WLAN_TDLS
9575 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08009576 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309577
9578 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9579 TRACE_CODE_HDD_CFG80211_ADD_STA,
9580 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009581 mask = params->sta_flags_mask;
9582
9583 set = params->sta_flags_set;
9584
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009585#ifdef WLAN_FEATURE_TDLS_DEBUG
9586 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9587 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
9588 __func__, mask, set, MAC_ADDR_ARRAY(mac));
9589#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009590
9591 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
9592 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009593 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009594 }
9595 }
9596#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009597 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009598}
9599
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009600
9601#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07009602
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +05309603static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07009604 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009605{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309606 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009607 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309608 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009609 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309610 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309611 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009612 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309613 hdd_context_t *pHddCtx;
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009614 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
9615 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009616
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309617 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309618 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009619 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309620 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009621 return -EINVAL;
9622 }
9623
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309624 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9625 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009626
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309627 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009628 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309629 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9630 "%s: HDD context is not valid", __func__);
9631 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009632 }
9633
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309634 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009635 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309636 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009637
Agarwal Ashish3da95242014-05-21 14:57:17 +05309638 for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009639 {
Agarwal Ashish3da95242014-05-21 14:57:17 +05309640 if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009641 pmksa->bssid, WNI_CFG_BSSID_LEN))
9642 {
9643 /* BSSID matched previous entry. Overwrite it. */
9644 BSSIDMatched = 1;
Agarwal Ashish3da95242014-05-21 14:57:17 +05309645 vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009646 pmksa->bssid, WNI_CFG_BSSID_LEN);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309647 vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309648 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009649 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309650 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009651 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009652 dump_bssid(pmksa->bssid);
9653 dump_pmkid(halHandle, pmksa->pmkid);
9654 break;
9655 }
9656 }
9657
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07009658 /* Check we compared all entries,if then take the first slot now */
Agarwal Ashish3da95242014-05-21 14:57:17 +05309659 if (j == MAX_PMKSAIDS_IN_CACHE) pHddStaCtx->PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07009660
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009661 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309662 {
9663 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Agarwal Ashish3da95242014-05-21 14:57:17 +05309664 vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309665 pmksa->bssid, ETHER_ADDR_LEN);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309666 vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309667 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009668 CSR_RSN_PMKID_SIZE);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309669 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Adding a new cache entry %d.",
9670 __func__, pHddStaCtx->PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009671 dump_bssid(pmksa->bssid);
9672 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309673 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009674 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Agarwal Ashish3da95242014-05-21 14:57:17 +05309675 if (pHddStaCtx->PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1))
9676 pHddStaCtx->PMKIDCacheIndex++;
9677 else
9678 pHddStaCtx->PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009679 }
9680
9681
9682 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Agarwal Ashish3da95242014-05-21 14:57:17 +05309683 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
9684 __func__, pHddStaCtx->PMKIDCacheIndex );
9685
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009686 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309687 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Agarwal Ashish3da95242014-05-21 14:57:17 +05309688 pHddStaCtx->PMKIDCache,
9689 pHddStaCtx->PMKIDCacheIndex);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309690 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9691 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
9692 pAdapter->sessionId, result));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009693 return 0;
9694}
9695
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +05309696static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
9697 struct cfg80211_pmksa *pmksa)
9698{
9699 int ret;
9700
9701 vos_ssr_protect(__func__);
9702 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
9703 vos_ssr_unprotect(__func__);
9704
9705 return ret;
9706}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009707
Wilson Yang6507c4e2013-10-01 20:11:19 -07009708
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +05309709static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07009710 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009711{
Wilson Yang6507c4e2013-10-01 20:11:19 -07009712 tANI_U32 j=0;
9713 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309714 hdd_station_ctx_t *pHddStaCtx;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009715 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009716 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009717 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -08009718 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009719
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009720 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
9721 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07009722
9723 /* Validate pAdapter */
9724 if (NULL == pAdapter)
9725 {
9726 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
9727 return -EINVAL;
9728 }
9729
9730 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9731 status = wlan_hdd_validate_context(pHddCtx);
9732
9733 if (0 != status)
9734 {
9735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9736 "%s: HDD context is not valid", __func__);
9737 return status;
9738 }
9739
9740 /*Retrieve halHandle*/
9741 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309742 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Wilson Yang6507c4e2013-10-01 20:11:19 -07009743
9744 /*in case index is 0,no entry to delete*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05309745 if (0 == pHddStaCtx->PMKIDCacheIndex)
Wilson Yang6507c4e2013-10-01 20:11:19 -07009746 {
Agarwal Ashish3da95242014-05-21 14:57:17 +05309747 hddLog(VOS_TRACE_LEVEL_INFO, FL("No entries to flush"));
9748 return 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009749 }
9750
9751 /*find the matching PMKSA entry from j=0 to (index-1),
9752 * and delete the matched one
9753 */
Agarwal Ashish3da95242014-05-21 14:57:17 +05309754 for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
Wilson Yang6507c4e2013-10-01 20:11:19 -07009755 {
Agarwal Ashish3da95242014-05-21 14:57:17 +05309756 if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID,
Wilson Yang6507c4e2013-10-01 20:11:19 -07009757 pmksa->bssid,
9758 WNI_CFG_BSSID_LEN))
9759 {
9760 /* BSSID matched entry */
9761 BSSIDMatched = 1;
Agarwal Ashish3da95242014-05-21 14:57:17 +05309762 if (j < pHddStaCtx->PMKIDCacheIndex-1)
Wilson Yang6507c4e2013-10-01 20:11:19 -07009763 {
9764 /*replace the matching entry with the last entry in HDD local cache*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05309765 vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID,
9766 pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID,
9767 VOS_MAC_ADDR_SIZE);
9768 vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID,
9769 pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID,
9770 CSR_RSN_PMKID_SIZE);
9771 }
Wilson Yang6507c4e2013-10-01 20:11:19 -07009772
9773 /*clear the last entry in HDD cache ---[index-1]*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05309774 vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID,
9775 VOS_MAC_ADDR_SIZE);
9776 vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID,
9777 CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -07009778 /*reduce the PMKID array index*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05309779 pHddStaCtx->PMKIDCacheIndex--;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009780 /*delete the last PMKID cache in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -08009781 if (eHAL_STATUS_SUCCESS !=
9782 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid))
Wilson Yang6507c4e2013-10-01 20:11:19 -07009783 {
9784 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
Agarwal Ashish3da95242014-05-21 14:57:17 +05309785 __func__, pHddStaCtx->PMKIDCacheIndex);
Wilson Yangef657d32014-01-15 19:19:23 -08009786 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009787 }
9788
9789 dump_bssid(pmksa->bssid);
9790 dump_pmkid(halHandle,pmksa->pmkid);
9791
9792 break;
9793 }
9794 }
9795
9796 /* we compare all entries,but cannot find matching entry */
9797 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
9798 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009799 hddLog(VOS_TRACE_LEVEL_FATAL,
9800 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
9801 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07009802 dump_bssid(pmksa->bssid);
9803 dump_pmkid(halHandle, pmksa->pmkid);
9804 return -EINVAL;
9805 }
Wilson Yangef657d32014-01-15 19:19:23 -08009806 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009807}
9808
Wilson Yang6507c4e2013-10-01 20:11:19 -07009809
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +05309810static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
9811 struct cfg80211_pmksa *pmksa)
9812{
9813 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009814
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +05309815 vos_ssr_protect(__func__);
9816 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
9817 vos_ssr_unprotect(__func__);
9818
9819 return ret;
9820
9821}
9822
9823static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009824{
Wilson Yang6507c4e2013-10-01 20:11:19 -07009825 tANI_U32 j=0;
9826 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309827 hdd_station_ctx_t *pHddStaCtx;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009828 tHalHandle halHandle;
9829 hdd_context_t *pHddCtx;
9830 tANI_U8 *pBSSId;
Wilson Yangef657d32014-01-15 19:19:23 -08009831 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009832
9833 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
9834
9835 /* Validate pAdapter */
9836 if (NULL == pAdapter)
9837 {
9838 hddLog(VOS_TRACE_LEVEL_ERROR,
9839 "%s: Invalid Adapter" ,__func__);
9840 return -EINVAL;
9841 }
9842
9843 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9844 status = wlan_hdd_validate_context(pHddCtx);
9845
9846 if (0 != status)
9847 {
9848 hddLog(VOS_TRACE_LEVEL_ERROR,
9849 "%s: HDD context is not valid", __func__);
9850 return status;
9851 }
9852
9853 /*Retrieve halHandle*/
9854 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309855 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Wilson Yang6507c4e2013-10-01 20:11:19 -07009856
9857 /*in case index is 0,no entry to delete*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05309858 if (0 == pHddStaCtx->PMKIDCacheIndex)
Wilson Yang6507c4e2013-10-01 20:11:19 -07009859 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05309860 hddLog(VOS_TRACE_LEVEL_ERROR, FL("No entries to flush"));
Agarwal Ashish3da95242014-05-21 14:57:17 +05309861 return 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009862 }
9863
9864 /*delete all the PMKSA one by one */
Agarwal Ashish3da95242014-05-21 14:57:17 +05309865 for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
Wilson Yang6507c4e2013-10-01 20:11:19 -07009866 {
Agarwal Ashish3da95242014-05-21 14:57:17 +05309867 pBSSId =(tANI_U8 *)(pHddStaCtx->PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -07009868 /*delete the PMKID in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -08009869 if (eHAL_STATUS_SUCCESS !=
9870 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId))
Wilson Yang6507c4e2013-10-01 20:11:19 -07009871 {
9872 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
9873 __func__,j);
Wilson Yangef657d32014-01-15 19:19:23 -08009874 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009875 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +05309876 /*clear the entry in HDD cache 0--index-1 */
Agarwal Ashish3da95242014-05-21 14:57:17 +05309877 vos_mem_zero(pHddStaCtx->PMKIDCache[j].BSSID, VOS_MAC_ADDR_SIZE);
9878 vos_mem_zero(pHddStaCtx->PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
9879 }
Wilson Yang6507c4e2013-10-01 20:11:19 -07009880
Agarwal Ashish3da95242014-05-21 14:57:17 +05309881 pHddStaCtx->PMKIDCacheIndex = 0;
Wilson Yangef657d32014-01-15 19:19:23 -08009882 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009883}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +05309884
9885static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
9886{
9887 int ret;
9888
9889 vos_ssr_protect(__func__);
9890 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
9891 vos_ssr_unprotect(__func__);
9892
9893 return ret;
9894}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009895#endif
9896
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009897#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309898static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009899 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
9900{
9901 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9902 hdd_station_ctx_t *pHddStaCtx;
9903
9904 if (NULL == pAdapter)
9905 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009906 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009907 return -ENODEV;
9908 }
9909
9910 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9911
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309912 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9913 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
9914 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009915 // Added for debug on reception of Re-assoc Req.
9916 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9917 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009918 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009919 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -08009920 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009921 }
9922
9923#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08009924 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009925 ftie->ie_len);
9926#endif
9927
9928 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05309929 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
9930 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009931 ftie->ie_len);
9932 return 0;
9933}
9934#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009935
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309936#ifdef FEATURE_WLAN_SCAN_PNO
9937
9938void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
9939 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9940{
9941 int ret;
9942 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9943 hdd_context_t *pHddCtx;
9944
Nirav Shah80830bf2013-12-31 16:35:12 +05309945 ENTER();
9946
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309947 if (NULL == pAdapter)
9948 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309949 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309950 "%s: HDD adapter is Null", __func__);
9951 return ;
9952 }
9953
9954 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9955 if (NULL == pHddCtx)
9956 {
9957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9958 "%s: HDD context is Null!!!", __func__);
9959 return ;
9960 }
9961
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309962 spin_lock(&pHddCtx->schedScan_lock);
9963 if (TRUE == pHddCtx->isWiphySuspended)
9964 {
9965 pHddCtx->isSchedScanUpdatePending = TRUE;
9966 spin_unlock(&pHddCtx->schedScan_lock);
9967 hddLog(VOS_TRACE_LEVEL_INFO,
9968 "%s: Update cfg80211 scan database after it resume", __func__);
9969 return ;
9970 }
9971 spin_unlock(&pHddCtx->schedScan_lock);
9972
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309973 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
9974
9975 if (0 > ret)
9976 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
9977
9978 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9980 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309981}
9982
9983/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309984 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05309985 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309986 */
9987static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
9988{
9989 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
9990 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05309991 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309992 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9993 int status = 0;
9994 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
9995
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05309996 /* The current firmware design does not allow PNO during any
9997 * active sessions. Hence, determine the active sessions
9998 * and return a failure.
9999 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053010000 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
10001 {
10002 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053010003 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053010004
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053010005 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
10006 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
10007 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
10008 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
10009 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
10010 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053010011 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053010012 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053010013 }
10014 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10015 pAdapterNode = pNext;
10016 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053010017 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053010018}
10019
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010020void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
10021{
10022 hdd_adapter_t *pAdapter = callbackContext;
10023 hdd_context_t *pHddCtx;
10024
10025 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
10026 {
10027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10028 FL("Invalid adapter or adapter has invalid magic"));
10029 return;
10030 }
10031
10032 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10033 if (0 != wlan_hdd_validate_context(pHddCtx))
10034 {
10035 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10036 FL("HDD context is not valid"));
10037 return;
10038 }
10039
10040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10041 FL("PNO enable response status = %d"), status);
10042
10043 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
10044 complete(&pAdapter->pno_comp_var);
10045}
10046
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053010047/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053010048 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
10049 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010050 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053010051static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010052 struct net_device *dev, struct cfg80211_sched_scan_request *request)
10053{
10054 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10055 tpSirPNOScanReq pPnoRequest = NULL;
10056 hdd_context_t *pHddCtx;
10057 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053010058 v_U32_t i, indx, num_ch, tempInterval;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053010059 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
10060 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010061 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
10062 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010063 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010064
10065 if (NULL == pAdapter)
10066 {
10067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10068 "%s: HDD adapter is Null", __func__);
10069 return -ENODEV;
10070 }
10071
10072 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010073 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010074
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010075 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010076 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053010077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10078 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010079 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010080 }
10081
10082 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10083 if (NULL == hHal)
10084 {
10085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10086 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010087 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010088 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053010089
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010090 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053010091 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053010092 {
10093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10094 "%s: aborting the existing scan is unsuccessfull", __func__);
10095 return -EBUSY;
10096 }
10097
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053010098 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053010099 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053010100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053010101 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053010102 return -EBUSY;
10103 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010104
c_hpothu37f21312014-04-09 21:49:54 +053010105 if (TRUE == pHddCtx->isPnoEnable)
10106 {
10107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10108 FL("already PNO is enabled"));
10109 return -EBUSY;
10110 }
10111 pHddCtx->isPnoEnable = TRUE;
10112
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010113 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
10114 if (NULL == pPnoRequest)
10115 {
10116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10117 "%s: vos_mem_malloc failed", __func__);
c_hpothu37f21312014-04-09 21:49:54 +053010118 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010119 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010120 }
10121
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +053010122 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010123 pPnoRequest->enable = 1; /*Enable PNO */
10124 pPnoRequest->ucNetworksCount = request->n_match_sets;
10125
10126 if (( !pPnoRequest->ucNetworksCount ) ||
10127 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
10128 {
10129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053010130 "%s: Network input is not correct %d Max Network supported is %d",
10131 __func__, pPnoRequest->ucNetworksCount,
10132 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010133 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010134 goto error;
10135 }
10136
10137 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
10138 {
10139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053010140 "%s: Incorrect number of channels %d",
10141 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010142 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010143 goto error;
10144 }
10145
10146 /* Framework provides one set of channels(all)
10147 * common for all saved profile */
10148 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
10149 channels_allowed, &num_channels_allowed))
10150 {
10151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10152 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010153 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010154 goto error;
10155 }
10156 /* Checking each channel against allowed channel list */
10157 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053010158 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010159 {
Nirav Shah80830bf2013-12-31 16:35:12 +053010160 char chList [(request->n_channels*5)+1];
10161 int len;
10162 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010163 {
Nirav Shah80830bf2013-12-31 16:35:12 +053010164 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010165 {
Nirav Shah80830bf2013-12-31 16:35:12 +053010166 if (request->channels[i]->hw_value == channels_allowed[indx])
10167 {
10168 valid_ch[num_ch++] = request->channels[i]->hw_value;
10169 len += snprintf(chList+len, 5, "%d ",
10170 request->channels[i]->hw_value);
10171 break ;
10172 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010173 }
10174 }
Nirav Shah80830bf2013-12-31 16:35:12 +053010175 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
10176 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010177
10178 /* Filling per profile params */
10179 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
10180 {
10181 pPnoRequest->aNetworks[i].ssId.length =
10182 request->match_sets[i].ssid.ssid_len;
10183
10184 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
10185 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
10186 {
10187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053010188 "%s: SSID Len %d is not correct for network %d",
10189 __func__, pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010190 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010191 goto error;
10192 }
10193
10194 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
10195 request->match_sets[i].ssid.ssid,
10196 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053010197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10198 "%s: SSID of network %d is %s ", __func__,
10199 i, pPnoRequest->aNetworks[i].ssId.ssId);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010200 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
10201 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
10202 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
10203
10204 /*Copying list of valid channel into request */
10205 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
10206 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
10207
10208 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
10209 }
10210
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053010211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080010212 "request->ie_len = %zu", request->ie_len);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053010213 if ((0 < request->ie_len) && (NULL != request->ie))
10214 {
10215 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
10216 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
10217 pPnoRequest->us24GProbeTemplateLen);
10218
10219 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
10220 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
10221 pPnoRequest->us5GProbeTemplateLen);
10222 }
10223
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053010224 /* Driver gets only one time interval which is hardcoded in
10225 * supplicant for 10000ms. Taking power consumption into account 6 timers
10226 * will be used, Timervalue is increased exponentially i.e 10,20,40,
10227 * 80,160,320 secs. And number of scan cycle for each timer
10228 * is configurable through INI param gPNOScanTimerRepeatValue.
10229 * If it is set to 0 only one timer will be used and PNO scan cycle
10230 * will be repeated after each interval specified by supplicant
10231 * till PNO is disabled.
10232 */
10233 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
10234 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
10235 else
10236 pPnoRequest->scanTimers.ucScanTimersCount =
10237 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
10238
10239 tempInterval = (request->interval)/1000;
10240 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10241 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
10242 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
10243 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
10244 {
10245 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
10246 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
10247 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
10248 tempInterval *= 2;
10249 }
10250 //Repeat last timer until pno disabled.
10251 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
10252
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +053010253 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010254
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010255 INIT_COMPLETION(pAdapter->pno_comp_var);
10256 pPnoRequest->statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
10257 pPnoRequest->callbackContext = pAdapter;
10258 pAdapter->pno_req_status = 0;
10259
Nirav Shah80830bf2013-12-31 16:35:12 +053010260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10261 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
10262 pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO,
10263 pPnoRequest->scanTimers.ucScanTimersCount);
10264
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010265 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
10266 pPnoRequest, pAdapter->sessionId,
10267 hdd_cfg80211_sched_scan_done_callback, pAdapter);
10268 if (eHAL_STATUS_SUCCESS != status)
10269 {
10270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053010271 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010272 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010273 goto error;
10274 }
10275
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010276 ret = wait_for_completion_timeout(
10277 &pAdapter->pno_comp_var,
10278 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
10279 if (0 >= ret)
10280 {
10281 // Did not receive the response for PNO enable in time.
10282 // Assuming the PNO enable was success.
10283 // Returning error from here, because we timeout, results
10284 // in side effect of Wifi (Wifi Setting) not to work.
10285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10286 FL("Timed out waiting for PNO to be Enabled"));
10287 ret = 0;
10288 goto error;
10289 }
10290
10291 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053010292 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010293
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010294error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10296 FL("PNO scanRequest offloaded ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010297 vos_mem_free(pPnoRequest);
c_hpothu37f21312014-04-09 21:49:54 +053010298 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010299 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010300}
10301
10302/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053010303 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
10304 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010305 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053010306static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
10307 struct net_device *dev, struct cfg80211_sched_scan_request *request)
10308{
10309 int ret;
10310
10311 vos_ssr_protect(__func__);
10312 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
10313 vos_ssr_unprotect(__func__);
10314
10315 return ret;
10316}
10317
10318/*
10319 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
10320 * Function to disable PNO
10321 */
10322static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010323 struct net_device *dev)
10324{
10325 eHalStatus status = eHAL_STATUS_FAILURE;
10326 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10327 hdd_context_t *pHddCtx;
10328 tHalHandle hHal;
10329 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010330 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010331
10332 ENTER();
10333
10334 if (NULL == pAdapter)
10335 {
10336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10337 "%s: HDD adapter is Null", __func__);
10338 return -ENODEV;
10339 }
10340
10341 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010342
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010343 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010344 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053010345 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010346 "%s: HDD context is Null", __func__);
10347 return -ENODEV;
10348 }
10349
10350 /* The return 0 is intentional when isLogpInProgress and
10351 * isLoadUnloadInProgress. We did observe a crash due to a return of
10352 * failure in sched_scan_stop , especially for a case where the unload
10353 * of the happens at the same time. The function __cfg80211_stop_sched_scan
10354 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
10355 * success. If it returns a failure , then its next invocation due to the
10356 * clean up of the second interface will have the dev pointer corresponding
10357 * to the first one leading to a crash.
10358 */
10359 if (pHddCtx->isLogpInProgress)
10360 {
10361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10362 "%s: LOGP in Progress. Ignore!!!", __func__);
10363 return ret;
10364 }
10365
Mihir Shete18156292014-03-11 15:38:30 +053010366 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010367 {
10368 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10369 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
10370 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010371 }
10372
10373 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10374 if (NULL == hHal)
10375 {
10376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10377 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010378 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010379 }
10380
10381 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
10382 if (NULL == pPnoRequest)
10383 {
10384 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10385 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010386 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010387 }
10388
10389 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
10390 pPnoRequest->enable = 0; /* Disable PNO */
10391 pPnoRequest->ucNetworksCount = 0;
10392
10393 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
10394 pAdapter->sessionId,
10395 NULL, pAdapter);
10396 if (eHAL_STATUS_SUCCESS != status)
10397 {
10398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10399 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010400 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010401 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010402 }
c_hpothu37f21312014-04-09 21:49:54 +053010403 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010404
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010405error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010406 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010407 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010408 vos_mem_free(pPnoRequest);
10409
10410 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010411 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010412}
10413
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053010414/*
10415 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
10416 * NL interface to disable PNO
10417 */
10418static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
10419 struct net_device *dev)
10420{
10421 int ret;
10422
10423 vos_ssr_protect(__func__);
10424 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
10425 vos_ssr_unprotect(__func__);
10426
10427 return ret;
10428}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010429#endif /*FEATURE_WLAN_SCAN_PNO*/
10430
10431
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010432#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053010433#if TDLS_MGMT_VERSION2
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010434static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
10435 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053010436 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
10437#else
10438static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
10439 u8 *peer, u8 action_code, u8 dialog_token,
10440 u16 status_code, const u8 *buf, size_t len)
10441#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010442{
10443
10444 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10445 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010446 u8 peerMac[6];
10447 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070010448 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080010449 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070010450 long rc;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053010451#if !(TDLS_MGMT_VERSION2)
10452 u32 peer_capability = 0;
10453#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010454 tANI_U16 numCurrTdlsPeers;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010455
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010456 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10457 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
10458 pAdapter->sessionId, action_code));
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010459 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010460 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010461 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010462 "Invalid arguments");
10463 return -EINVAL;
10464 }
10465
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010466 if (pHddCtx->isLogpInProgress)
10467 {
10468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10469 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010470 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010471 return -EBUSY;
10472 }
10473
Hoonki Lee27511902013-03-14 18:19:06 -070010474 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010475 {
Hoonki Lee27511902013-03-14 18:19:06 -070010476 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
10477 "%s: TDLS mode is disabled OR not enabled in FW."
10478 MAC_ADDRESS_STR " action %d declined.",
10479 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010480 return -ENOTSUPP;
10481 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080010482
Hoonki Lee27511902013-03-14 18:19:06 -070010483 /* other than teardown frame, other mgmt frames are not sent if disabled */
10484 if (SIR_MAC_TDLS_TEARDOWN != action_code)
10485 {
10486 /* if tdls_mode is disabled to respond to peer's request */
10487 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
10488 {
10489 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
10490 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010491 " TDLS mode is disabled. action %d declined.",
10492 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070010493
10494 return -ENOTSUPP;
10495 }
10496 }
10497
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010498 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
10499 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010500 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010501 {
10502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010503 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010504 " TDLS setup is ongoing. action %d declined.",
10505 __func__, MAC_ADDR_ARRAY(peer), action_code);
10506 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010507 }
10508 }
10509
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010510 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
10511 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080010512 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010513 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
10514 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080010515 {
10516 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
10517 we return error code at 'add_station()'. Hence we have this
10518 check again in addtion to add_station().
10519 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010520 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080010521 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010522 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10523 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010524 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
10525 __func__, MAC_ADDR_ARRAY(peer), action_code,
10526 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053010527 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080010528 }
10529 else
10530 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010531 /* maximum reached. tweak to send error code to peer and return
10532 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080010533 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010534 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10535 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010536 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
10537 __func__, MAC_ADDR_ARRAY(peer), status_code,
10538 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010539 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010540 /* fall through to send setup resp with failure status
10541 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080010542 }
10543 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010544 else
10545 {
10546 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010547 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010548 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010549 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010550 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010551 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
10552 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010553 return -EPERM;
10554 }
10555 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080010556 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010557 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010558
Hoonki Lee1090c6a2013-01-16 17:40:54 -080010559#ifdef WLAN_FEATURE_TDLS_DEBUG
10560 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053010561 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010562 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
10563 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -080010564#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010565
Hoonki Leea34dd892013-02-05 22:56:02 -080010566 /*Except teardown responder will not be used so just make 0*/
10567 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010568 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080010569 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070010570
10571 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010572 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070010573
10574 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
10575 responder = pTdlsPeer->is_responder;
10576 else
Hoonki Leea34dd892013-02-05 22:56:02 -080010577 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070010578 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053010579 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %zu",
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070010580 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
10581 dialog_token, status_code, len);
10582 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080010583 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010584 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010585
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053010586 /* For explicit trigger of DIS_REQ come out of BMPS for
10587 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070010588 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053010589 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
10590 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070010591 {
10592 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
10593 {
10594 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053010595 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -070010596 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
10597 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053010598 if (SIR_MAC_TDLS_DIS_REQ != action_code)
10599 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -070010600 }
10601
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010602 /* make sure doesn't call send_mgmt() while it is pending */
10603 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
10604 {
10605 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010606 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010607 __func__, MAC_ADDR_ARRAY(peer), action_code);
10608 return -EBUSY;
10609 }
10610
10611 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010612 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
10613
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010614 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053010615 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010616
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010617 if (VOS_STATUS_SUCCESS != status)
10618 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10620 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010621 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -070010622 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053010623 return -EINVAL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010624 }
10625
Hoonki Leed37cbb32013-04-20 00:31:14 -070010626 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
10627 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
10628
10629 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010630 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070010631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010632 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070010633 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010634 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080010635
10636 if (pHddCtx->isLogpInProgress)
10637 {
10638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10639 "%s: LOGP in Progress. Ignore!!!", __func__);
10640 return -EAGAIN;
10641 }
10642
Hoonki Leed37cbb32013-04-20 00:31:14 -070010643 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053010644 return -EINVAL;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010645 }
10646
Gopichand Nakkala05922802013-03-14 12:23:19 -070010647 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070010648 {
10649 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010650 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070010651 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010652
Hoonki Leea34dd892013-02-05 22:56:02 -080010653 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
10654 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080010655 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -080010656 }
10657 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
10658 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080010659 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -080010660 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010661
10662 return 0;
10663}
10664
10665static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
10666 u8 *peer, enum nl80211_tdls_operation oper)
10667{
10668 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10669 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010670 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010671 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010672
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010673 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10674 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
10675 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010676 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010677 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010678 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070010679 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010680 return -EINVAL;
10681 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080010682
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010683 status = wlan_hdd_validate_context(pHddCtx);
10684
10685 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010686 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010687 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10688 "%s: HDD context is not valid", __func__);
10689 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010690 }
10691
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010692
10693 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080010694 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010695 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080010696 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070010697 "TDLS Disabled in INI OR not enabled in FW. "
10698 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010699 return -ENOTSUPP;
10700 }
10701
10702 switch (oper) {
10703 case NL80211_TDLS_ENABLE_LINK:
10704 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010705 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010706 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010707 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010708
Sunil Dutt41de4e22013-11-14 18:09:02 +053010709 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
10710
10711 if ( NULL == pTdlsPeer ) {
10712 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
10713 " (oper %d) not exsting. ignored",
10714 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
10715 return -EINVAL;
10716 }
10717
10718 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10719 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
10720 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
10721 "NL80211_TDLS_ENABLE_LINK");
10722
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070010723 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
10724 {
10725 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
10726 MAC_ADDRESS_STR " failed",
10727 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
10728 return -EINVAL;
10729 }
10730
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010731 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010732 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053010733 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053010734
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053010735 if (0 != wlan_hdd_tdls_get_link_establish_params(
10736 pAdapter, peer,&tdlsLinkEstablishParams)) {
10737 return -EINVAL;
10738 }
10739 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010740
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053010741 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
10742 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
10743 /* Send TDLS peer UAPSD capabilities to the firmware and
10744 * register with the TL on after the response for this operation
10745 * is received .
10746 */
10747 ret = wait_for_completion_interruptible_timeout(
10748 &pAdapter->tdls_link_establish_req_comp,
10749 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
10750 if (ret <= 0)
10751 {
10752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10753 "%s: Link Establish Request Faled Status %ld",
10754 __func__, ret);
10755 return -EINVAL;
10756 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010757 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070010758 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +053010759 /* Mark TDLS client Authenticated .*/
10760 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
10761 pTdlsPeer->staId,
10762 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070010763 if (VOS_STATUS_SUCCESS == status)
10764 {
Hoonki Lee14621352013-04-16 17:51:19 -070010765 if (pTdlsPeer->is_responder == 0)
10766 {
10767 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
10768
10769 wlan_hdd_tdls_timer_restart(pAdapter,
10770 &pTdlsPeer->initiatorWaitTimeoutTimer,
10771 WAIT_TIME_TDLS_INITIATOR);
10772 /* suspend initiator TX until it receives direct packet from the
10773 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
10774 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
10775 &staId, NULL);
10776 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070010777 wlan_hdd_tdls_increment_peer_count(pAdapter);
10778 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010779 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010780
10781 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010782 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
10783 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010784 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010785 int ac;
10786 uint8 ucAc[4] = { WLANTL_AC_VO,
10787 WLANTL_AC_VI,
10788 WLANTL_AC_BK,
10789 WLANTL_AC_BE };
10790 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
10791 for(ac=0; ac < 4; ac++)
10792 {
10793 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
10794 pTdlsPeer->staId, ucAc[ac],
10795 tlTid[ac], tlTid[ac], 0, 0,
10796 WLANTL_BI_DIR );
10797 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010798 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010799 }
10800
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010801 }
10802 break;
10803 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080010804 {
Sunil Dutt41de4e22013-11-14 18:09:02 +053010805 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
10806
10807 if ( NULL == pTdlsPeer ) {
10808 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
10809 " (oper %d) not exsting. ignored",
10810 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
10811 return -EINVAL;
10812 }
10813
10814 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10815 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
10816 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
10817 "NL80211_TDLS_DISABLE_LINK");
10818
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010819 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080010820 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010821 long status;
10822
10823 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
10824
Lee Hoonkic1262f22013-01-24 21:59:00 -080010825 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
10826 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010827
10828 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
10829 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
10830 if (status <= 0)
10831 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010832 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010833 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10834 "%s: Del station failed status %ld",
10835 __func__, status);
10836 return -EPERM;
10837 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010838 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -080010839 }
10840 else
10841 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10843 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080010844 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080010845 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010846 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010847 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053010848 {
10849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10850 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
10851 __func__, MAC_ADDR_ARRAY(peer));
10852
10853 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
10854 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
10855
10856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10857 " %s TDLS External control and Implicit Trigger not enabled ",
10858 __func__);
10859 return -ENOTSUPP;
10860 }
10861
Sunil Dutt41de4e22013-11-14 18:09:02 +053010862
10863 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
10864
10865 if ( NULL == pTdlsPeer ) {
10866 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
10867 " peer not exsting",
10868 __func__, MAC_ADDR_ARRAY(peer));
Naresh Jayaram937abdf2013-11-26 19:50:25 +053010869 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +053010870 }
10871 else {
10872 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
10873 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
10874 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +053010875
10876 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) )
10877 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +053010878 break;
10879 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010880 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053010881 {
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053010882 hddTdlsPeer_t *pTdlsPeer;
Sunil Dutt41de4e22013-11-14 18:09:02 +053010883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10884 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
10885 __func__, MAC_ADDR_ARRAY(peer));
10886
10887 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
10888 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
10889
10890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10891 " %s TDLS External control and Implicit Trigger not enabled ",
10892 __func__);
10893 return -ENOTSUPP;
10894 }
10895
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053010896 /* To cater the requirement of establishing the TDLS link
10897 * irrespective of the data traffic , get an entry of TDLS peer.
10898 */
10899 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
10900 if (pTdlsPeer == NULL) {
10901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10902 "%s: peer " MAC_ADDRESS_STR " not existing",
10903 __func__, MAC_ADDR_ARRAY(peer));
10904 return -EINVAL;
10905 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +053010906
10907 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
10908
10909 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10910 " %s TDLS Add Force Peer Failed",
10911 __func__);
10912 return -EINVAL;
10913 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053010914 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053010915 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010916 case NL80211_TDLS_DISCOVERY_REQ:
10917 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10919 "%s: We don't support in-driver setup/teardown/discovery "
10920 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010921 return -ENOTSUPP;
10922 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10924 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010925 return -ENOTSUPP;
10926 }
10927 return 0;
10928}
Chilam NG571c65a2013-01-19 12:27:36 +053010929
10930int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
10931 struct net_device *dev, u8 *peer)
10932{
Arif Hussaina7c8e412013-11-20 11:06:42 -080010933 hddLog(VOS_TRACE_LEVEL_INFO,
10934 "tdls send discover req: "MAC_ADDRESS_STR,
10935 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053010936
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053010937#if TDLS_MGMT_VERSION2
10938 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
10939 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
10940#else
Chilam NG571c65a2013-01-19 12:27:36 +053010941 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
10942 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053010943#endif
Chilam NG571c65a2013-01-19 12:27:36 +053010944}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010945#endif
10946
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010947#ifdef WLAN_FEATURE_GTK_OFFLOAD
10948/*
10949 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
10950 * Callback rountine called upon receiving response for
10951 * get offload info
10952 */
10953void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
10954 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
10955{
10956
10957 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010958 tANI_U8 tempReplayCounter[8];
10959 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010960
10961 ENTER();
10962
10963 if (NULL == pAdapter)
10964 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010965 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010966 "%s: HDD adapter is Null", __func__);
10967 return ;
10968 }
10969
10970 if (NULL == pGtkOffloadGetInfoRsp)
10971 {
10972 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10973 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
10974 return ;
10975 }
10976
10977 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
10978 {
10979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10980 "%s: wlan Failed to get replay counter value",
10981 __func__);
10982 return ;
10983 }
10984
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010985 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10986 /* Update replay counter */
10987 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
10988 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
10989
10990 {
10991 /* changing from little to big endian since supplicant
10992 * works on big endian format
10993 */
10994 int i;
10995 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
10996
10997 for (i = 0; i < 8; i++)
10998 {
10999 tempReplayCounter[7-i] = (tANI_U8)p[i];
11000 }
11001 }
11002
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011003 /* Update replay counter to NL */
11004 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011005 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011006}
11007
11008/*
11009 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
11010 * This function is used to offload GTK rekeying job to the firmware.
11011 */
11012int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
11013 struct cfg80211_gtk_rekey_data *data)
11014{
11015 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11016 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
11017 hdd_station_ctx_t *pHddStaCtx;
11018 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011019 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011020 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011021 eHalStatus status = eHAL_STATUS_FAILURE;
11022
11023 ENTER();
11024
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011025
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011026 if (NULL == pAdapter)
11027 {
11028 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11029 "%s: HDD adapter is Null", __func__);
11030 return -ENODEV;
11031 }
11032
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011033 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11034 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
11035 pAdapter->sessionId, pAdapter->device_mode));
11036
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011037 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011038
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011039 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011040 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011041 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11042 "%s: HDD context is not valid", __func__);
11043 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011044 }
11045
11046 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11047 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
11048 if (NULL == hHal)
11049 {
11050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11051 "%s: HAL context is Null!!!", __func__);
11052 return -EAGAIN;
11053 }
11054
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011055 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
11056 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
11057 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
11058 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011059 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011060 {
11061 /* changing from big to little endian since driver
11062 * works on little endian format
11063 */
11064 tANI_U8 *p =
11065 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
11066 int i;
11067
11068 for (i = 0; i < 8; i++)
11069 {
11070 p[7-i] = data->replay_ctr[i];
11071 }
11072 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011073
11074 if (TRUE == pHddCtx->hdd_wlan_suspended)
11075 {
11076 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011077 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
11078 sizeof (tSirGtkOffloadParams));
11079 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011080 pAdapter->sessionId);
11081
11082 if (eHAL_STATUS_SUCCESS != status)
11083 {
11084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11085 "%s: sme_SetGTKOffload failed, returned %d",
11086 __func__, status);
11087 return status;
11088 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011089 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11090 "%s: sme_SetGTKOffload successfull", __func__);
11091 }
11092 else
11093 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11095 "%s: wlan not suspended GTKOffload request is stored",
11096 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011097 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011098
11099 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011100}
11101#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
11102
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011103/*
11104 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
11105 * This function is used to set access control policy
11106 */
11107static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
11108 struct net_device *dev, const struct cfg80211_acl_data *params)
11109{
11110 int i;
11111 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11112 hdd_hostapd_state_t *pHostapdState;
11113 tsap_Config_t *pConfig;
11114 v_CONTEXT_t pVosContext = NULL;
11115 hdd_context_t *pHddCtx;
11116 int status;
11117
11118 ENTER();
11119
11120 if (NULL == pAdapter)
11121 {
11122 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11123 "%s: HDD adapter is Null", __func__);
11124 return -ENODEV;
11125 }
11126
11127 if (NULL == params)
11128 {
11129 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11130 "%s: params is Null", __func__);
11131 return -EINVAL;
11132 }
11133
11134 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11135 status = wlan_hdd_validate_context(pHddCtx);
11136
11137 if (0 != status)
11138 {
11139 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11140 "%s: HDD context is not valid", __func__);
11141 return status;
11142 }
11143
11144 pVosContext = pHddCtx->pvosContext;
11145 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
11146
11147 if (NULL == pHostapdState)
11148 {
11149 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11150 "%s: pHostapdState is Null", __func__);
11151 return -EINVAL;
11152 }
11153
11154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
11155 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
11156
11157 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
11158 {
11159 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
11160
11161 /* default value */
11162 pConfig->num_accept_mac = 0;
11163 pConfig->num_deny_mac = 0;
11164
11165 /**
11166 * access control policy
11167 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
11168 * listed in hostapd.deny file.
11169 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
11170 * listed in hostapd.accept file.
11171 */
11172 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
11173 {
11174 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
11175 }
11176 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
11177 {
11178 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
11179 }
11180 else
11181 {
11182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11183 "%s:Acl Policy : %d is not supported",
11184 __func__, params->acl_policy);
11185 return -ENOTSUPP;
11186 }
11187
11188 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
11189 {
11190 pConfig->num_accept_mac = params->n_acl_entries;
11191 for (i = 0; i < params->n_acl_entries; i++)
11192 {
11193 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11194 "** Add ACL MAC entry %i in WhiletList :"
11195 MAC_ADDRESS_STR, i,
11196 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
11197
11198 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
11199 sizeof(qcmacaddr));
11200 }
11201 }
11202 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
11203 {
11204 pConfig->num_deny_mac = params->n_acl_entries;
11205 for (i = 0; i < params->n_acl_entries; i++)
11206 {
11207 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11208 "** Add ACL MAC entry %i in BlackList :"
11209 MAC_ADDRESS_STR, i,
11210 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
11211
11212 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
11213 sizeof(qcmacaddr));
11214 }
11215 }
11216
11217 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
11218 {
11219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11220 "%s: SAP Set Mac Acl fail", __func__);
11221 return -EINVAL;
11222 }
11223 }
11224 else
11225 {
11226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011227 "%s: Invalid device_mode = %s (%d)",
11228 __func__, hdd_device_modetoString(pAdapter->device_mode),
11229 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011230 return -EINVAL;
11231 }
11232
11233 return 0;
11234}
11235
Leo Chang9056f462013-08-01 19:21:11 -070011236#ifdef WLAN_NL80211_TESTMODE
11237#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070011238void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070011239(
11240 void *pAdapter,
11241 void *indCont
11242)
11243{
Leo Changd9df8aa2013-09-26 13:32:26 -070011244 tSirLPHBInd *lphbInd;
11245 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053011246 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070011247
11248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070011249 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070011250
c_hpothu73f35e62014-04-18 13:40:08 +053011251 if (pAdapter == NULL)
11252 {
11253 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11254 "%s: pAdapter is NULL\n",__func__);
11255 return;
11256 }
11257
Leo Chang9056f462013-08-01 19:21:11 -070011258 if (NULL == indCont)
11259 {
11260 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070011261 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070011262 return;
11263 }
11264
c_hpothu73f35e62014-04-18 13:40:08 +053011265 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070011266 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070011267 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053011268 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070011269 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070011270 GFP_ATOMIC);
11271 if (!skb)
11272 {
11273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11274 "LPHB timeout, NL buffer alloc fail");
11275 return;
11276 }
11277
Leo Changac3ba772013-10-07 09:47:04 -070011278 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070011279 {
11280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11281 "WLAN_HDD_TM_ATTR_CMD put fail");
11282 goto nla_put_failure;
11283 }
Leo Changac3ba772013-10-07 09:47:04 -070011284 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070011285 {
11286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11287 "WLAN_HDD_TM_ATTR_TYPE put fail");
11288 goto nla_put_failure;
11289 }
Leo Changac3ba772013-10-07 09:47:04 -070011290 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070011291 sizeof(tSirLPHBInd), lphbInd))
11292 {
11293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11294 "WLAN_HDD_TM_ATTR_DATA put fail");
11295 goto nla_put_failure;
11296 }
Leo Chang9056f462013-08-01 19:21:11 -070011297 cfg80211_testmode_event(skb, GFP_ATOMIC);
11298 return;
11299
11300nla_put_failure:
11301 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11302 "NLA Put fail");
11303 kfree_skb(skb);
11304
11305 return;
11306}
11307#endif /* FEATURE_WLAN_LPHB */
11308
11309static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
11310{
11311 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
11312 int err = 0;
11313#ifdef FEATURE_WLAN_LPHB
11314 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070011315 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -070011316#endif /* FEATURE_WLAN_LPHB */
11317
11318 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
11319 if (err)
11320 {
11321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11322 "%s Testmode INV ATTR", __func__);
11323 return err;
11324 }
11325
11326 if (!tb[WLAN_HDD_TM_ATTR_CMD])
11327 {
11328 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11329 "%s Testmode INV CMD", __func__);
11330 return -EINVAL;
11331 }
11332
11333 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
11334 {
11335#ifdef FEATURE_WLAN_LPHB
11336 /* Low Power Heartbeat configuration request */
11337 case WLAN_HDD_TM_CMD_WLAN_HB:
11338 {
11339 int buf_len;
11340 void *buf;
11341 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080011342 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070011343
11344 if (!tb[WLAN_HDD_TM_ATTR_DATA])
11345 {
11346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11347 "%s Testmode INV DATA", __func__);
11348 return -EINVAL;
11349 }
11350
11351 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
11352 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080011353
11354 hb_params_temp =(tSirLPHBReq *)buf;
11355 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
11356 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
11357 return -EINVAL;
11358
Leo Chang9056f462013-08-01 19:21:11 -070011359 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
11360 if (NULL == hb_params)
11361 {
11362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11363 "%s Request Buffer Alloc Fail", __func__);
11364 return -EINVAL;
11365 }
11366
11367 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070011368 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
11369 hb_params,
11370 wlan_hdd_cfg80211_lphb_ind_handler);
11371 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070011372 {
Leo Changd9df8aa2013-09-26 13:32:26 -070011373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11374 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070011375 vos_mem_free(hb_params);
11376 }
Leo Chang9056f462013-08-01 19:21:11 -070011377 return 0;
11378 }
11379#endif /* FEATURE_WLAN_LPHB */
11380 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11382 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070011383 return -EOPNOTSUPP;
11384 }
11385
11386 return err;
11387}
11388#endif /* CONFIG_NL80211_TESTMODE */
11389
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011390static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
11391 struct net_device *dev,
11392 int idx, struct survey_info *survey)
11393{
11394 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11395 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053011396 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011397 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053011398 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011399 v_S7_t snr,rssi;
11400 int status, i, j, filled = 0;
11401
11402 ENTER();
11403
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011404 if (NULL == pAdapter)
11405 {
11406 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11407 "%s: HDD adapter is Null", __func__);
11408 return -ENODEV;
11409 }
11410
11411 if (NULL == wiphy)
11412 {
11413 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11414 "%s: wiphy is Null", __func__);
11415 return -ENODEV;
11416 }
11417
11418 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11419 status = wlan_hdd_validate_context(pHddCtx);
11420
11421 if (0 != status)
11422 {
11423 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11424 "%s: HDD context is not valid", __func__);
11425 return status;
11426 }
11427
Mihir Sheted9072e02013-08-21 17:02:29 +053011428 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11429
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011430 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053011431 0 != pAdapter->survey_idx ||
11432 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011433 {
11434 /* The survey dump ops when implemented completely is expected to
11435 * return a survey of all channels and the ops is called by the
11436 * kernel with incremental values of the argument 'idx' till it
11437 * returns -ENONET. But we can only support the survey for the
11438 * operating channel for now. survey_idx is used to track
11439 * that the ops is called only once and then return -ENONET for
11440 * the next iteration
11441 */
11442 pAdapter->survey_idx = 0;
11443 return -ENONET;
11444 }
11445
11446 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
11447
11448 wlan_hdd_get_snr(pAdapter, &snr);
11449 wlan_hdd_get_rssi(pAdapter, &rssi);
11450
11451 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
11452 hdd_wlan_get_freq(channel, &freq);
11453
11454
11455 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
11456 {
11457 if (NULL == wiphy->bands[i])
11458 {
11459 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
11460 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
11461 continue;
11462 }
11463
11464 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
11465 {
11466 struct ieee80211_supported_band *band = wiphy->bands[i];
11467
11468 if (band->channels[j].center_freq == (v_U16_t)freq)
11469 {
11470 survey->channel = &band->channels[j];
11471 /* The Rx BDs contain SNR values in dB for the received frames
11472 * while the supplicant expects noise. So we calculate and
11473 * return the value of noise (dBm)
11474 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
11475 */
11476 survey->noise = rssi - snr;
11477 survey->filled = SURVEY_INFO_NOISE_DBM;
11478 filled = 1;
11479 }
11480 }
11481 }
11482
11483 if (filled)
11484 pAdapter->survey_idx = 1;
11485 else
11486 {
11487 pAdapter->survey_idx = 0;
11488 return -ENONET;
11489 }
11490
11491 return 0;
11492}
11493
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011494/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053011495 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011496 * this is called when cfg80211 driver resume
11497 * driver updates latest sched_scan scan result(if any) to cfg80211 database
11498 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053011499int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011500{
11501 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
11502 hdd_adapter_t *pAdapter;
11503 hdd_adapter_list_node_t *pAdapterNode, *pNext;
11504 VOS_STATUS status = VOS_STATUS_SUCCESS;
11505
11506 ENTER();
11507
11508 if ( NULL == pHddCtx )
11509 {
11510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11511 "%s: HddCtx validation failed", __func__);
11512 return 0;
11513 }
11514
11515 if (pHddCtx->isLogpInProgress)
11516 {
11517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11518 "%s: LOGP in Progress. Ignore!!!", __func__);
11519 return 0;
11520 }
11521
Mihir Shete18156292014-03-11 15:38:30 +053011522 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011523 {
11524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11525 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
11526 return 0;
11527 }
11528
11529 spin_lock(&pHddCtx->schedScan_lock);
11530 pHddCtx->isWiphySuspended = FALSE;
11531 if (TRUE != pHddCtx->isSchedScanUpdatePending)
11532 {
11533 spin_unlock(&pHddCtx->schedScan_lock);
11534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11535 "%s: Return resume is not due to PNO indication", __func__);
11536 return 0;
11537 }
11538 // Reset flag to avoid updatating cfg80211 data old results again
11539 pHddCtx->isSchedScanUpdatePending = FALSE;
11540 spin_unlock(&pHddCtx->schedScan_lock);
11541
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053011542
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011543 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
11544
11545 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
11546 {
11547 pAdapter = pAdapterNode->pAdapter;
11548 if ( (NULL != pAdapter) &&
11549 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
11550 {
11551 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053011552 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
11554 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053011555 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011556 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053011557 {
11558 /* Acquire wakelock to handle the case where APP's tries to
11559 * suspend immediately after updating the scan results. Whis
11560 * results in app's is in suspended state and not able to
11561 * process the connect request to AP
11562 */
11563 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011564 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053011565 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011566
11567 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11568 "%s : cfg80211 scan result database updated", __func__);
11569
11570 return 0;
11571
11572 }
11573 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
11574 pAdapterNode = pNext;
11575 }
11576
11577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11578 "%s: Failed to find Adapter", __func__);
11579 return 0;
11580}
11581
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053011582int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
11583{
11584 int ret;
11585
11586 vos_ssr_protect(__func__);
11587 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
11588 vos_ssr_unprotect(__func__);
11589
11590 return ret;
11591}
11592
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011593/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053011594 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011595 * this is called when cfg80211 driver suspends
11596 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053011597int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011598 struct cfg80211_wowlan *wow)
11599{
11600 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
11601
11602 ENTER();
11603 if (NULL == pHddCtx)
11604 {
11605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11606 "%s: HddCtx validation failed", __func__);
11607 return 0;
11608 }
11609
11610 pHddCtx->isWiphySuspended = TRUE;
11611
11612 EXIT();
11613
11614 return 0;
11615}
11616
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053011617int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
11618 struct cfg80211_wowlan *wow)
11619{
11620 int ret;
11621
11622 vos_ssr_protect(__func__);
11623 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
11624 vos_ssr_unprotect(__func__);
11625
11626 return ret;
11627}
Jeff Johnson295189b2012-06-20 16:38:30 -070011628/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011629static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070011630{
11631 .add_virtual_intf = wlan_hdd_add_virtual_intf,
11632 .del_virtual_intf = wlan_hdd_del_virtual_intf,
11633 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
11634 .change_station = wlan_hdd_change_station,
11635#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
11636 .add_beacon = wlan_hdd_cfg80211_add_beacon,
11637 .del_beacon = wlan_hdd_cfg80211_del_beacon,
11638 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011639#else
11640 .start_ap = wlan_hdd_cfg80211_start_ap,
11641 .change_beacon = wlan_hdd_cfg80211_change_beacon,
11642 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070011643#endif
11644 .change_bss = wlan_hdd_cfg80211_change_bss,
11645 .add_key = wlan_hdd_cfg80211_add_key,
11646 .get_key = wlan_hdd_cfg80211_get_key,
11647 .del_key = wlan_hdd_cfg80211_del_key,
11648 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080011649#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070011650 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080011651#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 .scan = wlan_hdd_cfg80211_scan,
11653 .connect = wlan_hdd_cfg80211_connect,
11654 .disconnect = wlan_hdd_cfg80211_disconnect,
11655 .join_ibss = wlan_hdd_cfg80211_join_ibss,
11656 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
11657 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
11658 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
11659 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070011660 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
11661 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053011662 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070011663#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11664 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
11665 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
11666 .set_txq_params = wlan_hdd_set_txq_params,
11667#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011668 .get_station = wlan_hdd_cfg80211_get_station,
11669 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
11670 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011671 .add_station = wlan_hdd_cfg80211_add_station,
11672#ifdef FEATURE_WLAN_LFR
11673 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
11674 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
11675 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
11676#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011677#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
11678 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
11679#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011680#ifdef FEATURE_WLAN_TDLS
11681 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
11682 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
11683#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011684#ifdef WLAN_FEATURE_GTK_OFFLOAD
11685 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
11686#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053011687#ifdef FEATURE_WLAN_SCAN_PNO
11688 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
11689 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
11690#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011691 .resume = wlan_hdd_cfg80211_resume_wlan,
11692 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011693 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070011694#ifdef WLAN_NL80211_TESTMODE
11695 .testmode_cmd = wlan_hdd_cfg80211_testmode,
11696#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011697 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070011698};
11699