blob: 76dded69d691d368ef7e7d01c2add61efc11542c [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
Dino Mycle6fb96c12014-06-10 11:52:40 +0530156#ifdef WLAN_FEATURE_EXTSCAN
157/*
158 * Used to allocate the size of 4096 for the EXTScan NL data.
159 * The size of 4096 is considered assuming that all data per
160 * respective event fit with in the limit.Please take a call
161 * on the limit based on the data requirements.
162 */
163
164#define EXTSCAN_EVENT_BUF_SIZE 4096
165#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
166#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530167
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530168static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700169{
170 WLAN_CIPHER_SUITE_WEP40,
171 WLAN_CIPHER_SUITE_WEP104,
172 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800173#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700174#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
175 WLAN_CIPHER_SUITE_KRK,
176 WLAN_CIPHER_SUITE_CCMP,
177#else
178 WLAN_CIPHER_SUITE_CCMP,
179#endif
180#ifdef FEATURE_WLAN_WAPI
181 WLAN_CIPHER_SUITE_SMS4,
182#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700183#ifdef WLAN_FEATURE_11W
184 WLAN_CIPHER_SUITE_AES_CMAC,
185#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700186};
187
188static inline int is_broadcast_ether_addr(const u8 *addr)
189{
190 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
191 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
192}
193
194static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530195{
Jeff Johnson295189b2012-06-20 16:38:30 -0700196 HDD2GHZCHAN(2412, 1, 0) ,
197 HDD2GHZCHAN(2417, 2, 0) ,
198 HDD2GHZCHAN(2422, 3, 0) ,
199 HDD2GHZCHAN(2427, 4, 0) ,
200 HDD2GHZCHAN(2432, 5, 0) ,
201 HDD2GHZCHAN(2437, 6, 0) ,
202 HDD2GHZCHAN(2442, 7, 0) ,
203 HDD2GHZCHAN(2447, 8, 0) ,
204 HDD2GHZCHAN(2452, 9, 0) ,
205 HDD2GHZCHAN(2457, 10, 0) ,
206 HDD2GHZCHAN(2462, 11, 0) ,
207 HDD2GHZCHAN(2467, 12, 0) ,
208 HDD2GHZCHAN(2472, 13, 0) ,
209 HDD2GHZCHAN(2484, 14, 0) ,
210};
211
Jeff Johnson295189b2012-06-20 16:38:30 -0700212static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
213{
214 HDD2GHZCHAN(2412, 1, 0) ,
215 HDD2GHZCHAN(2437, 6, 0) ,
216 HDD2GHZCHAN(2462, 11, 0) ,
217};
Jeff Johnson295189b2012-06-20 16:38:30 -0700218
219static struct ieee80211_channel hdd_channels_5_GHZ[] =
220{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700221 HDD5GHZCHAN(4920, 240, 0) ,
222 HDD5GHZCHAN(4940, 244, 0) ,
223 HDD5GHZCHAN(4960, 248, 0) ,
224 HDD5GHZCHAN(4980, 252, 0) ,
225 HDD5GHZCHAN(5040, 208, 0) ,
226 HDD5GHZCHAN(5060, 212, 0) ,
227 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 HDD5GHZCHAN(5180, 36, 0) ,
229 HDD5GHZCHAN(5200, 40, 0) ,
230 HDD5GHZCHAN(5220, 44, 0) ,
231 HDD5GHZCHAN(5240, 48, 0) ,
232 HDD5GHZCHAN(5260, 52, 0) ,
233 HDD5GHZCHAN(5280, 56, 0) ,
234 HDD5GHZCHAN(5300, 60, 0) ,
235 HDD5GHZCHAN(5320, 64, 0) ,
236 HDD5GHZCHAN(5500,100, 0) ,
237 HDD5GHZCHAN(5520,104, 0) ,
238 HDD5GHZCHAN(5540,108, 0) ,
239 HDD5GHZCHAN(5560,112, 0) ,
240 HDD5GHZCHAN(5580,116, 0) ,
241 HDD5GHZCHAN(5600,120, 0) ,
242 HDD5GHZCHAN(5620,124, 0) ,
243 HDD5GHZCHAN(5640,128, 0) ,
244 HDD5GHZCHAN(5660,132, 0) ,
245 HDD5GHZCHAN(5680,136, 0) ,
246 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800247#ifdef FEATURE_WLAN_CH144
248 HDD5GHZCHAN(5720,144, 0) ,
249#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700250 HDD5GHZCHAN(5745,149, 0) ,
251 HDD5GHZCHAN(5765,153, 0) ,
252 HDD5GHZCHAN(5785,157, 0) ,
253 HDD5GHZCHAN(5805,161, 0) ,
254 HDD5GHZCHAN(5825,165, 0) ,
255};
256
257static struct ieee80211_rate g_mode_rates[] =
258{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530259 HDD_G_MODE_RATETAB(10, 0x1, 0),
260 HDD_G_MODE_RATETAB(20, 0x2, 0),
261 HDD_G_MODE_RATETAB(55, 0x4, 0),
262 HDD_G_MODE_RATETAB(110, 0x8, 0),
263 HDD_G_MODE_RATETAB(60, 0x10, 0),
264 HDD_G_MODE_RATETAB(90, 0x20, 0),
265 HDD_G_MODE_RATETAB(120, 0x40, 0),
266 HDD_G_MODE_RATETAB(180, 0x80, 0),
267 HDD_G_MODE_RATETAB(240, 0x100, 0),
268 HDD_G_MODE_RATETAB(360, 0x200, 0),
269 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530271};
Jeff Johnson295189b2012-06-20 16:38:30 -0700272
273static struct ieee80211_rate a_mode_rates[] =
274{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530275 HDD_G_MODE_RATETAB(60, 0x10, 0),
276 HDD_G_MODE_RATETAB(90, 0x20, 0),
277 HDD_G_MODE_RATETAB(120, 0x40, 0),
278 HDD_G_MODE_RATETAB(180, 0x80, 0),
279 HDD_G_MODE_RATETAB(240, 0x100, 0),
280 HDD_G_MODE_RATETAB(360, 0x200, 0),
281 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 HDD_G_MODE_RATETAB(540, 0x800, 0),
283};
284
285static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
286{
287 .channels = hdd_channels_2_4_GHZ,
288 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
289 .band = IEEE80211_BAND_2GHZ,
290 .bitrates = g_mode_rates,
291 .n_bitrates = g_mode_rates_size,
292 .ht_cap.ht_supported = 1,
293 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
294 | IEEE80211_HT_CAP_GRN_FLD
295 | IEEE80211_HT_CAP_DSSSCCK40
296 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
297 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
298 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
299 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
300 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
301 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
302};
303
Jeff Johnson295189b2012-06-20 16:38:30 -0700304static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
305{
306 .channels = hdd_social_channels_2_4_GHZ,
307 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
308 .band = IEEE80211_BAND_2GHZ,
309 .bitrates = g_mode_rates,
310 .n_bitrates = g_mode_rates_size,
311 .ht_cap.ht_supported = 1,
312 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
313 | IEEE80211_HT_CAP_GRN_FLD
314 | IEEE80211_HT_CAP_DSSSCCK40
315 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
316 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
317 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
318 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
319 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
320 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
321};
Jeff Johnson295189b2012-06-20 16:38:30 -0700322
323static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
324{
325 .channels = hdd_channels_5_GHZ,
326 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
327 .band = IEEE80211_BAND_5GHZ,
328 .bitrates = a_mode_rates,
329 .n_bitrates = a_mode_rates_size,
330 .ht_cap.ht_supported = 1,
331 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
332 | IEEE80211_HT_CAP_GRN_FLD
333 | IEEE80211_HT_CAP_DSSSCCK40
334 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
335 | IEEE80211_HT_CAP_SGI_40
336 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
337 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
338 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
339 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
340 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
341 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
342};
343
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530344/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 TX/RX direction for each kind of interface */
346static const struct ieee80211_txrx_stypes
347wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
348 [NL80211_IFTYPE_STATION] = {
349 .tx = 0xffff,
350 .rx = BIT(SIR_MAC_MGMT_ACTION) |
351 BIT(SIR_MAC_MGMT_PROBE_REQ),
352 },
353 [NL80211_IFTYPE_AP] = {
354 .tx = 0xffff,
355 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
356 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
357 BIT(SIR_MAC_MGMT_PROBE_REQ) |
358 BIT(SIR_MAC_MGMT_DISASSOC) |
359 BIT(SIR_MAC_MGMT_AUTH) |
360 BIT(SIR_MAC_MGMT_DEAUTH) |
361 BIT(SIR_MAC_MGMT_ACTION),
362 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700363 [NL80211_IFTYPE_ADHOC] = {
364 .tx = 0xffff,
365 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
366 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
367 BIT(SIR_MAC_MGMT_PROBE_REQ) |
368 BIT(SIR_MAC_MGMT_DISASSOC) |
369 BIT(SIR_MAC_MGMT_AUTH) |
370 BIT(SIR_MAC_MGMT_DEAUTH) |
371 BIT(SIR_MAC_MGMT_ACTION),
372 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 [NL80211_IFTYPE_P2P_CLIENT] = {
374 .tx = 0xffff,
375 .rx = BIT(SIR_MAC_MGMT_ACTION) |
376 BIT(SIR_MAC_MGMT_PROBE_REQ),
377 },
378 [NL80211_IFTYPE_P2P_GO] = {
379 /* This is also same as for SoftAP */
380 .tx = 0xffff,
381 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
382 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
383 BIT(SIR_MAC_MGMT_PROBE_REQ) |
384 BIT(SIR_MAC_MGMT_DISASSOC) |
385 BIT(SIR_MAC_MGMT_AUTH) |
386 BIT(SIR_MAC_MGMT_DEAUTH) |
387 BIT(SIR_MAC_MGMT_ACTION),
388 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700389};
390
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800391#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800392static const struct ieee80211_iface_limit
393wlan_hdd_iface_limit[] = {
394 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800395 /* max = 3 ; Our driver create two interfaces during driver init
396 * wlan0 and p2p0 interfaces. p2p0 is considered as station
397 * interface until a group is formed. In JB architecture, once the
398 * group is formed, interface type of p2p0 is changed to P2P GO or
399 * Client.
400 * When supplicant remove the group, it first issue a set interface
401 * cmd to change the mode back to Station. In JB this works fine as
402 * we advertize two station type interface during driver init.
403 * Some vendors create separate interface for P2P GO/Client,
404 * after group formation(Third one). But while group remove
405 * supplicant first tries to change the mode(3rd interface) to STATION
406 * But as we advertized only two sta type interfaces nl80211 was
407 * returning error for the third one which was leading to failure in
408 * delete interface. Ideally while removing the group, supplicant
409 * should not try to change the 3rd interface mode to Station type.
410 * Till we get a fix in wpa_supplicant, we advertize max STA
411 * interface type to 3
412 */
413 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800414 .types = BIT(NL80211_IFTYPE_STATION),
415 },
416 {
417 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700418 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800419 },
420 {
421 .max = 1,
422 .types = BIT(NL80211_IFTYPE_P2P_GO) |
423 BIT(NL80211_IFTYPE_P2P_CLIENT),
424 },
425};
426
427/* By default, only single channel concurrency is allowed */
428static struct ieee80211_iface_combination
429wlan_hdd_iface_combination = {
430 .limits = wlan_hdd_iface_limit,
431 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800432 /*
433 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
434 * and p2p0 interfaces during driver init
435 * Some vendors create separate interface for P2P operations.
436 * wlan0: STA interface
437 * p2p0: P2P Device interface, action frames goes
438 * through this interface.
439 * p2p-xx: P2P interface, After GO negotiation this interface is
440 * created for p2p operations(GO/CLIENT interface).
441 */
442 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800443 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
444 .beacon_int_infra_match = false,
445};
446#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800447
Jeff Johnson295189b2012-06-20 16:38:30 -0700448static struct cfg80211_ops wlan_hdd_cfg80211_ops;
449
450/* Data rate 100KBPS based on IE Index */
451struct index_data_rate_type
452{
453 v_U8_t beacon_rate_index;
454 v_U16_t supported_rate[4];
455};
456
457/* 11B, 11G Rate table include Basic rate and Extended rate
458 The IDX field is the rate index
459 The HI field is the rate when RSSI is strong or being ignored
460 (in this case we report actual rate)
461 The MID field is the rate when RSSI is moderate
462 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
463 The LO field is the rate when RSSI is low
464 (in this case we don't report rates, actual current rate used)
465 */
466static const struct
467{
468 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700469 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700470} supported_data_rate[] =
471{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700472/* IDX HI HM LM LO (RSSI-based index */
473 {2, { 10, 10, 10, 0}},
474 {4, { 20, 20, 10, 0}},
475 {11, { 55, 20, 10, 0}},
476 {12, { 60, 55, 20, 0}},
477 {18, { 90, 55, 20, 0}},
478 {22, {110, 55, 20, 0}},
479 {24, {120, 90, 60, 0}},
480 {36, {180, 120, 60, 0}},
481 {44, {220, 180, 60, 0}},
482 {48, {240, 180, 90, 0}},
483 {66, {330, 180, 90, 0}},
484 {72, {360, 240, 90, 0}},
485 {96, {480, 240, 120, 0}},
486 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700487};
488
489/* MCS Based rate table */
490static struct index_data_rate_type supported_mcs_rate[] =
491{
492/* MCS L20 L40 S20 S40 */
493 {0, {65, 135, 72, 150}},
494 {1, {130, 270, 144, 300}},
495 {2, {195, 405, 217, 450}},
496 {3, {260, 540, 289, 600}},
497 {4, {390, 810, 433, 900}},
498 {5, {520, 1080, 578, 1200}},
499 {6, {585, 1215, 650, 1350}},
500 {7, {650, 1350, 722, 1500}}
501};
502
Leo Chang6f8870f2013-03-26 18:11:36 -0700503#ifdef WLAN_FEATURE_11AC
504
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530505#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700506
507struct index_vht_data_rate_type
508{
509 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530510 v_U16_t supported_VHT80_rate[2];
511 v_U16_t supported_VHT40_rate[2];
512 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700513};
514
515typedef enum
516{
517 DATA_RATE_11AC_MAX_MCS_7,
518 DATA_RATE_11AC_MAX_MCS_8,
519 DATA_RATE_11AC_MAX_MCS_9,
520 DATA_RATE_11AC_MAX_MCS_NA
521} eDataRate11ACMaxMcs;
522
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530523/* SSID broadcast type */
524typedef enum eSSIDBcastType
525{
526 eBCAST_UNKNOWN = 0,
527 eBCAST_NORMAL = 1,
528 eBCAST_HIDDEN = 2,
529} tSSIDBcastType;
530
Leo Chang6f8870f2013-03-26 18:11:36 -0700531/* MCS Based VHT rate table */
532static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
533{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530534/* MCS L80 S80 L40 S40 L20 S40*/
535 {0, {293, 325}, {135, 150}, {65, 72}},
536 {1, {585, 650}, {270, 300}, {130, 144}},
537 {2, {878, 975}, {405, 450}, {195, 217}},
538 {3, {1170, 1300}, {540, 600}, {260, 289}},
539 {4, {1755, 1950}, {810, 900}, {390, 433}},
540 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
541 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
542 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
543 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
544 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700545};
546#endif /* WLAN_FEATURE_11AC */
547
c_hpothu79aab322014-07-14 21:11:01 +0530548/*array index points to MCS and array value points respective rssi*/
549static int rssiMcsTbl[][10] =
550{
551/*MCS 0 1 2 3 4 5 6 7 8 9*/
552 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
553 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
554 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
555};
556
Jeff Johnson295189b2012-06-20 16:38:30 -0700557extern struct net_device_ops net_ops_struct;
558
Leo Chang9056f462013-08-01 19:21:11 -0700559#ifdef WLAN_NL80211_TESTMODE
560enum wlan_hdd_tm_attr
561{
562 WLAN_HDD_TM_ATTR_INVALID = 0,
563 WLAN_HDD_TM_ATTR_CMD = 1,
564 WLAN_HDD_TM_ATTR_DATA = 2,
565 WLAN_HDD_TM_ATTR_TYPE = 3,
566 /* keep last */
567 WLAN_HDD_TM_ATTR_AFTER_LAST,
568 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
569};
570
571enum wlan_hdd_tm_cmd
572{
573 WLAN_HDD_TM_CMD_WLAN_HB = 1,
574};
575
576#define WLAN_HDD_TM_DATA_MAX_LEN 5000
577
578static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
579{
580 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
581 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
582 .len = WLAN_HDD_TM_DATA_MAX_LEN },
583};
584#endif /* WLAN_NL80211_TESTMODE */
585
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800586#ifdef FEATURE_WLAN_CH_AVOID
587/*
588 * FUNCTION: wlan_hdd_send_avoid_freq_event
589 * This is called when wlan driver needs to send vendor specific
590 * avoid frequency range event to userspace
591 */
592int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
593 tHddAvoidFreqList *pAvoidFreqList)
594{
595 struct sk_buff *vendor_event;
596
597 ENTER();
598
599 if (!pHddCtx)
600 {
601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
602 "%s: HDD context is null", __func__);
603 return -1;
604 }
605
606 if (!pAvoidFreqList)
607 {
608 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
609 "%s: pAvoidFreqList is null", __func__);
610 return -1;
611 }
612
613 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
614 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530615 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800616 GFP_KERNEL);
617 if (!vendor_event)
618 {
619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
620 "%s: cfg80211_vendor_event_alloc failed", __func__);
621 return -1;
622 }
623
624 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
625 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
626
627 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
628
629 EXIT();
630 return 0;
631}
632#endif /* FEATURE_WLAN_CH_AVOID */
633
Sunil Duttc69bccb2014-05-26 21:30:20 +0530634#ifdef WLAN_FEATURE_LINK_LAYER_STATS
635
636static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
637 struct sk_buff *vendor_event)
638{
639 if (nla_put_u8(vendor_event,
640 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
641 stats->rate.preamble) ||
642 nla_put_u8(vendor_event,
643 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
644 stats->rate.nss) ||
645 nla_put_u8(vendor_event,
646 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
647 stats->rate.bw) ||
648 nla_put_u8(vendor_event,
649 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
650 stats->rate.rateMcsIdx) ||
651 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
652 stats->rate.bitrate ) ||
653 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
654 stats->txMpdu ) ||
655 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
656 stats->rxMpdu ) ||
657 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
658 stats->mpduLost ) ||
659 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
660 stats->retries) ||
661 nla_put_u32(vendor_event,
662 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
663 stats->retriesShort ) ||
664 nla_put_u32(vendor_event,
665 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
666 stats->retriesLong))
667 {
668 hddLog(VOS_TRACE_LEVEL_ERROR,
669 FL("QCA_WLAN_VENDOR_ATTR put fail"));
670 return FALSE;
671 }
672 return TRUE;
673}
674
675static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
676 struct sk_buff *vendor_event)
677{
678 u32 i = 0;
679 struct nlattr *rateInfo;
680 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
681 stats->type) ||
682 nla_put(vendor_event,
683 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
684 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
685 nla_put_u32(vendor_event,
686 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
687 stats->capabilities) ||
688 nla_put_u32(vendor_event,
689 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
690 stats->numRate))
691 {
692 hddLog(VOS_TRACE_LEVEL_ERROR,
693 FL("QCA_WLAN_VENDOR_ATTR put fail"));
694 goto error;
695 }
696
697 rateInfo = nla_nest_start(vendor_event,
698 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
699 for (i = 0; i < stats->numRate; i++)
700 {
701 struct nlattr *rates;
702 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
703 stats->rateStats +
704 (i * sizeof(tSirWifiRateStat)));
705 rates = nla_nest_start(vendor_event, i);
706
707 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
708 {
709 hddLog(VOS_TRACE_LEVEL_ERROR,
710 FL("QCA_WLAN_VENDOR_ATTR put fail"));
711 return FALSE;
712 }
713 nla_nest_end(vendor_event, rates);
714 }
715 nla_nest_end(vendor_event, rateInfo);
716
717 return TRUE;
718error:
719 return FALSE;
720}
721
722static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
723 struct sk_buff *vendor_event)
724{
725 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
726 stats->ac ) ||
727 nla_put_u32(vendor_event,
728 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
729 stats->txMpdu ) ||
730 nla_put_u32(vendor_event,
731 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
732 stats->rxMpdu ) ||
733 nla_put_u32(vendor_event,
734 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
735 stats->txMcast ) ||
736 nla_put_u32(vendor_event,
737 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
738 stats->rxMcast ) ||
739 nla_put_u32(vendor_event,
740 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
741 stats->rxAmpdu ) ||
742 nla_put_u32(vendor_event,
743 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
744 stats->txAmpdu ) ||
745 nla_put_u32(vendor_event,
746 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
747 stats->mpduLost )||
748 nla_put_u32(vendor_event,
749 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
750 stats->retries ) ||
751 nla_put_u32(vendor_event,
752 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
753 stats->retriesShort ) ||
754 nla_put_u32(vendor_event,
755 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
756 stats->retriesLong ) ||
757 nla_put_u32(vendor_event,
758 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
759 stats->contentionTimeMin ) ||
760 nla_put_u32(vendor_event,
761 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
762 stats->contentionTimeMax ) ||
763 nla_put_u32(vendor_event,
764 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
765 stats->contentionTimeAvg ) ||
766 nla_put_u32(vendor_event,
767 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
768 stats->contentionNumSamples ))
769 {
770 hddLog(VOS_TRACE_LEVEL_ERROR,
771 FL("QCA_WLAN_VENDOR_ATTR put fail") );
772 return FALSE;
773 }
774 return TRUE;
775}
776
777static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
778 struct sk_buff *vendor_event)
779{
780 if (nla_put_u32(vendor_event,
781 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
782 nla_put(vendor_event,
783 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
784 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
785 nla_put_u32(vendor_event,
786 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
787 stats->state ) ||
788 nla_put_u32(vendor_event,
789 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
790 stats->roaming ) ||
791 nla_put_u32(vendor_event,
792 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
793 stats->capabilities ) ||
794 nla_put(vendor_event,
795 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
796 strlen(stats->ssid), stats->ssid) ||
797 nla_put(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
799 WNI_CFG_BSSID_LEN, stats->bssid) ||
800 nla_put(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
802 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
803 nla_put(vendor_event,
804 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
805 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
806 )
807 {
808 hddLog(VOS_TRACE_LEVEL_ERROR,
809 FL("QCA_WLAN_VENDOR_ATTR put fail") );
810 return FALSE;
811 }
812 return TRUE;
813}
814
815static v_BOOL_t put_wifi_iface_stats(tpSirWifiIfaceStat pWifiIfaceStat,
816 struct sk_buff *vendor_event)
817{
818 int i = 0;
819 struct nlattr *wmmInfo;
820 if (FALSE == put_wifi_interface_info(
821 &pWifiIfaceStat->info,
822 vendor_event))
823 {
824 hddLog(VOS_TRACE_LEVEL_ERROR,
825 FL("QCA_WLAN_VENDOR_ATTR put fail") );
826 return FALSE;
827
828 }
829
830 if (nla_put_u32(vendor_event,
831 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
832 pWifiIfaceStat->beaconRx) ||
833 nla_put_u32(vendor_event,
834 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
835 pWifiIfaceStat->mgmtRx) ||
836 nla_put_u32(vendor_event,
837 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
838 pWifiIfaceStat->mgmtActionRx) ||
839 nla_put_u32(vendor_event,
840 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
841 pWifiIfaceStat->mgmtActionTx) ||
842 nla_put_u32(vendor_event,
843 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
844 pWifiIfaceStat->rssiMgmt) ||
845 nla_put_u32(vendor_event,
846 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
847 pWifiIfaceStat->rssiData) ||
848 nla_put_u32(vendor_event,
849 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
850 pWifiIfaceStat->rssiAck))
851 {
852 hddLog(VOS_TRACE_LEVEL_ERROR,
853 FL("QCA_WLAN_VENDOR_ATTR put fail"));
854 return FALSE;
855 }
856
857 wmmInfo = nla_nest_start(vendor_event,
858 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
859 for (i = 0; i < WIFI_AC_MAX; i++)
860 {
861 struct nlattr *wmmStats;
862 wmmStats = nla_nest_start(vendor_event, i);
863 if (FALSE == put_wifi_wmm_ac_stat(
864 &pWifiIfaceStat->AccessclassStats[i],
865 vendor_event))
866 {
867 hddLog(VOS_TRACE_LEVEL_ERROR,
868 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
869 return FALSE;
870 }
871
872 nla_nest_end(vendor_event, wmmStats);
873 }
874 nla_nest_end(vendor_event, wmmInfo);
875 return TRUE;
876}
877
878static tSirWifiInterfaceMode
879 hdd_map_device_to_ll_iface_mode ( int deviceMode )
880{
881 switch (deviceMode)
882 {
883 case WLAN_HDD_INFRA_STATION:
884 return WIFI_INTERFACE_STA;
885 case WLAN_HDD_SOFTAP:
886 return WIFI_INTERFACE_SOFTAP;
887 case WLAN_HDD_P2P_CLIENT:
888 return WIFI_INTERFACE_P2P_CLIENT;
889 case WLAN_HDD_P2P_GO:
890 return WIFI_INTERFACE_P2P_GO;
891 case WLAN_HDD_IBSS:
892 return WIFI_INTERFACE_IBSS;
893 default:
894 /* Return Interface Mode as STA for all the unsupported modes */
895 return WIFI_INTERFACE_STA;
896 }
897}
898
899static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
900 tpSirWifiInterfaceInfo pInfo)
901{
902 v_U8_t *staMac = NULL;
903 hdd_station_ctx_t *pHddStaCtx;
904 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
905 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
906
907 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
908
909 vos_mem_copy(pInfo->macAddr,
910 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
911
912 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
913 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
914 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
915 {
916 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
917 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
918 {
919 pInfo->state = WIFI_DISCONNECTED;
920 }
921 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
922 {
923 hddLog(VOS_TRACE_LEVEL_ERROR,
924 "%s: Session ID %d, Connection is in progress", __func__,
925 pAdapter->sessionId);
926 pInfo->state = WIFI_ASSOCIATING;
927 }
928 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
929 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
930 {
931 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
932 hddLog(VOS_TRACE_LEVEL_ERROR,
933 "%s: client " MAC_ADDRESS_STR
934 " is in the middle of WPS/EAPOL exchange.", __func__,
935 MAC_ADDR_ARRAY(staMac));
936 pInfo->state = WIFI_AUTHENTICATING;
937 }
938 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
939 {
940 pInfo->state = WIFI_ASSOCIATED;
941 vos_mem_copy(pInfo->bssid,
942 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
943 vos_mem_copy(pInfo->ssid,
944 pHddStaCtx->conn_info.SSID.SSID.ssId,
945 pHddStaCtx->conn_info.SSID.SSID.length);
946 //NULL Terminate the string.
947 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
948 }
949 }
950 vos_mem_copy(pInfo->countryStr,
951 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
952
953 vos_mem_copy(pInfo->apCountryStr,
954 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
955
956 return TRUE;
957}
958
959/*
960 * hdd_link_layer_process_peer_stats () - This function is called after
961 * receiving Link Layer Peer statistics from FW.This function converts
962 * the firmware data to the NL data and sends the same to the kernel/upper
963 * layers.
964 */
965static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
966 v_VOID_t *pData)
967{
968 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
969 tpSirWifiRateStat pWifiRateStat;
970 tpSirWifiPeerStat pWifiPeerStat;
971 tpSirWifiPeerInfo pWifiPeerInfo;
972 struct nlattr *peerInfo;
973 struct sk_buff *vendor_event;
974 int status, i;
975
976 status = wlan_hdd_validate_context(pHddCtx);
977 if (0 != status)
978 {
979 hddLog(VOS_TRACE_LEVEL_ERROR,
980 FL("HDD context is not valid") );
981 return;
982 }
983
984 pWifiPeerStat = (tpSirWifiPeerStat) pData;
985
986 hddLog(VOS_TRACE_LEVEL_INFO,
987 "LL_STATS_PEER_ALL : numPeers %u",
988 pWifiPeerStat->numPeers);
989 {
990 for (i = 0; i < pWifiPeerStat->numPeers; i++)
991 {
992 pWifiPeerInfo = (tpSirWifiPeerInfo)
993 ((uint8 *)pWifiPeerStat->peerInfo +
994 ( i * sizeof(tSirWifiPeerInfo)));
995
996 hddLog(VOS_TRACE_LEVEL_INFO,
997 " %d) LL_STATS Channel Stats "
998 " Peer Type %u "
999 " peerMacAddress %pM "
1000 " capabilities 0x%x "
1001 " numRate %u ",
1002 i,
1003 pWifiPeerInfo->type,
1004 pWifiPeerInfo->peerMacAddress,
1005 pWifiPeerInfo->capabilities,
1006 pWifiPeerInfo->numRate);
1007 {
1008 int j;
1009 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1010 {
1011 pWifiRateStat = (tpSirWifiRateStat)
1012 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1013 ( j * sizeof(tSirWifiRateStat)));
1014
1015 hddLog(VOS_TRACE_LEVEL_INFO,
1016 " peer Rate Stats "
1017 " preamble %u "
1018 " nss %u "
1019 " bw %u "
1020 " rateMcsIdx %u "
1021 " reserved %u "
1022 " bitrate %u "
1023 " txMpdu %u "
1024 " rxMpdu %u "
1025 " mpduLost %u "
1026 " retries %u "
1027 " retriesShort %u "
1028 " retriesLong %u",
1029 pWifiRateStat->rate.preamble,
1030 pWifiRateStat->rate.nss,
1031 pWifiRateStat->rate.bw,
1032 pWifiRateStat->rate.rateMcsIdx,
1033 pWifiRateStat->rate.reserved,
1034 pWifiRateStat->rate.bitrate,
1035 pWifiRateStat->txMpdu,
1036 pWifiRateStat->rxMpdu,
1037 pWifiRateStat->mpduLost,
1038 pWifiRateStat->retries,
1039 pWifiRateStat->retriesShort,
1040 pWifiRateStat->retriesLong);
1041 }
1042 }
1043 }
1044 }
1045
1046 /*
1047 * Allocate a size of 4096 for the peer stats comprising
1048 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1049 * sizeof (tSirWifiRateStat).Each field is put with an
1050 * NL attribute.The size of 4096 is considered assuming
1051 * that number of rates shall not exceed beyond 50 with
1052 * the sizeof (tSirWifiRateStat) being 32.
1053 */
1054 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1055 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1056 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1057 GFP_KERNEL);
1058 if (!vendor_event)
1059 {
1060 hddLog(VOS_TRACE_LEVEL_ERROR,
1061 "%s: cfg80211_vendor_event_alloc failed",
1062 __func__);
1063 return;
1064 }
1065 if (nla_put_u32(vendor_event,
1066 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1067 pWifiPeerStat->numPeers))
1068 {
1069 hddLog(VOS_TRACE_LEVEL_ERROR,
1070 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1071 kfree_skb(vendor_event);
1072 return;
1073 }
1074
1075 peerInfo = nla_nest_start(vendor_event,
1076 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
1077
1078 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1079 pWifiPeerStat->peerInfo);
1080
1081 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1082 {
1083 struct nlattr *peers = nla_nest_start(vendor_event, i);
1084 int numRate = pWifiPeerInfo->numRate;
1085
1086 if (FALSE == put_wifi_peer_info(
1087 pWifiPeerInfo, vendor_event))
1088 {
1089 hddLog(VOS_TRACE_LEVEL_ERROR,
1090 "%s: put_wifi_peer_info put fail", __func__);
1091 kfree_skb(vendor_event);
1092 return;
1093 }
1094
1095 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1096 pWifiPeerStat->peerInfo +
1097 (i * sizeof(tSirWifiPeerInfo)) +
1098 (numRate * sizeof (tSirWifiRateStat)));
1099 nla_nest_end(vendor_event, peers);
1100 }
1101 nla_nest_end(vendor_event, peerInfo);
1102 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1103}
1104
1105/*
1106 * hdd_link_layer_process_iface_stats () - This function is called after
1107 * receiving Link Layer Interface statistics from FW.This function converts
1108 * the firmware data to the NL data and sends the same to the kernel/upper
1109 * layers.
1110 */
1111static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1112 v_VOID_t *pData)
1113{
1114 tpSirWifiIfaceStat pWifiIfaceStat;
1115 struct sk_buff *vendor_event;
1116 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1117 int status;
1118
1119 status = wlan_hdd_validate_context(pHddCtx);
1120 if (0 != status)
1121 {
1122 hddLog(VOS_TRACE_LEVEL_ERROR,
1123 FL("HDD context is not valid") );
1124 return;
1125 }
1126 /*
1127 * Allocate a size of 4096 for the interface stats comprising
1128 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1129 * assuming that all these fit with in the limit.Please take
1130 * a call on the limit based on the data requirements on
1131 * interface statistics.
1132 */
1133 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1134 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1135 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1136 GFP_KERNEL);
1137 if (!vendor_event)
1138 {
1139 hddLog(VOS_TRACE_LEVEL_ERROR,
1140 FL("cfg80211_vendor_event_alloc failed") );
1141 return;
1142 }
1143
1144 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1145
1146 hddLog(VOS_TRACE_LEVEL_INFO,
1147 "WMI_LINK_STATS_IFACE Data");
1148
1149 hddLog(VOS_TRACE_LEVEL_INFO,
1150 "LL_STATS_IFACE: "
1151 " Mode %u "
1152 " MAC %pM "
1153 " State %u "
1154 " Roaming %u "
1155 " capabilities 0x%x "
1156 " SSID %s "
1157 " BSSID %pM",
1158 pWifiIfaceStat->info.mode,
1159 pWifiIfaceStat->info.macAddr,
1160 pWifiIfaceStat->info.state,
1161 pWifiIfaceStat->info.roaming,
1162 pWifiIfaceStat->info.capabilities,
1163 pWifiIfaceStat->info.ssid,
1164 pWifiIfaceStat->info.bssid);
1165
1166 hddLog(VOS_TRACE_LEVEL_INFO,
1167 " AP country str: %c%c%c",
1168 pWifiIfaceStat->info.apCountryStr[0],
1169 pWifiIfaceStat->info.apCountryStr[1],
1170 pWifiIfaceStat->info.apCountryStr[2]);
1171
1172
1173 hddLog(VOS_TRACE_LEVEL_INFO,
1174 " Country Str Association: %c%c%c",
1175 pWifiIfaceStat->info.countryStr[0],
1176 pWifiIfaceStat->info.countryStr[1],
1177 pWifiIfaceStat->info.countryStr[2]);
1178
1179 hddLog(VOS_TRACE_LEVEL_INFO,
1180 " beaconRx %u "
1181 " mgmtRx %u "
1182 " mgmtActionRx %u "
1183 " mgmtActionTx %u "
1184 " rssiMgmt %u "
1185 " rssiData %u "
1186 " rssiAck %u",
1187 pWifiIfaceStat->beaconRx,
1188 pWifiIfaceStat->mgmtRx,
1189 pWifiIfaceStat->mgmtActionRx,
1190 pWifiIfaceStat->mgmtActionTx,
1191 pWifiIfaceStat->rssiMgmt,
1192 pWifiIfaceStat->rssiData,
1193 pWifiIfaceStat->rssiAck );
1194
1195
1196 {
1197 int i;
1198 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1199 {
1200 hddLog(VOS_TRACE_LEVEL_INFO,
1201
1202 " %d) LL_STATS IFACE: "
1203 " ac: %u txMpdu: %u "
1204 " rxMpdu: %u txMcast: %u "
1205 " rxMcast: %u rxAmpdu: %u "
1206 " txAmpdu: %u mpduLost: %u "
1207 " retries: %u retriesShort: %u "
1208 " retriesLong: %u contentionTimeMin: %u "
1209 " contentionTimeMax: %u contentionTimeAvg: %u "
1210 " contentionNumSamples: %u",
1211 i,
1212 pWifiIfaceStat->AccessclassStats[i].ac,
1213 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1214 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1215 pWifiIfaceStat->AccessclassStats[i].txMcast,
1216 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1217 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1218 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1219 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1220 pWifiIfaceStat->AccessclassStats[i].retries,
1221 pWifiIfaceStat->
1222 AccessclassStats[i].retriesShort,
1223 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1224 pWifiIfaceStat->
1225 AccessclassStats[i].contentionTimeMin,
1226 pWifiIfaceStat->
1227 AccessclassStats[i].contentionTimeMax,
1228 pWifiIfaceStat->
1229 AccessclassStats[i].contentionTimeAvg,
1230 pWifiIfaceStat->
1231 AccessclassStats[i].contentionNumSamples);
1232
1233 }
1234 }
1235
1236 if (FALSE == hdd_get_interface_info( pAdapter,
1237 &pWifiIfaceStat->info))
1238 {
1239 hddLog(VOS_TRACE_LEVEL_ERROR,
1240 FL("hdd_get_interface_info get fail") );
1241 kfree_skb(vendor_event);
1242 return;
1243 }
1244
1245 if (FALSE == put_wifi_iface_stats( pWifiIfaceStat,
1246 vendor_event))
1247 {
1248 hddLog(VOS_TRACE_LEVEL_ERROR,
1249 FL("put_wifi_iface_stats fail") );
1250 kfree_skb(vendor_event);
1251 return;
1252 }
1253 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1254}
1255
1256/*
1257 * hdd_link_layer_process_radio_stats () - This function is called after
1258 * receiving Link Layer Radio statistics from FW.This function converts
1259 * the firmware data to the NL data and sends the same to the kernel/upper
1260 * layers.
1261 */
1262static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1263 v_VOID_t *pData)
1264{
1265 int status, i;
1266 tpSirWifiRadioStat pWifiRadioStat;
1267 tpSirWifiChannelStats pWifiChannelStats;
1268 struct sk_buff *vendor_event;
1269 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1270 struct nlattr *chList;
1271
1272 status = wlan_hdd_validate_context(pHddCtx);
1273 if (0 != status)
1274 {
1275 hddLog(VOS_TRACE_LEVEL_ERROR,
1276 FL("HDD context is not valid") );
1277 return;
1278 }
1279 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1280
1281 hddLog(VOS_TRACE_LEVEL_INFO,
1282 "LL_STATS_RADIO"
1283 " radio is %d onTime is %u "
1284 " txTime is %u rxTime is %u "
1285 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301286 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301287 " onTimePnoScan is %u onTimeHs20 is %u "
1288 " numChannels is %u",
1289 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1290 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1291 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301292 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301293 pWifiRadioStat->onTimeRoamScan,
1294 pWifiRadioStat->onTimePnoScan,
1295 pWifiRadioStat->onTimeHs20,
1296 pWifiRadioStat->numChannels);
1297 /*
1298 * Allocate a size of 4096 for the Radio stats comprising
1299 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1300 * (tSirWifiChannelStats).Each channel data is put with an
1301 * NL attribute.The size of 4096 is considered assuming that
1302 * number of channels shall not exceed beyond 60 with the
1303 * sizeof (tSirWifiChannelStats) being 24 bytes.
1304 */
1305
1306 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1307 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1308 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1309 GFP_KERNEL);
1310
1311 if (!vendor_event)
1312 {
1313 hddLog(VOS_TRACE_LEVEL_ERROR,
1314 FL("cfg80211_vendor_event_alloc failed") );
1315 return;
1316 }
1317
1318 if (nla_put_u32(vendor_event,
1319 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1320 pWifiRadioStat->radio) ||
1321 nla_put_u32(vendor_event,
1322 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1323 pWifiRadioStat->onTime) ||
1324 nla_put_u32(vendor_event,
1325 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1326 pWifiRadioStat->txTime) ||
1327 nla_put_u32(vendor_event,
1328 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1329 pWifiRadioStat->rxTime) ||
1330 nla_put_u32(vendor_event,
1331 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1332 pWifiRadioStat->onTimeScan) ||
1333 nla_put_u32(vendor_event,
1334 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1335 pWifiRadioStat->onTimeNbd) ||
1336 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301337 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1338 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301339 nla_put_u32(vendor_event,
1340 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1341 pWifiRadioStat->onTimeRoamScan) ||
1342 nla_put_u32(vendor_event,
1343 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1344 pWifiRadioStat->onTimePnoScan) ||
1345 nla_put_u32(vendor_event,
1346 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1347 pWifiRadioStat->onTimeHs20) ||
1348 nla_put_u32(vendor_event,
1349 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1350 pWifiRadioStat->numChannels))
1351 {
1352 hddLog(VOS_TRACE_LEVEL_ERROR,
1353 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1354 kfree_skb(vendor_event);
1355 return ;
1356 }
1357
1358 chList = nla_nest_start(vendor_event,
1359 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
1360 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1361 {
1362 struct nlattr *chInfo;
1363
1364 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1365 pWifiRadioStat->channels +
1366 (i * sizeof(tSirWifiChannelStats)));
1367
1368 hddLog(VOS_TRACE_LEVEL_INFO,
1369 " %d) Channel Info"
1370 " width is %u "
1371 " CenterFreq %u "
1372 " CenterFreq0 %u "
1373 " CenterFreq1 %u "
1374 " onTime %u "
1375 " ccaBusyTime %u",
1376 i,
1377 pWifiChannelStats->channel.width,
1378 pWifiChannelStats->channel.centerFreq,
1379 pWifiChannelStats->channel.centerFreq0,
1380 pWifiChannelStats->channel.centerFreq1,
1381 pWifiChannelStats->onTime,
1382 pWifiChannelStats->ccaBusyTime);
1383
1384
1385 chInfo = nla_nest_start(vendor_event, i);
1386
1387 if (nla_put_u32(vendor_event,
1388 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1389 pWifiChannelStats->channel.width) ||
1390 nla_put_u32(vendor_event,
1391 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1392 pWifiChannelStats->channel.centerFreq) ||
1393 nla_put_u32(vendor_event,
1394 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1395 pWifiChannelStats->channel.centerFreq0) ||
1396 nla_put_u32(vendor_event,
1397 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1398 pWifiChannelStats->channel.centerFreq1) ||
1399 nla_put_u32(vendor_event,
1400 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1401 pWifiChannelStats->onTime) ||
1402 nla_put_u32(vendor_event,
1403 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1404 pWifiChannelStats->ccaBusyTime))
1405 {
1406 hddLog(VOS_TRACE_LEVEL_ERROR,
1407 FL("cfg80211_vendor_event_alloc failed") );
1408 kfree_skb(vendor_event);
1409 return ;
1410 }
1411 nla_nest_end(vendor_event, chInfo);
1412 }
1413 nla_nest_end(vendor_event, chList);
1414
1415 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1416 return;
1417}
1418
1419/*
1420 * hdd_link_layer_stats_ind_callback () - This function is called after
1421 * receiving Link Layer indications from FW.This callback converts the firmware
1422 * data to the NL data and send the same to the kernel/upper layers.
1423 */
1424static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1425 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301426 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301427{
Dino Mycled3d50022014-07-07 12:58:25 +05301428 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1429 hdd_adapter_t *pAdapter = NULL;
1430 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301431 int status;
1432
1433 status = wlan_hdd_validate_context(pHddCtx);
1434
1435 if (0 != status)
1436 {
1437 hddLog(VOS_TRACE_LEVEL_ERROR,
1438 FL("HDD context is not valid"));
1439 return;
1440 }
1441
Dino Mycled3d50022014-07-07 12:58:25 +05301442
1443
1444 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1445 if (NULL == pAdapter)
1446 {
1447 hddLog(VOS_TRACE_LEVEL_ERROR,
1448 FL(" MAC address %pM does not exist with host"),
1449 macAddr);
1450 return;
1451 }
1452
Sunil Duttc69bccb2014-05-26 21:30:20 +05301453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301454 "%s: Interface: %s LLStats indType: %d", __func__,
1455 pAdapter->dev->name, indType);
1456
Sunil Duttc69bccb2014-05-26 21:30:20 +05301457 switch (indType)
1458 {
1459 case SIR_HAL_LL_STATS_RESULTS_RSP:
1460 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301461 hddLog(VOS_TRACE_LEVEL_INFO,
1462 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1463 hddLog(VOS_TRACE_LEVEL_INFO,
1464 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1465 linkLayerStatsResults->paramId);
1466 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301467 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1468 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301469 hddLog(VOS_TRACE_LEVEL_INFO,
1470 "LL_STATS RESULTS RESPONSE respId = %u",
1471 linkLayerStatsResults->respId);
1472 hddLog(VOS_TRACE_LEVEL_INFO,
1473 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1474 linkLayerStatsResults->moreResultToFollow);
1475 hddLog(VOS_TRACE_LEVEL_INFO,
1476 "LL_STATS RESULTS RESPONSE result = %p",
1477 linkLayerStatsResults->result);
1478 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1479 {
1480 hdd_link_layer_process_radio_stats(pAdapter,
1481 (v_VOID_t *)linkLayerStatsResults->result);
1482 }
1483 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1484 {
1485 hdd_link_layer_process_iface_stats(pAdapter,
1486 (v_VOID_t *)linkLayerStatsResults->result);
1487 }
1488 else if ( linkLayerStatsResults->paramId &
1489 WMI_LINK_STATS_ALL_PEER )
1490 {
1491 hdd_link_layer_process_peer_stats(pAdapter,
1492 (v_VOID_t *)linkLayerStatsResults->result);
1493 } /* WMI_LINK_STATS_ALL_PEER */
1494 else
1495 {
1496 hddLog(VOS_TRACE_LEVEL_ERROR,
1497 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1498 }
1499
1500 break;
1501 }
1502 default:
1503 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1504 break;
1505 }
1506 return;
1507}
1508
1509const struct
1510nla_policy
1511qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1512{
1513 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1514 { .type = NLA_U32 },
1515 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1516 { .type = NLA_U32 },
1517};
1518
1519static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1520 struct wireless_dev *wdev,
1521 void *data,
1522 int data_len)
1523{
1524 int status;
1525 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301526 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301527 struct net_device *dev = wdev->netdev;
1528 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1529 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1530
1531 status = wlan_hdd_validate_context(pHddCtx);
1532 if (0 != status)
1533 {
1534 hddLog(VOS_TRACE_LEVEL_ERROR,
1535 FL("HDD context is not valid"));
1536 return -EINVAL;
1537 }
1538
1539 if (NULL == pAdapter)
1540 {
1541 hddLog(VOS_TRACE_LEVEL_ERROR,
1542 FL("HDD adapter is Null"));
1543 return -ENODEV;
1544 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301545 /* check the LLStats Capability */
1546 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1547 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1548 {
1549 hddLog(VOS_TRACE_LEVEL_ERROR,
1550 FL("Link Layer Statistics not supported by Firmware"));
1551 return -EINVAL;
1552 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301553
1554 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1555 (struct nlattr *)data,
1556 data_len, qca_wlan_vendor_ll_set_policy))
1557 {
1558 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1559 return -EINVAL;
1560 }
1561 if (!tb_vendor
1562 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1563 {
1564 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1565 return -EINVAL;
1566 }
1567 if (!tb_vendor[
1568 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1569 {
1570 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1571 return -EINVAL;
1572 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301573 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301574 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301575
Dino Mycledf0a5d92014-07-04 09:41:55 +05301576 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301577 nla_get_u32(
1578 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1579
Dino Mycledf0a5d92014-07-04 09:41:55 +05301580 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301581 nla_get_u32(
1582 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1583
Dino Mycled3d50022014-07-07 12:58:25 +05301584 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1585 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301586
1587
1588 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301589 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301590 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301591 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301592 hddLog(VOS_TRACE_LEVEL_INFO,
1593 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301594 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301595 hddLog(VOS_TRACE_LEVEL_INFO,
1596 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301597 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301598
1599 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1600 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301601 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301602 {
1603 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1604 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301605 return -EINVAL;
1606
1607 }
1608 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301609 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301610 {
1611 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1612 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301613 return -EINVAL;
1614 }
1615
1616 pAdapter->isLinkLayerStatsSet = 1;
1617
1618 return 0;
1619}
1620
1621const struct
1622nla_policy
1623qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1624{
1625 /* Unsigned 32bit value provided by the caller issuing the GET stats
1626 * command. When reporting
1627 * the stats results, the driver uses the same value to indicate
1628 * which GET request the results
1629 * correspond to.
1630 */
1631 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1632
1633 /* Unsigned 32bit value . bit mask to identify what statistics are
1634 requested for retrieval */
1635 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1636};
1637
1638static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1639 struct wireless_dev *wdev,
1640 void *data,
1641 int data_len)
1642{
1643 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1644 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301645 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301646 struct net_device *dev = wdev->netdev;
1647 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1648 int status;
1649
1650 status = wlan_hdd_validate_context(pHddCtx);
1651 if (0 != status)
1652 {
1653 hddLog(VOS_TRACE_LEVEL_ERROR,
1654 FL("HDD context is not valid"));
1655 return -EINVAL ;
1656 }
1657
1658 if (NULL == pAdapter)
1659 {
1660 hddLog(VOS_TRACE_LEVEL_FATAL,
1661 "%s: HDD adapter is Null", __func__);
1662 return -ENODEV;
1663 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301664 /* check the LLStats Capability */
1665 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1666 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1667 {
1668 hddLog(VOS_TRACE_LEVEL_ERROR,
1669 FL("Link Layer Statistics not supported by Firmware"));
1670 return -EINVAL;
1671 }
1672
Sunil Duttc69bccb2014-05-26 21:30:20 +05301673
1674 if (!pAdapter->isLinkLayerStatsSet)
1675 {
1676 hddLog(VOS_TRACE_LEVEL_FATAL,
1677 "%s: isLinkLayerStatsSet : %d",
1678 __func__, pAdapter->isLinkLayerStatsSet);
1679 return -EINVAL;
1680 }
1681
1682 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
1683 (struct nlattr *)data,
1684 data_len, qca_wlan_vendor_ll_get_policy))
1685 {
1686 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1687 return -EINVAL;
1688 }
1689
1690 if (!tb_vendor
1691 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
1692 {
1693 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
1694 return -EINVAL;
1695 }
1696
1697 if (!tb_vendor
1698 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
1699 {
1700 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
1701 return -EINVAL;
1702 }
1703
Sunil Duttc69bccb2014-05-26 21:30:20 +05301704
Dino Mycledf0a5d92014-07-04 09:41:55 +05301705 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301706 nla_get_u32( tb_vendor[
1707 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05301708 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301709 nla_get_u32( tb_vendor[
1710 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
1711
Dino Mycled3d50022014-07-07 12:58:25 +05301712 vos_mem_copy(linkLayerStatsGetReq.macAddr,
1713 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301714
1715 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301716 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301717 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301718 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301719 hddLog(VOS_TRACE_LEVEL_INFO,
1720 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301721 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301722
1723 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301724 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301725 {
1726 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1727 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301728 return -EINVAL;
1729 }
1730 return 0;
1731}
1732
1733const struct
1734nla_policy
1735qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
1736{
1737 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
1738 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
1739 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
1740 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
1741};
1742
1743static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
1744 struct wireless_dev *wdev,
1745 void *data,
1746 int data_len)
1747{
1748 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1749 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301750 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301751 struct net_device *dev = wdev->netdev;
1752 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1753 u32 statsClearReqMask;
1754 u8 stopReq;
1755 int status;
1756
1757 status = wlan_hdd_validate_context(pHddCtx);
1758 if (0 != status)
1759 {
1760 hddLog(VOS_TRACE_LEVEL_ERROR,
1761 FL("HDD context is not valid"));
1762 return -EINVAL;
1763 }
1764
1765 if (NULL == pAdapter)
1766 {
1767 hddLog(VOS_TRACE_LEVEL_FATAL,
1768 "%s: HDD adapter is Null", __func__);
1769 return -ENODEV;
1770 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301771 /* check the LLStats Capability */
1772 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1773 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1774 {
1775 hddLog(VOS_TRACE_LEVEL_ERROR,
1776 FL("Enable LLStats Capability"));
1777 return -EINVAL;
1778 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301779
1780 if (!pAdapter->isLinkLayerStatsSet)
1781 {
1782 hddLog(VOS_TRACE_LEVEL_FATAL,
1783 "%s: isLinkLayerStatsSet : %d",
1784 __func__, pAdapter->isLinkLayerStatsSet);
1785 return -EINVAL;
1786 }
1787
1788 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
1789 (struct nlattr *)data,
1790 data_len, qca_wlan_vendor_ll_clr_policy))
1791 {
1792 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1793 return -EINVAL;
1794 }
1795
1796 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
1797
1798 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
1799 {
1800 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
1801 return -EINVAL;
1802
1803 }
1804
Sunil Duttc69bccb2014-05-26 21:30:20 +05301805
Dino Mycledf0a5d92014-07-04 09:41:55 +05301806 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301807 nla_get_u32(
1808 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
1809
Dino Mycledf0a5d92014-07-04 09:41:55 +05301810 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301811 nla_get_u8(
1812 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
1813
1814 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301815 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301816
Dino Mycled3d50022014-07-07 12:58:25 +05301817 vos_mem_copy(linkLayerStatsClearReq.macAddr,
1818 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301819
1820 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301821 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301822 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301823 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301824 hddLog(VOS_TRACE_LEVEL_INFO,
1825 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301826 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301827 hddLog(VOS_TRACE_LEVEL_INFO,
1828 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301829 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301830
1831 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301832 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301833 {
1834 struct sk_buff *temp_skbuff;
1835 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
1836 2 * sizeof(u32) +
1837 NLMSG_HDRLEN);
1838
1839 if (temp_skbuff != NULL)
1840 {
1841
1842 if (nla_put_u32(temp_skbuff,
1843 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
1844 statsClearReqMask) ||
1845 nla_put_u32(temp_skbuff,
1846 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
1847 stopReq))
1848 {
1849 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
1850 kfree_skb(temp_skbuff);
1851 return -EINVAL;
1852 }
1853 /* If the ask is to stop the stats collection as part of clear
1854 * (stopReq = 1) , ensure that no further requests of get
1855 * go to the firmware by having isLinkLayerStatsSet set to 0.
1856 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301857 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05301858 * case the firmware is just asked to clear the statistics.
1859 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05301860 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301861 pAdapter->isLinkLayerStatsSet = 0;
1862 return cfg80211_vendor_cmd_reply(temp_skbuff);
1863 }
1864 return -ENOMEM;
1865 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301866 return -EINVAL;
1867}
1868#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1869
Dino Mycle6fb96c12014-06-10 11:52:40 +05301870#ifdef WLAN_FEATURE_EXTSCAN
1871static const struct nla_policy
1872wlan_hdd_extscan_config_policy
1873 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
1874{
1875 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
1876 { .type = NLA_U32 },
1877 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
1878 { .type = NLA_U32 },
1879 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
1880 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
1881 { .type = NLA_U32 },
1882 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
1883 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
1884
1885 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
1886 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
1887 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
1888 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
1889 { .type = NLA_U8 },
1890 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
1891 { .type = NLA_U32 },
1892 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
1893 { .type = NLA_U32 },
1894 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
1895 { .type = NLA_U32 },
1896 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
1897 { .type = NLA_U8 },
1898 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
1899 { .type = NLA_U8 },
1900 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
1901 { .type = NLA_U8 },
1902
1903 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
1904 { .type = NLA_U32 },
1905 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
1906 { .type = NLA_UNSPEC },
1907 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
1908 { .type = NLA_S32 },
1909 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
1910 { .type = NLA_S32 },
1911 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
1912 { .type = NLA_U32 },
1913 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
1914 { .type = NLA_U32 },
1915 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
1916 { .type = NLA_U32 },
1917 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
1918 = { .type = NLA_U32 },
1919 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
1920 { .type = NLA_U32 },
1921 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
1922 NLA_U32 },
1923};
1924
1925static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
1926{
1927 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
1928 struct sk_buff *skb = NULL;
1929 tpSirEXTScanCapabilitiesEvent pData =
1930 (tpSirEXTScanCapabilitiesEvent) pMsg;
1931
1932 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
1933 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
1934 "or pData(%p) is null"), pData);
1935 return;
1936 }
1937
1938 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1939 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1940 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
1941 GFP_KERNEL);
1942
1943 if (!skb) {
1944 hddLog(VOS_TRACE_LEVEL_ERROR,
1945 FL("cfg80211_vendor_event_alloc failed"));
1946 return;
1947 }
1948
1949 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
1950 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
1951 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
1952 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
1953 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
1954 pData->maxRssiSampleSize);
1955 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
1956 pData->maxScanReportingThreshold);
1957 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
1958 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
1959 pData->maxSignificantWifiChangeAPs);
1960 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
1961 pData->maxBsidHistoryEntries);
1962
1963 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
1964 pData->requestId) ||
1965 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
1966 nla_put_u32(skb,
1967 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
1968 pData->scanCacheSize) ||
1969 nla_put_u32(skb,
1970 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
1971 pData->scanBuckets) ||
1972 nla_put_u32(skb,
1973 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
1974 pData->maxApPerScan) ||
1975 nla_put_u32(skb,
1976 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
1977 pData->maxRssiSampleSize) ||
1978 nla_put_u32(skb,
1979 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
1980 pData->maxScanReportingThreshold) ||
1981 nla_put_u32(skb,
1982 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
1983 pData->maxHotlistAPs) ||
1984 nla_put_u32(skb,
1985 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
1986 pData->maxSignificantWifiChangeAPs) ||
1987 nla_put_u32(skb,
1988 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
1989 pData->maxBsidHistoryEntries)) {
1990 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
1991 goto nla_put_failure;
1992 }
1993
1994 cfg80211_vendor_event(skb, GFP_KERNEL);
1995 return;
1996
1997nla_put_failure:
1998 kfree_skb(skb);
1999 return;
2000}
2001
2002
2003static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2004{
2005 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2006 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2007 struct sk_buff *skb = NULL;
2008 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2009
2010
2011 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2012 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2013 "or pData(%p) is null"), pData);
2014 return;
2015 }
2016
2017 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2018 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2019 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2020 GFP_KERNEL);
2021
2022 if (!skb) {
2023 hddLog(VOS_TRACE_LEVEL_ERROR,
2024 FL("cfg80211_vendor_event_alloc failed"));
2025 return;
2026 }
2027 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2028 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2029 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2030
2031 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2032 pData->requestId) ||
2033 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2034 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2035 goto nla_put_failure;
2036 }
2037
2038 /*
2039 * Store the Request ID for comparing with the requestID obtained
2040 * in other requests.HDD shall return a failure is the extscan_stop
2041 * request is issued with a different requestId as that of the
2042 * extscan_start request. Also, This requestId shall be used while
2043 * indicating the full scan results to the upper layers.
2044 * The requestId is stored with the assumption that the firmware
2045 * shall return the ext scan start request's requestId in ext scan
2046 * start response.
2047 */
2048 if (pData->status == 0)
2049 pMac->sme.extScanStartReqId = pData->requestId;
2050
2051
2052 cfg80211_vendor_event(skb, GFP_KERNEL);
2053 return;
2054
2055nla_put_failure:
2056 kfree_skb(skb);
2057 return;
2058}
2059
2060
2061static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2062{
2063 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2064 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2065 struct sk_buff *skb = NULL;
2066
2067 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2068 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2069 "or pData(%p) is null"), pData);
2070 return;
2071 }
2072
2073 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2074 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2075 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2076 GFP_KERNEL);
2077
2078 if (!skb) {
2079 hddLog(VOS_TRACE_LEVEL_ERROR,
2080 FL("cfg80211_vendor_event_alloc failed"));
2081 return;
2082 }
2083 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2084 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2085
2086 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2087 pData->requestId) ||
2088 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2089 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2090 goto nla_put_failure;
2091 }
2092
2093 cfg80211_vendor_event(skb, GFP_KERNEL);
2094 return;
2095
2096nla_put_failure:
2097 kfree_skb(skb);
2098 return;
2099}
2100
2101
2102static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2103 void *pMsg)
2104{
2105 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2106 struct sk_buff *skb = NULL;
2107 tpSirEXTScanSetBssidHotListRspParams pData =
2108 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2109
2110 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2111 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2112 "or pData(%p) is null"), pData);
2113 return;
2114 }
2115 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2116 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2117 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2118 GFP_KERNEL);
2119
2120 if (!skb) {
2121 hddLog(VOS_TRACE_LEVEL_ERROR,
2122 FL("cfg80211_vendor_event_alloc failed"));
2123 return;
2124 }
2125 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2126 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2127 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2128
2129 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2130 pData->requestId) ||
2131 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2132 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2133 goto nla_put_failure;
2134 }
2135
2136 cfg80211_vendor_event(skb, GFP_KERNEL);
2137 return;
2138
2139nla_put_failure:
2140 kfree_skb(skb);
2141 return;
2142}
2143
2144static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2145 void *pMsg)
2146{
2147 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2148 struct sk_buff *skb = NULL;
2149 tpSirEXTScanResetBssidHotlistRspParams pData =
2150 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2151
2152 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2153 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2154 "or pData(%p) is null"), pData);
2155 return;
2156 }
2157
2158 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2159 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2160 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2161 GFP_KERNEL);
2162
2163 if (!skb) {
2164 hddLog(VOS_TRACE_LEVEL_ERROR,
2165 FL("cfg80211_vendor_event_alloc failed"));
2166 return;
2167 }
2168 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2169 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2170
2171 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2172 pData->requestId) ||
2173 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2174 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2175 goto nla_put_failure;
2176 }
2177
2178 cfg80211_vendor_event(skb, GFP_KERNEL);
2179 return;
2180
2181nla_put_failure:
2182 kfree_skb(skb);
2183 return;
2184}
2185
2186
2187static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2188 void *pMsg)
2189{
2190 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2191 struct sk_buff *skb = NULL;
2192 tpSirEXTScanSetSignificantChangeRspParams pData =
2193 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2194
2195 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2196 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2197 "or pData(%p) is null"), pData);
2198 return;
2199 }
2200
2201 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2202 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2203 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2204 GFP_KERNEL);
2205
2206 if (!skb) {
2207 hddLog(VOS_TRACE_LEVEL_ERROR,
2208 FL("cfg80211_vendor_event_alloc failed"));
2209 return;
2210 }
2211 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2212 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2213 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2214
2215 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2216 pData->requestId) ||
2217 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2218 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2219 goto nla_put_failure;
2220 }
2221
2222 cfg80211_vendor_event(skb, GFP_KERNEL);
2223 return;
2224
2225nla_put_failure:
2226 kfree_skb(skb);
2227 return;
2228}
2229
2230
2231static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2232 void *pMsg)
2233{
2234 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2235 struct sk_buff *skb = NULL;
2236 tpSirEXTScanResetSignificantChangeRspParams pData =
2237 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2238
2239 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2240 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2241 "or pData(%p) is null"), pData);
2242 return;
2243 }
2244
2245 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2246 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2247 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2248 GFP_KERNEL);
2249
2250 if (!skb) {
2251 hddLog(VOS_TRACE_LEVEL_ERROR,
2252 FL("cfg80211_vendor_event_alloc failed"));
2253 return;
2254 }
2255 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2256 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2257 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2258
2259 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2260 pData->requestId) ||
2261 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2262 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2263 goto nla_put_failure;
2264 }
2265
2266 cfg80211_vendor_event(skb, GFP_KERNEL);
2267 return;
2268
2269nla_put_failure:
2270 kfree_skb(skb);
2271 return;
2272}
2273
2274static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2275 void *pMsg)
2276{
2277 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2278 struct sk_buff *skb = NULL;
2279 tANI_U32 i = 0, j, resultsPerEvent;
2280 tANI_S32 totalResults;
2281 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2282 tpSirWifiScanResult pSirWifiScanResult;
2283
2284 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2285 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2286 "or pData(%p) is null"), pData);
2287 return;
2288 }
2289 totalResults = pData->numOfAps;
2290 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2291 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2292 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2293
2294 do{
2295 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2296 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2297 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2298
2299 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2300 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2301 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2302 GFP_KERNEL);
2303
2304 if (!skb) {
2305 hddLog(VOS_TRACE_LEVEL_ERROR,
2306 FL("cfg80211_vendor_event_alloc failed"));
2307 return;
2308 }
2309
2310 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2311
2312 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2313 pData->requestId) ||
2314 nla_put_u32(skb,
2315 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2316 resultsPerEvent)) {
2317 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2318 goto fail;
2319 }
2320 if (nla_put_u8(skb,
2321 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2322 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2323 {
2324 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2325 goto fail;
2326 }
2327
2328 if (resultsPerEvent) {
2329 struct nlattr *aps;
2330
2331 aps = nla_nest_start(skb,
2332 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2333 if (!aps)
2334 {
2335 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2336 goto fail;
2337 }
2338
2339 for (j = 0; j < resultsPerEvent; j++, i++) {
2340 struct nlattr *ap;
2341 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2342 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2343
2344 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2345 "Ssid (%s)"
2346 "Bssid: %pM "
2347 "Channel (%u)"
2348 "Rssi (%d)"
2349 "RTT (%u)"
2350 "RTT_SD (%u)",
2351 i,
2352 pSirWifiScanResult->ts,
2353 pSirWifiScanResult->ssid,
2354 pSirWifiScanResult->bssid,
2355 pSirWifiScanResult->channel,
2356 pSirWifiScanResult->rssi,
2357 pSirWifiScanResult->rtt,
2358 pSirWifiScanResult->rtt_sd);
2359
2360 ap = nla_nest_start(skb, j + 1);
2361 if (!ap)
2362 {
2363 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2364 goto fail;
2365 }
2366
2367 if (nla_put_u64(skb,
2368 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2369 pSirWifiScanResult->ts) )
2370 {
2371 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2372 goto fail;
2373 }
2374 if (nla_put(skb,
2375 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2376 sizeof(pSirWifiScanResult->ssid),
2377 pSirWifiScanResult->ssid) )
2378 {
2379 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2380 goto fail;
2381 }
2382 if (nla_put(skb,
2383 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2384 sizeof(pSirWifiScanResult->bssid),
2385 pSirWifiScanResult->bssid) )
2386 {
2387 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2388 goto fail;
2389 }
2390 if (nla_put_u32(skb,
2391 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2392 pSirWifiScanResult->channel) )
2393 {
2394 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2395 goto fail;
2396 }
2397 if (nla_put_u32(skb,
2398 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2399 pSirWifiScanResult->rssi) )
2400 {
2401 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2402 goto fail;
2403 }
2404 if (nla_put_u32(skb,
2405 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2406 pSirWifiScanResult->rtt) )
2407 {
2408 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2409 goto fail;
2410 }
2411 if (nla_put_u32(skb,
2412 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2413 pSirWifiScanResult->rtt_sd))
2414 {
2415 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2416 goto fail;
2417 }
2418
2419 nla_nest_end(skb, ap);
2420 }
2421 nla_nest_end(skb, aps);
2422
2423 }
2424 cfg80211_vendor_event(skb, GFP_KERNEL);
2425 } while (totalResults > 0);
2426
2427 return;
2428fail:
2429 kfree_skb(skb);
2430 return;
2431}
2432
2433static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2434 void *pMsg)
2435{
2436 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2437 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2438 struct sk_buff *skb = NULL;
2439 tANI_U32 i;
2440
2441 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2442 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2443 "or pData(%p) is null"), pData);
2444 return;
2445 }
2446
2447 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2448 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2449 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2450 GFP_KERNEL);
2451
2452 if (!skb) {
2453 hddLog(VOS_TRACE_LEVEL_ERROR,
2454 FL("cfg80211_vendor_event_alloc failed"));
2455 return;
2456 }
2457 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2458 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2459 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2460 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2461
2462 for (i = 0; i < pData->numOfAps; i++) {
2463 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2464 "Ssid (%s) "
2465 "Bssid (" MAC_ADDRESS_STR ") "
2466 "Channel (%u) "
2467 "Rssi (%d) "
2468 "RTT (%u) "
2469 "RTT_SD (%u) ",
2470 i,
2471 pData->ap[i].ts,
2472 pData->ap[i].ssid,
2473 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2474 pData->ap[i].channel,
2475 pData->ap[i].rssi,
2476 pData->ap[i].rtt,
2477 pData->ap[i].rtt_sd);
2478 }
2479
2480 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2481 pData->requestId) ||
2482 nla_put_u32(skb,
2483 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2484 pData->numOfAps)) {
2485 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2486 goto fail;
2487 }
2488 if (pData->numOfAps) {
2489 struct nlattr *aps;
2490
2491 aps = nla_nest_start(skb,
2492 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2493 if (!aps)
2494 goto fail;
2495
2496 for (i = 0; i < pData->numOfAps; i++) {
2497 struct nlattr *ap;
2498
2499 ap = nla_nest_start(skb, i + 1);
2500 if (!ap)
2501 goto fail;
2502
2503 if (nla_put_u64(skb,
2504 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2505 pData->ap[i].ts) ||
2506 nla_put(skb,
2507 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2508 sizeof(pData->ap[i].ssid),
2509 pData->ap[i].ssid) ||
2510 nla_put(skb,
2511 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2512 sizeof(pData->ap[i].bssid),
2513 pData->ap[i].bssid) ||
2514 nla_put_u32(skb,
2515 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2516 pData->ap[i].channel) ||
2517 nla_put_s32(skb,
2518 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2519 pData->ap[i].rssi) ||
2520 nla_put_u32(skb,
2521 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2522 pData->ap[i].rtt) ||
2523 nla_put_u32(skb,
2524 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2525 pData->ap[i].rtt_sd))
2526 goto fail;
2527
2528 nla_nest_end(skb, ap);
2529 }
2530 nla_nest_end(skb, aps);
2531
2532 if (nla_put_u8(skb,
2533 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2534 pData->moreData))
2535 goto fail;
2536 }
2537
2538 cfg80211_vendor_event(skb, GFP_KERNEL);
2539 return;
2540
2541fail:
2542 kfree_skb(skb);
2543 return;
2544
2545}
2546static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
2547 void *pMsg)
2548{
2549 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2550 struct sk_buff *skb = NULL;
2551 tANI_U32 i, j;
2552 tpSirWifiSignificantChangeEvent pData =
2553 (tpSirWifiSignificantChangeEvent) pMsg;
2554
2555 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2556 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2557 "or pData(%p) is null"), pData);
2558 return;
2559 }
2560 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2561 EXTSCAN_EVENT_BUF_SIZE,
2562 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
2563 GFP_KERNEL);
2564
2565 if (!skb) {
2566 hddLog(VOS_TRACE_LEVEL_ERROR,
2567 FL("cfg80211_vendor_event_alloc failed"));
2568 return;
2569 }
2570 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2571 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2572 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
2573 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
2574 pData->numSigRssiBss);
2575 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
2576
2577 for (i = 0; i < pData->numSigRssiBss; i++) {
2578 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
2579 " num RSSI %u ",
2580 i, pData->sigRssiResult[i].bssid,
2581 pData->sigRssiResult[i].channel,
2582 pData->sigRssiResult[i].numRssi);
2583
2584 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
2585
2586 hddLog(VOS_TRACE_LEVEL_INFO,
2587 " [%d]",
2588 pData->sigRssiResult[i].rssi[0]);
2589
2590 }
2591 }
2592
2593
2594 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2595 pData->requestId) ||
2596 nla_put_u32(skb,
2597 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2598 pData->numSigRssiBss)) {
2599 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2600 goto fail;
2601 }
2602
2603 if (pData->numSigRssiBss) {
2604 struct nlattr *aps;
2605 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2606 if (!aps)
2607 goto fail;
2608 for (i = 0; i < pData->numSigRssiBss; i++) {
2609 struct nlattr *ap;
2610
2611 ap = nla_nest_start(skb, i);
2612 if (!ap)
2613 goto fail;
2614 if (nla_put(skb,
2615 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
2616 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
2617 nla_put_u32(skb,
2618 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
2619 pData->sigRssiResult[i].channel) ||
2620 nla_put_u32(skb,
2621 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
2622 pData->sigRssiResult[i].numRssi) ||
2623 nla_put(skb,
2624 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
2625 sizeof(s32) * pData->sigRssiResult[i].numRssi,
2626 pData->sigRssiResult[i].rssi))
2627 goto fail;
2628 nla_nest_end(skb, ap);
2629 }
2630 nla_nest_end(skb, aps);
2631 if (nla_put_u8(skb,
2632 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2633 pData->moreData))
2634 goto fail;
2635 }
2636 cfg80211_vendor_event(skb, GFP_KERNEL);
2637 return;
2638fail:
2639 kfree_skb(skb);
2640 return;
2641}
2642
2643static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
2644 void *pMsg)
2645{
2646 struct sk_buff *skb;
2647 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2648 tpSirWifiFullScanResultEvent pData =
2649 (tpSirWifiFullScanResultEvent) (pMsg);
2650
2651 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2652 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2653 "or pData(%p) is null"), pData);
2654 return;
2655 }
2656
2657 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2658 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2659 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
2660 GFP_KERNEL);
2661
2662 if (!skb) {
2663 hddLog(VOS_TRACE_LEVEL_ERROR,
2664 FL("cfg80211_vendor_event_alloc failed"));
2665 return;
2666 }
2667
2668 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2669 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
2670 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
2671 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
2672 "Ssid (%s)"
2673 "Bssid (" MAC_ADDRESS_STR ")"
2674 "Channel (%u)"
2675 "Rssi (%d)"
2676 "RTT (%u)"
2677 "RTT_SD (%u)"),
2678 pData->ap.ts,
2679 pData->ap.ssid,
2680 MAC_ADDR_ARRAY(pData->ap.bssid),
2681 pData->ap.channel,
2682 pData->ap.rssi,
2683 pData->ap.rtt,
2684 pData->ap.rtt_sd);
2685 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
2686 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2687 pData->requestId) ||
2688 nla_put_u64(skb,
2689 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2690 pData->ap.ts) ||
2691 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2692 sizeof(pData->ap.ssid),
2693 pData->ap.ssid) ||
2694 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2695 WNI_CFG_BSSID_LEN,
2696 pData->ap.bssid) ||
2697 nla_put_u32(skb,
2698 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2699 pData->ap.channel) ||
2700 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2701 pData->ap.rssi) ||
2702 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2703 pData->ap.rtt) ||
2704 nla_put_u32(skb,
2705 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2706 pData->ap.rtt_sd) ||
2707 nla_put_u16(skb,
2708 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
2709 pData->ap.beaconPeriod) ||
2710 nla_put_u16(skb,
2711 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
2712 pData->ap.capability) ||
2713 nla_put_u32(skb,
2714 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
2715 pData->ieLength))
2716 {
2717 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2718 goto nla_put_failure;
2719 }
2720 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
2721 pData->ieLength,
2722 pData->ie))
2723 {
2724 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2725 goto nla_put_failure;
2726 }
2727
2728 cfg80211_vendor_event(skb, GFP_KERNEL);
2729 return;
2730
2731nla_put_failure:
2732 kfree_skb(skb);
2733 return;
2734}
2735
2736static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
2737 void *pMsg)
2738{
2739 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2740 struct sk_buff *skb = NULL;
2741 tpSirEXTScanResultsAvailableIndParams pData =
2742 (tpSirEXTScanResultsAvailableIndParams) pMsg;
2743
2744 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2745 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2746 "or pData(%p) is null"), pData);
2747 return;
2748 }
2749
2750 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2751 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2752 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
2753 GFP_KERNEL);
2754
2755 if (!skb) {
2756 hddLog(VOS_TRACE_LEVEL_ERROR,
2757 FL("cfg80211_vendor_event_alloc failed"));
2758 return;
2759 }
2760
2761 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2762 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2763 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
2764 pData->numResultsAvailable);
2765 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2766 pData->requestId) ||
2767 nla_put_u32(skb,
2768 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2769 pData->numResultsAvailable)) {
2770 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2771 goto nla_put_failure;
2772 }
2773
2774 cfg80211_vendor_event(skb, GFP_KERNEL);
2775 return;
2776
2777nla_put_failure:
2778 kfree_skb(skb);
2779 return;
2780}
2781
2782static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
2783{
2784 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2785 struct sk_buff *skb = NULL;
2786 tpSirEXTScanProgressIndParams pData =
2787 (tpSirEXTScanProgressIndParams) pMsg;
2788
2789 if (wlan_hdd_validate_context(pHddCtx) || !pData) {
2790 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid "
2791 "or pData(%p) is null"), pData);
2792 return;
2793 }
2794
2795 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2796 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2797 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
2798 GFP_KERNEL);
2799
2800 if (!skb) {
2801 hddLog(VOS_TRACE_LEVEL_ERROR,
2802 FL("cfg80211_vendor_event_alloc failed"));
2803 return;
2804 }
2805 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2806 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
2807 pData->extScanEventType);
2808 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
2809 pData->status);
2810
2811 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
2812 pData->extScanEventType) ||
2813 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05302814 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2815 pData->requestId) ||
2816 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302817 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
2818 pData->status)) {
2819 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2820 goto nla_put_failure;
2821 }
2822
2823 cfg80211_vendor_event(skb, GFP_KERNEL);
2824 return;
2825
2826nla_put_failure:
2827 kfree_skb(skb);
2828 return;
2829}
2830
2831void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
2832 void *pMsg)
2833{
2834 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2835
2836 if (wlan_hdd_validate_context(pHddCtx)) {
2837 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is not valid"));
2838 return;
2839 }
2840
2841 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
2842
2843
2844 switch(evType) {
2845 case SIR_HAL_EXTSCAN_START_RSP:
2846 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
2847 break;
2848
2849 case SIR_HAL_EXTSCAN_STOP_RSP:
2850 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
2851 break;
2852 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
2853 /* There is no need to send this response to upper layer
2854 Just log the message */
2855 hddLog(VOS_TRACE_LEVEL_INFO,
2856 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
2857 break;
2858 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
2859 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
2860 break;
2861
2862 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
2863 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
2864 break;
2865
2866 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
2867 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
2868 break;
2869
2870 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
2871 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
2872 break;
2873 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
2874 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
2875 break;
2876 case SIR_HAL_EXTSCAN_PROGRESS_IND:
2877 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
2878 break;
2879 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
2880 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
2881 break;
2882 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
2883 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
2884 break;
2885 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
2886 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
2887 break;
2888 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
2889 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
2890 break;
2891 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
2892 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
2893 break;
2894 default:
2895 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
2896 break;
2897 }
2898}
2899
2900static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
2901 struct wireless_dev *wdev,
2902 void *data, int dataLen)
2903{
Dino Myclee8843b32014-07-04 14:21:45 +05302904 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302905 struct net_device *dev = wdev->netdev;
2906 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2907 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2908 struct nlattr
2909 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
2910 eHalStatus status;
2911
2912 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering"));
2913 status = wlan_hdd_validate_context(pHddCtx);
2914 if (0 != status)
2915 {
2916 hddLog(VOS_TRACE_LEVEL_ERROR,
2917 FL("HDD context is not valid"));
2918 return -EINVAL;
2919 }
Dino Myclee8843b32014-07-04 14:21:45 +05302920 /* check the EXTScan Capability */
2921 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
2922 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
2923 {
2924 hddLog(VOS_TRACE_LEVEL_ERROR,
2925 FL("EXTScan not enabled/supported by Firmware"));
2926 return -EINVAL;
2927 }
2928
Dino Mycle6fb96c12014-06-10 11:52:40 +05302929 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
2930 data, dataLen,
2931 wlan_hdd_extscan_config_policy)) {
2932 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
2933 return -EINVAL;
2934 }
2935
2936 /* Parse and fetch request Id */
2937 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
2938 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
2939 return -EINVAL;
2940 }
2941
Dino Mycle6fb96c12014-06-10 11:52:40 +05302942
Dino Myclee8843b32014-07-04 14:21:45 +05302943 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05302944 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05302945 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302946
Dino Myclee8843b32014-07-04 14:21:45 +05302947 reqMsg.sessionId = pAdapter->sessionId;
2948 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302949
Dino Myclee8843b32014-07-04 14:21:45 +05302950 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302951 if (!HAL_STATUS_SUCCESS(status)) {
2952 hddLog(VOS_TRACE_LEVEL_ERROR,
2953 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05302954 return -EINVAL;
2955 }
2956
2957 return 0;
2958}
2959
2960
2961static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
2962 struct wireless_dev *wdev,
2963 void *data, int dataLen)
2964{
Dino Myclee8843b32014-07-04 14:21:45 +05302965 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05302966 struct net_device *dev = wdev->netdev;
2967 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2968 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2969 struct nlattr
2970 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
2971 eHalStatus status;
2972
2973 status = wlan_hdd_validate_context(pHddCtx);
2974 if (0 != status)
2975 {
2976 hddLog(VOS_TRACE_LEVEL_ERROR,
2977 FL("HDD context is not valid"));
2978 return -EINVAL;
2979 }
Dino Myclee8843b32014-07-04 14:21:45 +05302980 /* check the EXTScan Capability */
2981 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
2982 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
2983 {
2984 hddLog(VOS_TRACE_LEVEL_ERROR,
2985 FL("EXTScan not enabled/supported by Firmware"));
2986 return -EINVAL;
2987 }
2988
Dino Mycle6fb96c12014-06-10 11:52:40 +05302989 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
2990 data, dataLen,
2991 wlan_hdd_extscan_config_policy)) {
2992 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
2993 return -EINVAL;
2994 }
2995 /* Parse and fetch request Id */
2996 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
2997 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
2998 return -EINVAL;
2999 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303000
Dino Myclee8843b32014-07-04 14:21:45 +05303001 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303002 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3003
Dino Myclee8843b32014-07-04 14:21:45 +05303004 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303005
Dino Myclee8843b32014-07-04 14:21:45 +05303006 reqMsg.sessionId = pAdapter->sessionId;
3007 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303008
3009 /* Parse and fetch flush parameter */
3010 if (!tb
3011 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3012 {
3013 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3014 goto failed;
3015 }
Dino Myclee8843b32014-07-04 14:21:45 +05303016 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303017 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3018
Dino Myclee8843b32014-07-04 14:21:45 +05303019 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303020
Dino Myclee8843b32014-07-04 14:21:45 +05303021 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303022 if (!HAL_STATUS_SUCCESS(status)) {
3023 hddLog(VOS_TRACE_LEVEL_ERROR,
3024 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303025 return -EINVAL;
3026 }
3027 return 0;
3028
3029failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303030 return -EINVAL;
3031}
3032
3033static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3034 struct wireless_dev *wdev,
3035 void *data, int dataLen)
3036{
3037 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3038 struct net_device *dev = wdev->netdev;
3039 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3040 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3041 struct nlattr
3042 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3043 struct nlattr
3044 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3045 struct nlattr *apTh;
3046 eHalStatus status;
3047 tANI_U8 i = 0;
3048 int rem;
3049
3050 status = wlan_hdd_validate_context(pHddCtx);
3051 if (0 != status)
3052 {
3053 hddLog(VOS_TRACE_LEVEL_ERROR,
3054 FL("HDD context is not valid"));
3055 return -EINVAL;
3056 }
Dino Myclee8843b32014-07-04 14:21:45 +05303057 /* check the EXTScan Capability */
3058 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3059 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3060 {
3061 hddLog(VOS_TRACE_LEVEL_ERROR,
3062 FL("EXTScan not enabled/supported by Firmware"));
3063 return -EINVAL;
3064 }
3065
Dino Mycle6fb96c12014-06-10 11:52:40 +05303066 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3067 data, dataLen,
3068 wlan_hdd_extscan_config_policy)) {
3069 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3070 return -EINVAL;
3071 }
3072
3073 /* Parse and fetch request Id */
3074 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3075 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3076 return -EINVAL;
3077 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303078 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3079 vos_mem_malloc(sizeof(*pReqMsg));
3080 if (!pReqMsg) {
3081 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3082 return -ENOMEM;
3083 }
3084
Dino Myclee8843b32014-07-04 14:21:45 +05303085
Dino Mycle6fb96c12014-06-10 11:52:40 +05303086 pReqMsg->requestId = nla_get_u32(
3087 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3088 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3089
3090 /* Parse and fetch number of APs */
3091 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3092 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3093 goto fail;
3094 }
3095
3096 pReqMsg->sessionId = pAdapter->sessionId;
3097 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3098
3099 pReqMsg->numAp = nla_get_u32(
3100 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3101 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3102
3103 nla_for_each_nested(apTh,
3104 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3105 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3106 nla_data(apTh), nla_len(apTh),
3107 NULL)) {
3108 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3109 goto fail;
3110 }
3111
3112 /* Parse and fetch MAC address */
3113 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3114 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3115 goto fail;
3116 }
3117 memcpy(pReqMsg->ap[i].bssid, nla_data(
3118 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3119 sizeof(tSirMacAddr));
3120 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3121
3122 /* Parse and fetch low RSSI */
3123 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3124 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3125 goto fail;
3126 }
3127 pReqMsg->ap[i].low = nla_get_s32(
3128 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3129 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3130
3131 /* Parse and fetch high RSSI */
3132 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3133 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3134 goto fail;
3135 }
3136 pReqMsg->ap[i].high = nla_get_s32(
3137 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3138 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3139 pReqMsg->ap[i].high);
3140
3141 /* Parse and fetch channel */
3142 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3143 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3144 goto fail;
3145 }
3146 pReqMsg->ap[i].channel = nla_get_u32(
3147 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3148 hddLog(VOS_TRACE_LEVEL_INFO,
3149 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3150 i++;
3151 }
3152 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3153 if (!HAL_STATUS_SUCCESS(status)) {
3154 hddLog(VOS_TRACE_LEVEL_ERROR,
3155 FL("sme_SetBssHotlist failed(err=%d)"), status);
3156 vos_mem_free(pReqMsg);
3157 return -EINVAL;
3158 }
3159
Dino Myclee8843b32014-07-04 14:21:45 +05303160 vos_mem_free(pReqMsg);
3161
Dino Mycle6fb96c12014-06-10 11:52:40 +05303162 return 0;
3163
3164fail:
3165 vos_mem_free(pReqMsg);
3166 return -EINVAL;
3167}
3168
3169static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3170 struct wireless_dev *wdev,
3171 void *data, int dataLen)
3172{
3173 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3174 struct net_device *dev = wdev->netdev;
3175 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3176 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3177 struct nlattr
3178 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3179 struct nlattr
3180 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3181 struct nlattr *apTh;
3182 eHalStatus status;
3183 int i = 0;
3184 int rem;
3185
3186 status = wlan_hdd_validate_context(pHddCtx);
3187 if (0 != status)
3188 {
3189 hddLog(VOS_TRACE_LEVEL_ERROR,
3190 FL("HDD context is not valid"));
3191 return -EINVAL;
3192 }
Dino Myclee8843b32014-07-04 14:21:45 +05303193 /* check the EXTScan Capability */
3194 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3195 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3196 {
3197 hddLog(VOS_TRACE_LEVEL_ERROR,
3198 FL("EXTScan not enabled/supported by Firmware"));
3199 return -EINVAL;
3200 }
3201
Dino Mycle6fb96c12014-06-10 11:52:40 +05303202 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3203 data, dataLen,
3204 wlan_hdd_extscan_config_policy)) {
3205 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3206 return -EINVAL;
3207 }
3208
3209 /* Parse and fetch request Id */
3210 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3211 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3212 return -EINVAL;
3213 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303214 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303215 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303216 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303217 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3218 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303219 }
3220
Dino Myclee8843b32014-07-04 14:21:45 +05303221
3222
Dino Mycle6fb96c12014-06-10 11:52:40 +05303223 pReqMsg->requestId = nla_get_u32(
3224 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3225 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3226
3227 /* Parse and fetch RSSI sample size */
3228 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3229 {
3230 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3231 goto fail;
3232 }
3233 pReqMsg->rssiSampleSize = nla_get_u32(
3234 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3235 hddLog(VOS_TRACE_LEVEL_INFO,
3236 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3237
3238 /* Parse and fetch lost AP sample size */
3239 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3240 {
3241 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3242 goto fail;
3243 }
3244 pReqMsg->lostApSampleSize = nla_get_u32(
3245 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3246 hddLog(VOS_TRACE_LEVEL_INFO,
3247 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3248 /* Parse and fetch minimum Breaching */
3249 if (!tb
3250 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3251 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3252 goto fail;
3253 }
3254 pReqMsg->minBreaching = nla_get_u32(
3255 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3256 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3257
3258 /* Parse and fetch number of APs */
3259 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3260 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3261 goto fail;
3262 }
3263 pReqMsg->numAp = nla_get_u32(
3264 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3265 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3266
3267 pReqMsg->sessionId = pAdapter->sessionId;
3268 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3269
3270 nla_for_each_nested(apTh,
3271 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3272 if(nla_parse(tb2,
3273 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3274 nla_data(apTh), nla_len(apTh),
3275 NULL)) {
3276 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3277 goto fail;
3278 }
3279
3280 /* Parse and fetch MAC address */
3281 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3282 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3283 goto fail;
3284 }
3285 memcpy(pReqMsg->ap[i].bssid, nla_data(
3286 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3287 sizeof(tSirMacAddr));
3288
3289 /* Parse and fetch low RSSI */
3290 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3291 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3292 goto fail;
3293 }
3294 pReqMsg->ap[i].low = nla_get_s32(
3295 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3296 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3297
3298 /* Parse and fetch high RSSI */
3299 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3300 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3301 goto fail;
3302 }
3303 pReqMsg->ap[i].high = nla_get_s32(
3304 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3305 hddLog(VOS_TRACE_LEVEL_INFO,
3306 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3307
3308 /* Parse and fetch channel */
3309 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3310 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3311 goto fail;
3312 }
3313 pReqMsg->ap[i].channel = nla_get_u32(
3314 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3315 hddLog(VOS_TRACE_LEVEL_INFO,
3316 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3317 i++;
3318 }
3319
3320 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3321 if (!HAL_STATUS_SUCCESS(status)) {
3322 hddLog(VOS_TRACE_LEVEL_ERROR,
3323 FL("sme_SetSignificantChange failed(err=%d)"), status);
3324 vos_mem_free(pReqMsg);
3325 return -EINVAL;
3326 }
Dino Myclee8843b32014-07-04 14:21:45 +05303327 vos_mem_free(pReqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303328 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Exiting"));
3329 return 0;
3330
3331fail:
3332 vos_mem_free(pReqMsg);
3333 return -EINVAL;
3334}
3335
3336static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3337 struct wireless_dev *wdev,
3338 void *data, int dataLen)
3339{
3340 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3341 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3342 tANI_U8 numChannels = 0;
3343 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3344 tANI_U32 requestId;
3345 tWifiBand wifiBand;
3346 eHalStatus status;
3347 struct sk_buff *replySkb;
3348 tANI_U8 i;
3349
3350 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering"));
3351 status = wlan_hdd_validate_context(pHddCtx);
3352 if (0 != status)
3353 {
3354 hddLog(VOS_TRACE_LEVEL_ERROR,
3355 FL("HDD context is not valid"));
3356 return -EINVAL;
3357 }
Dino Myclee8843b32014-07-04 14:21:45 +05303358 /* check the EXTScan Capability */
3359 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3360 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3361 {
3362 hddLog(VOS_TRACE_LEVEL_ERROR,
3363 FL("EXTScan not enabled/supported by Firmware"));
3364 return -EINVAL;
3365 }
3366
Dino Mycle6fb96c12014-06-10 11:52:40 +05303367 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3368 data, dataLen,
3369 wlan_hdd_extscan_config_policy)) {
3370 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3371 return -EINVAL;
3372 }
3373
3374 /* Parse and fetch request Id */
3375 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3376 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3377 return -EINVAL;
3378 }
3379 requestId = nla_get_u32(
3380 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3381 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3382
3383 /* Parse and fetch wifi band */
3384 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3385 {
3386 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3387 return -EINVAL;
3388 }
3389 wifiBand = nla_get_u32(
3390 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3391 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3392
3393 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3394 wifiBand, ChannelList,
3395 &numChannels);
3396 if (eHAL_STATUS_SUCCESS != status) {
3397 hddLog(VOS_TRACE_LEVEL_ERROR,
3398 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3399 return -EINVAL;
3400 }
3401 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3402 for (i = 0; i < numChannels; i++)
3403 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3404
3405 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3406 sizeof(u32) * numChannels +
3407 NLMSG_HDRLEN);
3408
3409 if (!replySkb) {
3410 hddLog(VOS_TRACE_LEVEL_ERROR,
3411 FL("valid channels: buffer alloc fail"));
3412 return -EINVAL;
3413 }
3414 if (nla_put_u32(replySkb,
3415 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3416 numChannels) ||
3417 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3418 sizeof(u32) * numChannels, ChannelList)) {
3419
3420 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3421 kfree_skb(replySkb);
3422 return -EINVAL;
3423 }
3424
3425 return cfg80211_vendor_cmd_reply(replySkb);
3426}
3427
3428static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
3429 struct wireless_dev *wdev,
3430 void *data, int dataLen)
3431{
Dino Myclee8843b32014-07-04 14:21:45 +05303432 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303433 struct net_device *dev = wdev->netdev;
3434 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3435 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3436 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3437 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3438 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3439 struct nlattr *buckets;
3440 struct nlattr *channels;
3441 int rem1;
3442 int rem2;
3443 eHalStatus status;
3444 tANI_U8 bktIndex;
3445 tANI_U32 i = 0, j = 0;
3446
3447 status = wlan_hdd_validate_context(pHddCtx);
3448 if (0 != status)
3449 {
3450 hddLog(VOS_TRACE_LEVEL_ERROR,
3451 FL("HDD context is not valid"));
3452 return -EINVAL;
3453 }
Dino Myclee8843b32014-07-04 14:21:45 +05303454 /* check the EXTScan Capability */
3455 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3456 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3457 {
3458 hddLog(VOS_TRACE_LEVEL_ERROR,
3459 FL("EXTScan not enabled/supported by Firmware"));
3460 return -EINVAL;
3461 }
3462
Dino Mycle6fb96c12014-06-10 11:52:40 +05303463 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3464 data, dataLen,
3465 wlan_hdd_extscan_config_policy)) {
3466 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3467 return -EINVAL;
3468 }
3469
3470 /* Parse and fetch request Id */
3471 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3472 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3473 return -EINVAL;
3474 }
3475
Dino Myclee8843b32014-07-04 14:21:45 +05303476 pReqMsg = (tpSirEXTScanStartReqParams)
3477 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303478 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303479 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3480 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303481 }
3482
3483 pReqMsg->requestId = nla_get_u32(
3484 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3485 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3486
3487 pReqMsg->sessionId = pAdapter->sessionId;
3488 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3489
3490 /* Parse and fetch base period */
3491 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
3492 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
3493 goto fail;
3494 }
3495 pReqMsg->basePeriod = nla_get_u32(
3496 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
3497 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
3498 pReqMsg->basePeriod);
3499
3500 /* Parse and fetch max AP per scan */
3501 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
3502 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
3503 goto fail;
3504 }
3505 pReqMsg->maxAPperScan = nla_get_u32(
3506 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
3507 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
3508 pReqMsg->maxAPperScan);
3509
3510 /* Parse and fetch report threshold */
3511 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
3512 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
3513 goto fail;
3514 }
3515 pReqMsg->reportThreshold = nla_get_u8(
3516 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
3517 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
3518 pReqMsg->reportThreshold);
3519
3520 /* Parse and fetch number of buckets */
3521 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
3522 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
3523 goto fail;
3524 }
3525 pReqMsg->numBuckets = nla_get_u8(
3526 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
3527 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
3528 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
3529 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
3530 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
3531 }
3532 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
3533 pReqMsg->numBuckets);
3534 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
3535 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
3536 goto fail;
3537 }
3538
3539 nla_for_each_nested(buckets,
3540 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
3541 if(nla_parse(bucket,
3542 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3543 nla_data(buckets), nla_len(buckets), NULL)) { //policy
3544 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3545 goto fail;
3546 }
3547
3548 /* Parse and fetch bucket spec */
3549 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
3550 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
3551 goto fail;
3552 }
3553 bktIndex = nla_get_u8(
3554 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
3555 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"), bktIndex);
3556 pReqMsg->buckets[bktIndex].bucket = bktIndex;
3557
3558 /* Parse and fetch wifi band */
3559 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
3560 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3561 goto fail;
3562 }
3563 pReqMsg->buckets[bktIndex].band = nla_get_u8(
3564 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
3565 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
3566 pReqMsg->buckets[bktIndex].band);
3567
3568 /* Parse and fetch period */
3569 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
3570 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
3571 goto fail;
3572 }
3573 pReqMsg->buckets[bktIndex].period = nla_get_u32(
3574 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
3575 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
3576 pReqMsg->buckets[bktIndex].period);
3577
3578 /* Parse and fetch report events */
3579 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
3580 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
3581 goto fail;
3582 }
3583 pReqMsg->buckets[bktIndex].reportEvents = nla_get_u8(
3584 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
3585 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
3586 pReqMsg->buckets[bktIndex].reportEvents);
3587
3588 /* Parse and fetch number of channels */
3589 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]) {
3590 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
3591 goto fail;
3592 }
3593 pReqMsg->buckets[bktIndex].numChannels = nla_get_u32(
3594 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
3595 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
3596 pReqMsg->buckets[bktIndex].numChannels);
3597
3598 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
3599 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
3600 goto fail;
3601 }
3602
3603 j = 0;
3604 nla_for_each_nested(channels,
3605 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
3606 if(nla_parse(channel,
3607 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3608 nla_data(channels), nla_len(channels),
3609 NULL)) { //wlan_hdd_extscan_config_policy here
3610 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3611 goto fail;
3612 }
3613
3614 /* Parse and fetch channel */
3615 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
3616 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3617 goto fail;
3618 }
3619 pReqMsg->buckets[bktIndex].channels[j].channel = nla_get_u32(
3620 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
3621 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
3622 pReqMsg->buckets[bktIndex].channels[j].channel);
3623
3624 /* Parse and fetch dwell time */
3625 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
3626 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
3627 goto fail;
3628 }
3629 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs = nla_get_u32(
3630 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
3631 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
3632 pReqMsg->buckets[bktIndex].channels[j].dwellTimeMs);
3633
3634 /* Parse and fetch channel spec passive */
3635 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
3636 hddLog(VOS_TRACE_LEVEL_ERROR,
3637 FL("attr channel spec passive failed"));
3638 goto fail;
3639 }
3640 pReqMsg->buckets[bktIndex].channels[j].passive = nla_get_u8(
3641 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
3642 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
3643 pReqMsg->buckets[bktIndex].channels[j].passive);
3644 j++;
3645 }
3646 i++;
3647 }
3648 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
3649 if (!HAL_STATUS_SUCCESS(status)) {
3650 hddLog(VOS_TRACE_LEVEL_ERROR,
3651 FL("sme_EXTScanStart failed(err=%d)"), status);
3652 vos_mem_free(pReqMsg);
3653 return -EINVAL;
3654 }
3655
Dino Myclee8843b32014-07-04 14:21:45 +05303656 vos_mem_free(pReqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303657 return 0;
3658
3659fail:
3660 vos_mem_free(pReqMsg);
3661 return -EINVAL;
3662}
3663
3664static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
3665 struct wireless_dev *wdev,
3666 void *data, int dataLen)
3667{
Dino Myclee8843b32014-07-04 14:21:45 +05303668 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303669 struct net_device *dev = wdev->netdev;
3670 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3671 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3672 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3673 eHalStatus status;
3674
3675 status = wlan_hdd_validate_context(pHddCtx);
3676 if (0 != status)
3677 {
3678 hddLog(VOS_TRACE_LEVEL_ERROR,
3679 FL("HDD context is not valid"));
3680 return -EINVAL;
3681 }
Dino Myclee8843b32014-07-04 14:21:45 +05303682 /* check the EXTScan Capability */
3683 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3684 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3685 {
3686 hddLog(VOS_TRACE_LEVEL_ERROR,
3687 FL("EXTScan not enabled/supported by Firmware"));
3688 return -EINVAL;
3689 }
3690
Dino Mycle6fb96c12014-06-10 11:52:40 +05303691 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3692 data, dataLen,
3693 wlan_hdd_extscan_config_policy)) {
3694 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3695 return -EINVAL;
3696 }
3697
3698 /* Parse and fetch request Id */
3699 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3700 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3701 return -EINVAL;
3702 }
3703
Dino Myclee8843b32014-07-04 14:21:45 +05303704 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303705 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303706 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303707
Dino Myclee8843b32014-07-04 14:21:45 +05303708 reqMsg.sessionId = pAdapter->sessionId;
3709 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303710
Dino Myclee8843b32014-07-04 14:21:45 +05303711 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303712 if (!HAL_STATUS_SUCCESS(status)) {
3713 hddLog(VOS_TRACE_LEVEL_ERROR,
3714 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303715 return -EINVAL;
3716 }
3717
3718 return 0;
3719}
3720
3721static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
3722 struct wireless_dev *wdev,
3723 void *data, int dataLen)
3724{
Dino Myclee8843b32014-07-04 14:21:45 +05303725 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303726 struct net_device *dev = wdev->netdev;
3727 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3728 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3729 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3730 eHalStatus status;
3731
3732 status = wlan_hdd_validate_context(pHddCtx);
3733 if (0 != status)
3734 {
3735 hddLog(VOS_TRACE_LEVEL_ERROR,
3736 FL("HDD context is not valid"));
3737 return -EINVAL;
3738 }
Dino Myclee8843b32014-07-04 14:21:45 +05303739 /* check the EXTScan Capability */
3740 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3741 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3742 {
3743 hddLog(VOS_TRACE_LEVEL_ERROR,
3744 FL("EXTScan not enabled/supported by Firmware"));
3745 return -EINVAL;
3746 }
3747
Dino Mycle6fb96c12014-06-10 11:52:40 +05303748 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3749 data, dataLen,
3750 wlan_hdd_extscan_config_policy)) {
3751 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3752 return -EINVAL;
3753 }
3754
3755 /* Parse and fetch request Id */
3756 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3757 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3758 return -EINVAL;
3759 }
3760
Dino Myclee8843b32014-07-04 14:21:45 +05303761 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303762 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303763 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303764
Dino Myclee8843b32014-07-04 14:21:45 +05303765 reqMsg.sessionId = pAdapter->sessionId;
3766 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303767
Dino Myclee8843b32014-07-04 14:21:45 +05303768 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303769 if (!HAL_STATUS_SUCCESS(status)) {
3770 hddLog(VOS_TRACE_LEVEL_ERROR,
3771 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303772 return -EINVAL;
3773 }
3774
3775 return 0;
3776}
3777
3778static int wlan_hdd_cfg80211_extscan_reset_significant_change(
3779 struct wiphy *wiphy,
3780 struct wireless_dev *wdev,
3781 void *data, int dataLen)
3782{
Dino Myclee8843b32014-07-04 14:21:45 +05303783 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303784 struct net_device *dev = wdev->netdev;
3785 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3786 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3787 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3788 eHalStatus status;
3789
3790 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Entering"));
3791 status = wlan_hdd_validate_context(pHddCtx);
3792 if (0 != status)
3793 {
3794 hddLog(VOS_TRACE_LEVEL_ERROR,
3795 FL("HDD context is not valid"));
3796 return -EINVAL;
3797 }
Dino Myclee8843b32014-07-04 14:21:45 +05303798 /* check the EXTScan Capability */
3799 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3800 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3801 {
3802 hddLog(VOS_TRACE_LEVEL_ERROR,
3803 FL("EXTScan not enabled/supported by Firmware"));
3804 return -EINVAL;
3805 }
3806
Dino Mycle6fb96c12014-06-10 11:52:40 +05303807 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3808 data, dataLen,
3809 wlan_hdd_extscan_config_policy)) {
3810 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3811 return -EINVAL;
3812 }
3813
3814 /* Parse and fetch request Id */
3815 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3816 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3817 return -EINVAL;
3818 }
3819
Dino Mycle6fb96c12014-06-10 11:52:40 +05303820
Dino Myclee8843b32014-07-04 14:21:45 +05303821 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303822 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303823 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303824
Dino Myclee8843b32014-07-04 14:21:45 +05303825 reqMsg.sessionId = pAdapter->sessionId;
3826 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303827
Dino Myclee8843b32014-07-04 14:21:45 +05303828 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303829 if (!HAL_STATUS_SUCCESS(status)) {
3830 hddLog(VOS_TRACE_LEVEL_ERROR,
3831 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303832 return -EINVAL;
3833 }
3834
3835 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Exiting"));
3836 return 0;
3837}
3838
3839#endif /* WLAN_FEATURE_EXTSCAN */
3840
Sunil Duttc69bccb2014-05-26 21:30:20 +05303841const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
3842{
3843#ifdef WLAN_FEATURE_LINK_LAYER_STATS
3844 {
3845 .info.vendor_id = QCA_NL80211_VENDOR_ID,
3846 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
3847 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
3848 WIPHY_VENDOR_CMD_NEED_NETDEV |
3849 WIPHY_VENDOR_CMD_NEED_RUNNING,
3850 .doit = wlan_hdd_cfg80211_ll_stats_clear
3851 },
3852
3853 {
3854 .info.vendor_id = QCA_NL80211_VENDOR_ID,
3855 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
3856 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
3857 WIPHY_VENDOR_CMD_NEED_NETDEV |
3858 WIPHY_VENDOR_CMD_NEED_RUNNING,
3859 .doit = wlan_hdd_cfg80211_ll_stats_set
3860 },
3861
3862 {
3863 .info.vendor_id = QCA_NL80211_VENDOR_ID,
3864 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
3865 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
3866 WIPHY_VENDOR_CMD_NEED_NETDEV |
3867 WIPHY_VENDOR_CMD_NEED_RUNNING,
3868 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05303869 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05303870#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05303871#ifdef WLAN_FEATURE_EXTSCAN
3872 {
3873 .info.vendor_id = QCA_NL80211_VENDOR_ID,
3874 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
3875 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
3876 WIPHY_VENDOR_CMD_NEED_NETDEV |
3877 WIPHY_VENDOR_CMD_NEED_RUNNING,
3878 .doit = wlan_hdd_cfg80211_extscan_start
3879 },
3880 {
3881 .info.vendor_id = QCA_NL80211_VENDOR_ID,
3882 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
3883 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
3884 WIPHY_VENDOR_CMD_NEED_NETDEV |
3885 WIPHY_VENDOR_CMD_NEED_RUNNING,
3886 .doit = wlan_hdd_cfg80211_extscan_stop
3887 },
3888 {
3889 .info.vendor_id = QCA_NL80211_VENDOR_ID,
3890 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
3891 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
3892 WIPHY_VENDOR_CMD_NEED_NETDEV,
3893 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
3894 },
3895 {
3896 .info.vendor_id = QCA_NL80211_VENDOR_ID,
3897 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
3898 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
3899 WIPHY_VENDOR_CMD_NEED_NETDEV |
3900 WIPHY_VENDOR_CMD_NEED_RUNNING,
3901 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
3902 },
3903 {
3904 .info.vendor_id = QCA_NL80211_VENDOR_ID,
3905 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
3906 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
3907 WIPHY_VENDOR_CMD_NEED_NETDEV |
3908 WIPHY_VENDOR_CMD_NEED_RUNNING,
3909 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
3910 },
3911 {
3912 .info.vendor_id = QCA_NL80211_VENDOR_ID,
3913 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
3914 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
3915 WIPHY_VENDOR_CMD_NEED_NETDEV |
3916 WIPHY_VENDOR_CMD_NEED_RUNNING,
3917 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
3918 },
3919 {
3920 .info.vendor_id = QCA_NL80211_VENDOR_ID,
3921 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
3922 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
3923 WIPHY_VENDOR_CMD_NEED_NETDEV |
3924 WIPHY_VENDOR_CMD_NEED_RUNNING,
3925 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
3926 },
3927 {
3928 .info.vendor_id = QCA_NL80211_VENDOR_ID,
3929 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
3930 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
3931 WIPHY_VENDOR_CMD_NEED_NETDEV |
3932 WIPHY_VENDOR_CMD_NEED_RUNNING,
3933 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
3934 },
3935 {
3936 .info.vendor_id = QCA_NL80211_VENDOR_ID,
3937 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
3938 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
3939 WIPHY_VENDOR_CMD_NEED_NETDEV |
3940 WIPHY_VENDOR_CMD_NEED_RUNNING,
3941 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
3942 },
3943#endif /* WLAN_FEATURE_EXTSCAN */
Sunil Duttc69bccb2014-05-26 21:30:20 +05303944};
3945
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08003946/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05303947static const
3948struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08003949{
3950#ifdef FEATURE_WLAN_CH_AVOID
3951 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05303952 .vendor_id = QCA_NL80211_VENDOR_ID,
3953 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08003954 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05303955#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
3956#ifdef WLAN_FEATURE_LINK_LAYER_STATS
3957 {
3958 /* Index = 1*/
3959 .vendor_id = QCA_NL80211_VENDOR_ID,
3960 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
3961 },
3962 {
3963 /* Index = 2*/
3964 .vendor_id = QCA_NL80211_VENDOR_ID,
3965 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
3966 },
3967 {
3968 /* Index = 3*/
3969 .vendor_id = QCA_NL80211_VENDOR_ID,
3970 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
3971 },
3972 {
3973 /* Index = 4*/
3974 .vendor_id = QCA_NL80211_VENDOR_ID,
3975 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
3976 },
3977 {
3978 /* Index = 5*/
3979 .vendor_id = QCA_NL80211_VENDOR_ID,
3980 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
3981 },
3982 {
3983 /* Index = 6*/
3984 .vendor_id = QCA_NL80211_VENDOR_ID,
3985 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
3986 },
3987#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05303988#ifdef WLAN_FEATURE_EXTSCAN
3989 {
3990 .vendor_id = QCA_NL80211_VENDOR_ID,
3991 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
3992 },
3993 {
3994 .vendor_id = QCA_NL80211_VENDOR_ID,
3995 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
3996 },
3997 {
3998 .vendor_id = QCA_NL80211_VENDOR_ID,
3999 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
4000 },
4001 {
4002 .vendor_id = QCA_NL80211_VENDOR_ID,
4003 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
4004 },
4005 {
4006 .vendor_id = QCA_NL80211_VENDOR_ID,
4007 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
4008 },
4009 {
4010 .vendor_id = QCA_NL80211_VENDOR_ID,
4011 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
4012 },
4013 {
4014 .vendor_id = QCA_NL80211_VENDOR_ID,
4015 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
4016 },
4017 {
4018 .vendor_id = QCA_NL80211_VENDOR_ID,
4019 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
4020 },
4021 {
4022 .vendor_id = QCA_NL80211_VENDOR_ID,
4023 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
4024 },
4025 {
4026 .vendor_id = QCA_NL80211_VENDOR_ID,
4027 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
4028 },
4029 {
4030 .vendor_id = QCA_NL80211_VENDOR_ID,
4031 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
4032 },
4033 {
4034 .vendor_id = QCA_NL80211_VENDOR_ID,
4035 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
4036 },
4037 {
4038 .vendor_id = QCA_NL80211_VENDOR_ID,
4039 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
4040 },
4041#endif /* WLAN_FEATURE_EXTSCAN */
Sunil Duttc69bccb2014-05-26 21:30:20 +05304042
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004043};
4044
Jeff Johnson295189b2012-06-20 16:38:30 -07004045/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304046 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304047 * This function is called by hdd_wlan_startup()
4048 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304049 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304051struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07004052{
4053 struct wiphy *wiphy;
4054 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304055 /*
4056 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 */
4058 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
4059
4060 if (!wiphy)
4061 {
4062 /* Print error and jump into err label and free the memory */
4063 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
4064 return NULL;
4065 }
4066
Sunil Duttc69bccb2014-05-26 21:30:20 +05304067
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 return wiphy;
4069}
4070
4071/*
4072 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304073 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 * private ioctl to change the band value
4075 */
4076int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
4077{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304078 int i, j;
4079 eNVChannelEnabledType channelEnabledState;
4080
Jeff Johnsone7245742012-09-05 17:12:55 -07004081 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304082
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304083 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304085
4086 if (NULL == wiphy->bands[i])
4087 {
4088 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
4089 __func__, i);
4090 continue;
4091 }
4092
4093 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
4094 {
4095 struct ieee80211_supported_band *band = wiphy->bands[i];
4096
4097 channelEnabledState = vos_nv_getChannelEnabledState(
4098 band->channels[j].hw_value);
4099
4100 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
4101 {
4102 // Enable Social channels for P2P
4103 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
4104 NV_CHANNEL_ENABLE == channelEnabledState)
4105 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
4106 else
4107 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4108 continue;
4109 }
4110 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
4111 {
4112 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4113 continue;
4114 }
4115
4116 if (NV_CHANNEL_DISABLE == channelEnabledState ||
4117 NV_CHANNEL_INVALID == channelEnabledState)
4118 {
4119 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4120 }
4121 else if (NV_CHANNEL_DFS == channelEnabledState)
4122 {
4123 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
4124 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
4125 }
4126 else
4127 {
4128 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
4129 |IEEE80211_CHAN_RADAR);
4130 }
4131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 }
4133 return 0;
4134}
4135/*
4136 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304137 * This function is called by hdd_wlan_startup()
4138 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 * This function is used to initialize and register wiphy structure.
4140 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304141int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 struct wiphy *wiphy,
4143 hdd_config_t *pCfg
4144 )
4145{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304146 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05304147 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4148
Jeff Johnsone7245742012-09-05 17:12:55 -07004149 ENTER();
4150
Jeff Johnson295189b2012-06-20 16:38:30 -07004151 /* Now bind the underlying wlan device with wiphy */
4152 set_wiphy_dev(wiphy, dev);
4153
4154 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07004155
Kiet Lam6c583332013-10-14 05:37:09 +05304156#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07004157 /* the flag for the other case would be initialzed in
4158 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07004159 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05304160#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07004161
Amar Singhalfddc28c2013-09-05 13:03:40 -07004162 /* This will disable updating of NL channels from passive to
4163 * active if a beacon is received on passive channel. */
4164 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07004165
Amar Singhalfddc28c2013-09-05 13:03:40 -07004166
Amar Singhala49cbc52013-10-08 18:37:44 -07004167
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004168#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004169 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
4170 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
4171 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07004172 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05304173 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004174#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07004175
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004176#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07004177 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08004178#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07004179 || pCfg->isFastRoamIniFeatureEnabled
4180#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004181#ifdef FEATURE_WLAN_ESE
4182 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07004183#endif
4184 )
4185 {
4186 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
4187 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08004188#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004189#ifdef FEATURE_WLAN_TDLS
4190 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
4191 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
4192#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05304193#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05304194 if (pCfg->configPNOScanSupport)
4195 {
4196 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
4197 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
4198 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
4199 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
4200 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05304201#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004202
Amar Singhalfddc28c2013-09-05 13:03:40 -07004203#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07004204 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
4205 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07004206 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07004207 driver need to determine what to do with both
4208 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07004209
4210 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07004211#else
4212 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07004213#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004214
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304215 wiphy->max_scan_ssids = MAX_SCAN_SSID;
4216
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +05304217 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07004218
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05304219 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
4220
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304222 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -07004224 | BIT(NL80211_IFTYPE_P2P_CLIENT)
4225 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 | BIT(NL80211_IFTYPE_AP);
4227
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304228 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004229 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304230#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
4231 if( pCfg->enableMCC )
4232 {
4233 /* Currently, supports up to two channels */
4234 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004235
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304236 if( !pCfg->allowMCCGODiffBI )
4237 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004238
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304239 }
4240 wiphy->iface_combinations = &wlan_hdd_iface_combination;
4241 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004242#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05304243 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08004244
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 /* Before registering we need to update the ht capabilitied based
4246 * on ini values*/
4247 if( !pCfg->ShortGI20MhzEnable )
4248 {
4249 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
4250 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
4251 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
4252 }
4253
4254 if( !pCfg->ShortGI40MhzEnable )
4255 {
4256 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
4257 }
4258
4259 if( !pCfg->nChannelBondingMode5GHz )
4260 {
4261 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
4262 }
4263
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304264 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05304265 if (true == hdd_is_5g_supported(pHddCtx))
4266 {
4267 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
4268 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05304269
4270 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
4271 {
4272
4273 if (NULL == wiphy->bands[i])
4274 {
4275 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
4276 __func__, i);
4277 continue;
4278 }
4279
4280 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
4281 {
4282 struct ieee80211_supported_band *band = wiphy->bands[i];
4283
4284 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
4285 {
4286 // Enable social channels for P2P
4287 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
4288 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
4289 else
4290 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4291 continue;
4292 }
4293 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
4294 {
4295 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
4296 continue;
4297 }
4298 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 }
4300 /*Initialise the supported cipher suite details*/
4301 wiphy->cipher_suites = hdd_cipher_suites;
4302 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
4303
4304 /*signal strength in mBm (100*dBm) */
4305 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
4306
4307#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05304308 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07004309#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004310
Sunil Duttc69bccb2014-05-26 21:30:20 +05304311 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
4312 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08004313 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
4314 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
4315
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304316 EXIT();
4317 return 0;
4318}
4319
4320/* In this function we are registering wiphy. */
4321int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
4322{
4323 ENTER();
4324 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 if (0 > wiphy_register(wiphy))
4326 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304327 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
4329 return -EIO;
4330 }
4331
4332 EXIT();
4333 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304334}
Jeff Johnson295189b2012-06-20 16:38:30 -07004335
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304336/* In this function we are updating channel list when,
4337 regulatory domain is FCC and country code is US.
4338 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
4339 As per FCC smart phone is not a indoor device.
4340 GO should not opeate on indoor channels */
4341void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
4342{
4343 int j;
4344 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4345 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
4346 //Default counrtycode from NV at the time of wiphy initialization.
4347 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
4348 &defaultCountryCode[0]))
4349 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004350 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304351 }
4352 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
4353 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05304354 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
4355 {
4356 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
4357 return;
4358 }
4359 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
4360 {
4361 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
4362 // Mark UNII -1 band channel as passive
4363 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
4364 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
4365 }
4366 }
4367}
4368
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05304369/* This function registers for all frame which supplicant is interested in */
4370void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004371{
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4373 /* Register for all P2P action, public action etc frames */
4374 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
4375
Jeff Johnsone7245742012-09-05 17:12:55 -07004376 ENTER();
4377
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 /* Right now we are registering these frame when driver is getting
4379 initialized. Once we will move to 2.6.37 kernel, in which we have
4380 frame register ops, we will move this code as a part of that */
4381 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304382 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
4384
4385 /* GAS Initial Response */
4386 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
4387 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304388
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 /* GAS Comeback Request */
4390 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
4391 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
4392
4393 /* GAS Comeback Response */
4394 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
4395 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
4396
4397 /* P2P Public Action */
4398 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304399 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 P2P_PUBLIC_ACTION_FRAME_SIZE );
4401
4402 /* P2P Action */
4403 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
4404 (v_U8_t*)P2P_ACTION_FRAME,
4405 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07004406
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05304407 /* WNM BSS Transition Request frame */
4408 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
4409 (v_U8_t*)WNM_BSS_ACTION_FRAME,
4410 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07004411
4412 /* WNM-Notification */
4413 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
4414 (v_U8_t*)WNM_NOTIFICATION_FRAME,
4415 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004416}
4417
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05304418void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004419{
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4421 /* Register for all P2P action, public action etc frames */
4422 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
4423
Jeff Johnsone7245742012-09-05 17:12:55 -07004424 ENTER();
4425
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 /* Right now we are registering these frame when driver is getting
4427 initialized. Once we will move to 2.6.37 kernel, in which we have
4428 frame register ops, we will move this code as a part of that */
4429 /* GAS Initial Request */
4430
4431 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
4432 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
4433
4434 /* GAS Initial Response */
4435 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
4436 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304437
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 /* GAS Comeback Request */
4439 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
4440 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
4441
4442 /* GAS Comeback Response */
4443 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
4444 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
4445
4446 /* P2P Public Action */
4447 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304448 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 P2P_PUBLIC_ACTION_FRAME_SIZE );
4450
4451 /* P2P Action */
4452 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
4453 (v_U8_t*)P2P_ACTION_FRAME,
4454 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07004455 /* WNM-Notification */
4456 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
4457 (v_U8_t*)WNM_NOTIFICATION_FRAME,
4458 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004459}
4460
4461#ifdef FEATURE_WLAN_WAPI
4462void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
4463 const u8 *mac_addr, u8 *key , int key_Len)
4464{
4465 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4466 tCsrRoamSetKey setKey;
4467 v_BOOL_t isConnected = TRUE;
4468 int status = 0;
4469 v_U32_t roamId= 0xFF;
4470 tANI_U8 *pKeyPtr = NULL;
4471 int n = 0;
4472
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05304473 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
4474 __func__, hdd_device_modetoString(pAdapter->device_mode),
4475 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004476
Gopichand Nakkalae7480202013-02-11 15:24:22 +05304477 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 setKey.keyId = key_index; // Store Key ID
4479 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
4480 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
4481 setKey.paeRole = 0 ; // the PAE role
4482 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
4483 {
4484 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
4485 }
4486 else
4487 {
4488 isConnected = hdd_connIsConnected(pHddStaCtx);
4489 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
4490 }
4491 setKey.keyLength = key_Len;
4492 pKeyPtr = setKey.Key;
4493 memcpy( pKeyPtr, key, key_Len);
4494
Arif Hussain6d2a3322013-11-17 19:50:10 -08004495 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 __func__, key_Len);
4497 for (n = 0 ; n < key_Len; n++)
4498 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
4499 __func__,n,setKey.Key[n]);
4500
4501 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
4502 if ( isConnected )
4503 {
4504 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
4505 pAdapter->sessionId, &setKey, &roamId );
4506 }
4507 if ( status != 0 )
4508 {
4509 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4510 "[%4d] sme_RoamSetKey returned ERROR status= %d",
4511 __LINE__, status );
4512 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
4513 }
4514}
4515#endif /* FEATURE_WLAN_WAPI*/
4516
4517#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304518int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 beacon_data_t **ppBeacon,
4520 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004521#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304522int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004523 beacon_data_t **ppBeacon,
4524 struct cfg80211_beacon_data *params,
4525 int dtim_period)
4526#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304527{
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 int size;
4529 beacon_data_t *beacon = NULL;
4530 beacon_data_t *old = NULL;
4531 int head_len,tail_len;
4532
Jeff Johnsone7245742012-09-05 17:12:55 -07004533 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304535 {
4536 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4537 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004540
4541 old = pAdapter->sessionCtx.ap.beacon;
4542
4543 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304544 {
4545 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4546 FL("session(%d) old and new heads points to NULL"),
4547 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304549 }
4550
4551 if (params->tail && !params->tail_len)
4552 {
4553 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4554 FL("tail_len is zero but tail is not NULL"));
4555 return -EINVAL;
4556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004557
Jeff Johnson295189b2012-06-20 16:38:30 -07004558#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
4559 /* Kernel 3.0 is not updating dtim_period for set beacon */
4560 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304561 {
4562 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4563 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004566#endif
4567
4568 if(params->head)
4569 head_len = params->head_len;
4570 else
4571 head_len = old->head_len;
4572
4573 if(params->tail || !old)
4574 tail_len = params->tail_len;
4575 else
4576 tail_len = old->tail_len;
4577
4578 size = sizeof(beacon_data_t) + head_len + tail_len;
4579
4580 beacon = kzalloc(size, GFP_KERNEL);
4581
4582 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304583 {
4584 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4585 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004588
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004589#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 if(params->dtim_period || !old )
4591 beacon->dtim_period = params->dtim_period;
4592 else
4593 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004594#else
4595 if(dtim_period || !old )
4596 beacon->dtim_period = dtim_period;
4597 else
4598 beacon->dtim_period = old->dtim_period;
4599#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304600
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
4602 beacon->tail = beacon->head + head_len;
4603 beacon->head_len = head_len;
4604 beacon->tail_len = tail_len;
4605
4606 if(params->head) {
4607 memcpy (beacon->head,params->head,beacon->head_len);
4608 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304609 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 if(old)
4611 memcpy (beacon->head,old->head,beacon->head_len);
4612 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304613
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 if(params->tail) {
4615 memcpy (beacon->tail,params->tail,beacon->tail_len);
4616 }
4617 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304618 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07004619 memcpy (beacon->tail,old->tail,beacon->tail_len);
4620 }
4621
4622 *ppBeacon = beacon;
4623
4624 kfree(old);
4625
4626 return 0;
4627
4628}
Jeff Johnson295189b2012-06-20 16:38:30 -07004629
4630v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
4631{
4632 int left = length;
4633 v_U8_t *ptr = pIes;
4634 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304635
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304637 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 elem_id = ptr[0];
4639 elem_len = ptr[1];
4640 left -= 2;
4641 if(elem_len > left)
4642 {
4643 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07004644 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 eid,elem_len,left);
4646 return NULL;
4647 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304648 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 {
4650 return ptr;
4651 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304652
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 left -= elem_len;
4654 ptr += (elem_len + 2);
4655 }
4656 return NULL;
4657}
4658
Jeff Johnson295189b2012-06-20 16:38:30 -07004659/* Check if rate is 11g rate or not */
4660static int wlan_hdd_rate_is_11g(u8 rate)
4661{
Sanjay Devnani28322e22013-06-21 16:13:40 -07004662 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 u8 i;
4664 for (i = 0; i < 8; i++)
4665 {
4666 if(rate == gRateArray[i])
4667 return TRUE;
4668 }
4669 return FALSE;
4670}
4671
4672/* Check for 11g rate and set proper 11g only mode */
4673static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
4674 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
4675{
4676 u8 i, num_rates = pIe[0];
4677
4678 pIe += 1;
4679 for ( i = 0; i < num_rates; i++)
4680 {
4681 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
4682 {
4683 /* If rate set have 11g rate than change the mode to 11G */
4684 *pSapHw_mode = eSAP_DOT11_MODE_11g;
4685 if (pIe[i] & BASIC_RATE_MASK)
4686 {
4687 /* If we have 11g rate as basic rate, it means mode
4688 is 11g only mode.
4689 */
4690 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
4691 *pCheckRatesfor11g = FALSE;
4692 }
4693 }
4694 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
4695 {
4696 *require_ht = TRUE;
4697 }
4698 }
4699 return;
4700}
4701
4702static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
4703{
4704 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
4705 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
4706 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
4707 u8 checkRatesfor11g = TRUE;
4708 u8 require_ht = FALSE;
4709 u8 *pIe=NULL;
4710
4711 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
4712
4713 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
4714 pBeacon->head_len, WLAN_EID_SUPP_RATES);
4715 if (pIe != NULL)
4716 {
4717 pIe += 1;
4718 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
4719 &pConfig->SapHw_mode);
4720 }
4721
4722 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
4723 WLAN_EID_EXT_SUPP_RATES);
4724 if (pIe != NULL)
4725 {
4726
4727 pIe += 1;
4728 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
4729 &pConfig->SapHw_mode);
4730 }
4731
4732 if( pConfig->channel > 14 )
4733 {
4734 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
4735 }
4736
4737 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
4738 WLAN_EID_HT_CAPABILITY);
4739
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304740 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 {
4742 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
4743 if(require_ht)
4744 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
4745 }
4746}
4747
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05304748static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
4749 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
4750{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07004751 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05304752 v_U8_t *pIe = NULL;
4753 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
4754
4755 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
4756 pBeacon->tail, pBeacon->tail_len);
4757
4758 if (pIe)
4759 {
4760 ielen = pIe[1] + 2;
4761 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
4762 {
4763 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
4764 }
4765 else
4766 {
4767 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
4768 return -EINVAL;
4769 }
4770 *total_ielen += ielen;
4771 }
4772 return 0;
4773}
4774
Arif Hussaine7f3ea52013-09-12 21:56:36 -07004775static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
4776 v_U8_t *genie, v_U8_t *total_ielen)
4777{
4778 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
4779 int left = pBeacon->tail_len;
4780 v_U8_t *ptr = pBeacon->tail;
4781 v_U8_t elem_id, elem_len;
4782 v_U16_t ielen = 0;
4783
4784 if ( NULL == ptr || 0 == left )
4785 return;
4786
4787 while (left >= 2)
4788 {
4789 elem_id = ptr[0];
4790 elem_len = ptr[1];
4791 left -= 2;
4792 if (elem_len > left)
4793 {
4794 hddLog( VOS_TRACE_LEVEL_ERROR,
4795 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
4796 elem_id, elem_len, left);
4797 return;
4798 }
4799 if (IE_EID_VENDOR == elem_id)
4800 {
4801 /* skipping the VSIE's which we don't want to include or
4802 * it will be included by existing code
4803 */
4804 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
4805#ifdef WLAN_FEATURE_WFD
4806 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
4807#endif
4808 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
4809 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
4810 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
4811 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
4812 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
4813 {
4814 ielen = ptr[1] + 2;
4815 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
4816 {
4817 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
4818 *total_ielen += ielen;
4819 }
4820 else
4821 {
4822 hddLog( VOS_TRACE_LEVEL_ERROR,
4823 "IE Length is too big "
4824 "IEs eid=%d elem_len=%d total_ie_lent=%d",
4825 elem_id, elem_len, *total_ielen);
4826 }
4827 }
4828 }
4829
4830 left -= elem_len;
4831 ptr += (elem_len + 2);
4832 }
4833 return;
4834}
4835
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004836#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07004837static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
4838 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004839#else
4840static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
4841 struct cfg80211_beacon_data *params)
4842#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004843{
4844 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05304845 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004846 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07004847 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004848
4849 genie = vos_mem_malloc(MAX_GENIE_LEN);
4850
4851 if(genie == NULL) {
4852
4853 return -ENOMEM;
4854 }
4855
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05304856 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
4857 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304859 hddLog(LOGE,
4860 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05304861 ret = -EINVAL;
4862 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 }
4864
4865#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05304866 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
4867 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
4868 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304869 hddLog(LOGE,
4870 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05304871 ret = -EINVAL;
4872 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 }
4874#endif
4875
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05304876 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
4877 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304879 hddLog(LOGE,
4880 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05304881 ret = -EINVAL;
4882 goto done;
4883 }
4884
4885 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
4886 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07004887 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004889
4890 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
4891 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
4892 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
4893 {
4894 hddLog(LOGE,
4895 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07004896 ret = -EINVAL;
4897 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 }
4899
4900 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
4901 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
4902 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
4903 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
4904 ==eHAL_STATUS_FAILURE)
4905 {
4906 hddLog(LOGE,
4907 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07004908 ret = -EINVAL;
4909 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 }
4911
4912 // Added for ProResp IE
4913 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
4914 {
4915 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
4916 u8 probe_rsp_ie_len[3] = {0};
4917 u8 counter = 0;
4918 /* Check Probe Resp Length if it is greater then 255 then Store
4919 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
4920 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
4921 Store More then 255 bytes into One Variable.
4922 */
4923 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
4924 {
4925 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
4926 {
4927 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
4928 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
4929 }
4930 else
4931 {
4932 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
4933 rem_probe_resp_ie_len = 0;
4934 }
4935 }
4936
4937 rem_probe_resp_ie_len = 0;
4938
4939 if (probe_rsp_ie_len[0] > 0)
4940 {
4941 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
4942 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
4943 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
4944 probe_rsp_ie_len[0], NULL,
4945 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
4946 {
4947 hddLog(LOGE,
4948 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07004949 ret = -EINVAL;
4950 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 }
4952 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
4953 }
4954
4955 if (probe_rsp_ie_len[1] > 0)
4956 {
4957 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
4958 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
4959 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
4960 probe_rsp_ie_len[1], NULL,
4961 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
4962 {
4963 hddLog(LOGE,
4964 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07004965 ret = -EINVAL;
4966 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 }
4968 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
4969 }
4970
4971 if (probe_rsp_ie_len[2] > 0)
4972 {
4973 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
4974 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
4975 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
4976 probe_rsp_ie_len[2], NULL,
4977 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
4978 {
4979 hddLog(LOGE,
4980 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07004981 ret = -EINVAL;
4982 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 }
4984 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
4985 }
4986
4987 if (probe_rsp_ie_len[1] == 0 )
4988 {
4989 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
4990 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
4991 eANI_BOOLEAN_FALSE) )
4992 {
4993 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004994 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 }
4996 }
4997
4998 if (probe_rsp_ie_len[2] == 0 )
4999 {
5000 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5001 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
5002 eANI_BOOLEAN_FALSE) )
5003 {
5004 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005005 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 }
5007 }
5008
5009 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5010 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5011 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5012 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5013 == eHAL_STATUS_FAILURE)
5014 {
5015 hddLog(LOGE,
5016 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005017 ret = -EINVAL;
5018 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005019 }
5020 }
5021 else
5022 {
5023 // Reset WNI_CFG_PROBE_RSP Flags
5024 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
5025
5026 hddLog(VOS_TRACE_LEVEL_INFO,
5027 "%s: No Probe Response IE received in set beacon",
5028 __func__);
5029 }
5030
5031 // Added for AssocResp IE
5032 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
5033 {
5034 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5035 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
5036 params->assocresp_ies_len, NULL,
5037 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5038 {
5039 hddLog(LOGE,
5040 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005041 ret = -EINVAL;
5042 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005043 }
5044
5045 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5046 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
5047 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
5048 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
5049 == eHAL_STATUS_FAILURE)
5050 {
5051 hddLog(LOGE,
5052 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07005053 ret = -EINVAL;
5054 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 }
5056 }
5057 else
5058 {
5059 hddLog(VOS_TRACE_LEVEL_INFO,
5060 "%s: No Assoc Response IE received in set beacon",
5061 __func__);
5062
5063 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
5064 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
5065 eANI_BOOLEAN_FALSE) )
5066 {
5067 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005068 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07005069 }
5070 }
5071
Jeff Johnsone7245742012-09-05 17:12:55 -07005072done:
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05305074 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07005075}
Jeff Johnson295189b2012-06-20 16:38:30 -07005076
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305077/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 * FUNCTION: wlan_hdd_validate_operation_channel
5079 * called by wlan_hdd_cfg80211_start_bss() and
5080 * wlan_hdd_cfg80211_set_channel()
5081 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305082 * channel list.
5083 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07005084VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005085{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305086
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 v_U32_t num_ch = 0;
5088 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5089 u32 indx = 0;
5090 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305091 v_U8_t fValidChannel = FALSE, count = 0;
5092 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305093
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5095
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305096 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305098 /* Validate the channel */
5099 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305101 if ( channel == rfChannels[count].channelNum )
5102 {
5103 fValidChannel = TRUE;
5104 break;
5105 }
5106 }
5107 if (fValidChannel != TRUE)
5108 {
5109 hddLog(VOS_TRACE_LEVEL_ERROR,
5110 "%s: Invalid Channel [%d]", __func__, channel);
5111 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005112 }
5113 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305114 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05305116 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
5117 valid_ch, &num_ch))
5118 {
5119 hddLog(VOS_TRACE_LEVEL_ERROR,
5120 "%s: failed to get valid channel list", __func__);
5121 return VOS_STATUS_E_FAILURE;
5122 }
5123 for (indx = 0; indx < num_ch; indx++)
5124 {
5125 if (channel == valid_ch[indx])
5126 {
5127 break;
5128 }
5129 }
5130
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05305131 if (indx >= num_ch)
5132 {
5133 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
5134 {
5135 eCsrBand band;
5136 unsigned int freq;
5137
5138 sme_GetFreqBand(hHal, &band);
5139
5140 if (eCSR_BAND_5G == band)
5141 {
5142#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
5143 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
5144 {
5145 freq = ieee80211_channel_to_frequency(channel,
5146 IEEE80211_BAND_2GHZ);
5147 }
5148 else
5149 {
5150 freq = ieee80211_channel_to_frequency(channel,
5151 IEEE80211_BAND_5GHZ);
5152 }
5153#else
5154 freq = ieee80211_channel_to_frequency(channel);
5155#endif
5156 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
5157 return VOS_STATUS_SUCCESS;
5158 }
5159 }
5160
5161 hddLog(VOS_TRACE_LEVEL_ERROR,
5162 "%s: Invalid Channel [%d]", __func__, channel);
5163 return VOS_STATUS_E_FAILURE;
5164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005165 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05305166
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305168
Jeff Johnson295189b2012-06-20 16:38:30 -07005169}
5170
Viral Modi3a32cc52013-02-08 11:14:52 -08005171/**
5172 * FUNCTION: wlan_hdd_cfg80211_set_channel
5173 * This function is used to set the channel number
5174 */
5175static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
5176 struct ieee80211_channel *chan,
5177 enum nl80211_channel_type channel_type
5178 )
5179{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305180 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08005181 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07005182 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08005183 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305184 hdd_context_t *pHddCtx;
5185 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08005186
5187 ENTER();
5188
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305189
Viral Modi3a32cc52013-02-08 11:14:52 -08005190 if( NULL == dev )
5191 {
5192 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005193 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08005194 return -ENODEV;
5195 }
5196 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05305197
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305198 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5199 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
5200 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08005201 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305202 "%s: device_mode = %s (%d) freq = %d", __func__,
5203 hdd_device_modetoString(pAdapter->device_mode),
5204 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305205
5206 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5207 status = wlan_hdd_validate_context(pHddCtx);
5208
5209 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08005210 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305211 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5212 "%s: HDD context is not valid", __func__);
5213 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08005214 }
5215
5216 /*
5217 * Do freq to chan conversion
5218 * TODO: for 11a
5219 */
5220
5221 channel = ieee80211_frequency_to_channel(freq);
5222
5223 /* Check freq range */
5224 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
5225 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
5226 {
5227 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005228 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08005229 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
5230 WNI_CFG_CURRENT_CHANNEL_STAMAX);
5231 return -EINVAL;
5232 }
5233
5234 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5235
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05305236 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
5237 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08005238 {
5239 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
5240 {
5241 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005242 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08005243 return -EINVAL;
5244 }
5245 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5246 "%s: set channel to [%d] for device mode =%d",
5247 __func__, channel,pAdapter->device_mode);
5248 }
5249 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08005250 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08005251 )
5252 {
5253 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5254 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
5255 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5256
5257 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
5258 {
5259 /* Link is up then return cant set channel*/
5260 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005261 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08005262 return -EINVAL;
5263 }
5264
5265 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
5266 pHddStaCtx->conn_info.operationChannel = channel;
5267 pRoamProfile->ChannelInfo.ChannelList =
5268 &pHddStaCtx->conn_info.operationChannel;
5269 }
5270 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08005271 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08005272 )
5273 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05305274 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
5275 {
5276 if(VOS_STATUS_SUCCESS !=
5277 wlan_hdd_validate_operation_channel(pAdapter,channel))
5278 {
5279 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005280 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05305281 return -EINVAL;
5282 }
5283 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
5284 }
5285 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08005286 {
5287 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
5288
5289 /* If auto channel selection is configured as enable/ 1 then ignore
5290 channel set by supplicant
5291 */
5292 if ( cfg_param->apAutoChannelSelection )
5293 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05305294 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
5295 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08005296 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305297 "%s: set channel to auto channel (0) for device mode =%s (%d)",
5298 __func__, hdd_device_modetoString(pAdapter->device_mode),
5299 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08005300 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05305301 else
5302 {
5303 if(VOS_STATUS_SUCCESS !=
5304 wlan_hdd_validate_operation_channel(pAdapter,channel))
5305 {
5306 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005307 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05305308 return -EINVAL;
5309 }
5310 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
5311 }
Viral Modi3a32cc52013-02-08 11:14:52 -08005312 }
5313 }
5314 else
5315 {
5316 hddLog(VOS_TRACE_LEVEL_FATAL,
5317 "%s: Invalid device mode failed to set valid channel", __func__);
5318 return -EINVAL;
5319 }
5320 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305321 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08005322}
5323
Jeff Johnson295189b2012-06-20 16:38:30 -07005324#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
5325static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
5326 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005327#else
5328static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
5329 struct cfg80211_beacon_data *params,
5330 const u8 *ssid, size_t ssid_len,
5331 enum nl80211_hidden_ssid hidden_ssid)
5332#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005333{
5334 tsap_Config_t *pConfig;
5335 beacon_data_t *pBeacon = NULL;
5336 struct ieee80211_mgmt *pMgmt_frame;
5337 v_U8_t *pIe=NULL;
5338 v_U16_t capab_info;
5339 eCsrAuthType RSNAuthType;
5340 eCsrEncryptionType RSNEncryptType;
5341 eCsrEncryptionType mcRSNEncryptType;
5342 int status = VOS_STATUS_SUCCESS;
5343 tpWLAN_SAPEventCB pSapEventCallback;
5344 hdd_hostapd_state_t *pHostapdState;
5345 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
5346 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05305347 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05305349 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07005350 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08005351 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Chet Lanctot40142442014-05-20 13:39:25 -07005352 v_BOOL_t MFPCapable = VOS_FALSE;
5353 v_BOOL_t MFPRequired = VOS_FALSE;
Abhishek Singhf0ac1752014-03-05 17:47:09 +05305354 eHddDot11Mode sapDot11Mode =
5355 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005356
5357 ENTER();
5358
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05305359 iniConfig = pHddCtx->cfg_ini;
5360
Jeff Johnson295189b2012-06-20 16:38:30 -07005361 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
5362
5363 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
5364
5365 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
5366
5367 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
5368
5369 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
5370
5371 //channel is already set in the set_channel Call back
5372 //pConfig->channel = pCommitConfig->channel;
5373
5374 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305375 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07005376 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
5377
5378 pConfig->dtim_period = pBeacon->dtim_period;
5379
Arif Hussain6d2a3322013-11-17 19:50:10 -08005380 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 pConfig->dtim_period);
5382
5383
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08005384 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07005385 {
5386 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07005387 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05305388 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
5389 {
5390 tANI_BOOLEAN restartNeeded;
5391 pConfig->ieee80211d = 1;
5392 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
5393 sme_setRegInfo(hHal, pConfig->countryCode);
5394 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
5395 }
5396 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07005398 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07005399 pConfig->ieee80211d = 1;
5400 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
5401 sme_setRegInfo(hHal, pConfig->countryCode);
5402 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07005404 else
5405 {
5406 pConfig->ieee80211d = 0;
5407 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05305408 /*
5409 * If auto channel is configured i.e. channel is 0,
5410 * so skip channel validation.
5411 */
5412 if( AUTO_CHANNEL_SELECT != pConfig->channel )
5413 {
5414 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
5415 {
5416 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005417 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05305418 return -EINVAL;
5419 }
5420 }
5421 else
5422 {
5423 if(1 != pHddCtx->is_dynamic_channel_range_set)
5424 {
5425 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
5426 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
5427 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
5428 }
5429 pHddCtx->is_dynamic_channel_range_set = 0;
5430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07005432 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 {
5434 pConfig->ieee80211d = 0;
5435 }
5436 pConfig->authType = eSAP_AUTO_SWITCH;
5437
5438 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305439
5440 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07005441 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
5442
5443 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
5444
5445 /*Set wps station to configured*/
5446 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
5447
5448 if(pIe)
5449 {
5450 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
5451 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005452 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 return -EINVAL;
5454 }
5455 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
5456 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07005457 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07005458 /* Check 15 bit of WPS IE as it contain information for wps state
5459 * WPS state
5460 */
5461 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
5462 {
5463 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
5464 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
5465 {
5466 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
5467 }
5468 }
5469 }
5470 else
5471 {
5472 pConfig->wps_state = SAP_WPS_DISABLED;
5473 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305474 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07005475
c_hpothufe599e92014-06-16 11:38:55 +05305476 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
5477 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
5478 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
5479 eCSR_ENCRYPT_TYPE_NONE;
5480
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 pConfig->RSNWPAReqIELength = 0;
5482 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305483 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 WLAN_EID_RSN);
5485 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305486 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 pConfig->RSNWPAReqIELength = pIe[1] + 2;
5488 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
5489 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305490 /* The actual processing may eventually be more extensive than
5491 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 * by the app.
5493 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305494 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
5496 &RSNEncryptType,
5497 &mcRSNEncryptType,
5498 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08005499 &MFPCapable,
5500 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07005501 pConfig->pRSNWPAReqIE[1]+2,
5502 pConfig->pRSNWPAReqIE );
5503
5504 if( VOS_STATUS_SUCCESS == status )
5505 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305506 /* Now copy over all the security attributes you have
5507 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07005508 * */
5509 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
5510 pConfig->mcRSNEncryptType = mcRSNEncryptType;
5511 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
5512 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305513 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005514 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
5516 }
5517 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305518
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
5520 pBeacon->tail, pBeacon->tail_len);
5521
5522 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
5523 {
5524 if (pConfig->pRSNWPAReqIE)
5525 {
5526 /*Mixed mode WPA/WPA2*/
5527 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
5528 pConfig->RSNWPAReqIELength += pIe[1] + 2;
5529 }
5530 else
5531 {
5532 pConfig->RSNWPAReqIELength = pIe[1] + 2;
5533 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
5534 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305535 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
5537 &RSNEncryptType,
5538 &mcRSNEncryptType,
5539 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08005540 &MFPCapable,
5541 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 pConfig->pRSNWPAReqIE[1]+2,
5543 pConfig->pRSNWPAReqIE );
5544
5545 if( VOS_STATUS_SUCCESS == status )
5546 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305547 /* Now copy over all the security attributes you have
5548 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 * */
5550 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
5551 pConfig->mcRSNEncryptType = mcRSNEncryptType;
5552 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
5553 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05305554 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08005555 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
5557 }
5558 }
5559 }
5560
Jeff Johnson4416a782013-03-25 14:17:50 -07005561 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
5562 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
5563 return -EINVAL;
5564 }
5565
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
5567
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005568#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07005569 if (params->ssid != NULL)
5570 {
5571 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
5572 pConfig->SSIDinfo.ssid.length = params->ssid_len;
5573 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
5574 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
5575 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005576#else
5577 if (ssid != NULL)
5578 {
5579 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
5580 pConfig->SSIDinfo.ssid.length = ssid_len;
5581 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
5582 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
5583 }
5584#endif
5585
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305586 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07005587 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305588
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 /* default value */
5590 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
5591 pConfig->num_accept_mac = 0;
5592 pConfig->num_deny_mac = 0;
5593
5594 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
5595 pBeacon->tail, pBeacon->tail_len);
5596
5597 /* pIe for black list is following form:
5598 type : 1 byte
5599 length : 1 byte
5600 OUI : 4 bytes
5601 acl type : 1 byte
5602 no of mac addr in black list: 1 byte
5603 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305604 */
5605 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07005606 {
5607 pConfig->SapMacaddr_acl = pIe[6];
5608 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08005609 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305611 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
5612 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
5614 for (i = 0; i < pConfig->num_deny_mac; i++)
5615 {
5616 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
5617 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 }
5620 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
5621 pBeacon->tail, pBeacon->tail_len);
5622
5623 /* pIe for white list is following form:
5624 type : 1 byte
5625 length : 1 byte
5626 OUI : 4 bytes
5627 acl type : 1 byte
5628 no of mac addr in white list: 1 byte
5629 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305630 */
5631 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 {
5633 pConfig->SapMacaddr_acl = pIe[6];
5634 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08005635 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305637 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
5638 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
5640 for (i = 0; i < pConfig->num_accept_mac; i++)
5641 {
5642 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
5643 acl_entry++;
5644 }
5645 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305646
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 wlan_hdd_set_sapHwmode(pHostapdAdapter);
5648
Jeff Johnsone7245742012-09-05 17:12:55 -07005649#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08005650 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05305651 * This is valid only if mode is set to 11n in hostapd, either AUTO or
5652 * 11ac in .ini and 11ac is supported by both host and firmware.
5653 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
5654 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08005655 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
5656 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Abhishek Singhf0ac1752014-03-05 17:47:09 +05305657 (( sapDot11Mode == eHDD_DOT11_MODE_AUTO ) ||
5658 ( sapDot11Mode == eHDD_DOT11_MODE_11ac ) ||
5659 ( sapDot11Mode == eHDD_DOT11_MODE_11ac_ONLY ) ) &&
5660 (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
5661 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07005662 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05305663 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07005664 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05305665 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07005666
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05305667 /* If ACS disable and selected channel <= 14
5668 * OR
5669 * ACS enabled and ACS operating band is choosen as 2.4
5670 * AND
5671 * VHT in 2.4G Disabled
5672 * THEN
5673 * Fallback to 11N mode
5674 */
5675 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
5676 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Siddharth Bhalf42f8592014-05-15 13:39:07 +05305677 operatingBand == RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05305678 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07005679 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05305680 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
5681 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07005682 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
5683 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005684 }
5685#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305686
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005687 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
5688 {
5689 sme_SelectCBMode(hHal,
5690 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
5691 pConfig->channel);
5692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 // ht_capab is not what the name conveys,this is used for protection bitmap
5694 pConfig->ht_capab =
5695 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
5696
5697 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
5698 {
5699 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
5700 return -EINVAL;
5701 }
5702
5703 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305704 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
5706 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305707 pConfig->obssProtEnabled =
5708 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07005709
Chet Lanctot8cecea22014-02-11 19:09:36 -08005710#ifdef WLAN_FEATURE_11W
5711 pConfig->mfpCapable = MFPCapable;
5712 pConfig->mfpRequired = MFPRequired;
5713 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
5714 pConfig->mfpCapable, pConfig->mfpRequired);
5715#endif
5716
Arif Hussain6d2a3322013-11-17 19:50:10 -08005717 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08005719 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
5720 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
5721 (int)pConfig->channel);
5722 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
5723 pConfig->SapHw_mode, pConfig->privacy,
5724 pConfig->authType);
5725 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
5726 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
5727 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
5728 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07005729
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305730 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 {
5732 //Bss already started. just return.
5733 //TODO Probably it should update some beacon params.
5734 hddLog( LOGE, "Bss Already started...Ignore the request");
5735 EXIT();
5736 return 0;
5737 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305738
Agarwal Ashish51325b52014-06-16 16:50:49 +05305739 if (vos_max_concurrent_connections_reached()) {
5740 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
5741 return -EINVAL;
5742 }
5743
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 pConfig->persona = pHostapdAdapter->device_mode;
5745
5746 pSapEventCallback = hdd_hostapd_SAPEventCB;
5747 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
5748 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
5749 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005750 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005751 return -EINVAL;
5752 }
5753
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305754 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07005755 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
5756
5757 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305758
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305760 {
5761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005762 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07005763 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 VOS_ASSERT(0);
5765 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305766
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05305768 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005769
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07005770#ifdef WLAN_FEATURE_P2P_DEBUG
5771 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
5772 {
5773 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
5774 {
5775 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
5776 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08005777 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07005778 }
5779 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
5780 {
5781 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
5782 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08005783 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07005784 }
5785 }
5786#endif
5787
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 pHostapdState->bCommit = TRUE;
5789 EXIT();
5790
5791 return 0;
5792}
5793
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005794#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305795static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
5796 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 struct beacon_parameters *params)
5798{
5799 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05305800 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305801 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005802
5803 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05305804
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305805 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5806 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
5807 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305808 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
5809 hdd_device_modetoString(pAdapter->device_mode),
5810 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005811
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305812 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5813 status = wlan_hdd_validate_context(pHddCtx);
5814
5815 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005816 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305817 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5818 "%s: HDD context is not valid", __func__);
5819 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005820 }
5821
Agarwal Ashish51325b52014-06-16 16:50:49 +05305822 if (vos_max_concurrent_connections_reached()) {
5823 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
5824 return -EINVAL;
5825 }
5826
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305827 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 )
5830 {
5831 beacon_data_t *old,*new;
5832
5833 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305834
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305836 {
5837 hddLog(VOS_TRACE_LEVEL_WARN,
5838 FL("already beacon info added to session(%d)"),
5839 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005842
5843 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
5844
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305845 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 {
5847 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005848 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 return -EINVAL;
5850 }
5851
5852 pAdapter->sessionCtx.ap.beacon = new;
5853
5854 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
5855 }
5856
5857 EXIT();
5858 return status;
5859}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305860
5861static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 struct net_device *dev,
5863 struct beacon_parameters *params)
5864{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305865 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05305866 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5867 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305868 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005869
5870 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05305871 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5872 TRACE_CODE_HDD_CFG80211_SET_BEACON,
5873 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
5874 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
5875 __func__, hdd_device_modetoString(pAdapter->device_mode),
5876 pAdapter->device_mode);
5877
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305878 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5879 status = wlan_hdd_validate_context(pHddCtx);
5880
5881 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005882 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305883 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5884 "%s: HDD context is not valid", __func__);
5885 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005886 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05305887
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305888 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305890 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 {
5892 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305893
Jeff Johnson295189b2012-06-20 16:38:30 -07005894 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305895
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305897 {
5898 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5899 FL("session(%d) old and new heads points to NULL"),
5900 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005901 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005903
5904 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
5905
5906 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305907 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08005908 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 return -EINVAL;
5910 }
5911
5912 pAdapter->sessionCtx.ap.beacon = new;
5913
5914 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
5915 }
5916
5917 EXIT();
5918 return status;
5919}
5920
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005921#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
5922
5923#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07005924static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
5925 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005926#else
5927static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
5928 struct net_device *dev)
5929#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005930{
5931 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07005932 hdd_context_t *pHddCtx = NULL;
5933 hdd_scaninfo_t *pScanInfo = NULL;
5934 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305935 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05305936 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07005937
5938 ENTER();
5939
5940 if (NULL == pAdapter)
5941 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05305942 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005943 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 return -ENODEV;
5945 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07005946
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305947 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5948 TRACE_CODE_HDD_CFG80211_STOP_AP,
5949 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305950 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5951 status = wlan_hdd_validate_context(pHddCtx);
5952
5953 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07005954 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305955 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5956 "%s: HDD context is not valid", __func__);
5957 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07005958 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07005959
5960 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
5961 if (NULL == staAdapter)
5962 {
5963 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
5964 if (NULL == staAdapter)
5965 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07005966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5967 "%s: HDD adapter context for STA/P2P-CLI is Null",
5968 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07005969 }
5970 }
5971
5972 pScanInfo = &pHddCtx->scan_info;
5973
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305974 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
5975 __func__, hdd_device_modetoString(pAdapter->device_mode),
5976 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005977
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05305978 ret = wlan_hdd_scan_abort(pAdapter);
5979
Girish Gowli4bf7a632014-06-12 13:42:11 +05305980 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07005981 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05305982 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5983 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305984
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05305985 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07005986 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05305987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5988 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08005989
Jeff Johnsone7245742012-09-05 17:12:55 -07005990 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05305991 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07005992 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05305993 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07005994 }
5995
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05305996 hdd_hostapd_stop(dev);
5997
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 )
6001 {
6002 beacon_data_t *old;
6003
6004 old = pAdapter->sessionCtx.ap.beacon;
6005
6006 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306007 {
6008 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6009 FL("session(%d) beacon data points to NULL"),
6010 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306012 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006013
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006015
6016 mutex_lock(&pHddCtx->sap_lock);
6017 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
6018 {
Jeff Johnson4416a782013-03-25 14:17:50 -07006019 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006020 {
6021 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
6022
6023 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
6024
6025 if (!VOS_IS_STATUS_SUCCESS(status))
6026 {
6027 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006028 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306030 }
6031 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006032 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05306033 /* BSS stopped, clear the active sessions for this device mode */
6034 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 }
6036 mutex_unlock(&pHddCtx->sap_lock);
6037
6038 if(status != VOS_STATUS_SUCCESS)
6039 {
6040 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006041 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 return -EINVAL;
6043 }
6044
Jeff Johnson4416a782013-03-25 14:17:50 -07006045 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
6047 ==eHAL_STATUS_FAILURE)
6048 {
6049 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006050 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 }
6052
Jeff Johnson4416a782013-03-25 14:17:50 -07006053 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6055 eANI_BOOLEAN_FALSE) )
6056 {
6057 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006058 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 }
6060
6061 // Reset WNI_CFG_PROBE_RSP Flags
6062 wlan_hdd_reset_prob_rspies(pAdapter);
6063
6064 pAdapter->sessionCtx.ap.beacon = NULL;
6065 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07006066#ifdef WLAN_FEATURE_P2P_DEBUG
6067 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
6068 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
6069 {
6070 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
6071 "GO got removed");
6072 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
6073 }
6074#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 }
6076 EXIT();
6077 return status;
6078}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006079
6080#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
6081
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306082static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
6083 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006084 struct cfg80211_ap_settings *params)
6085{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306086 hdd_adapter_t *pAdapter;
6087 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306088 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006089
6090 ENTER();
6091
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306092 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07006093 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306094 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306095 "%s: Device is Null", __func__);
6096 return -ENODEV;
6097 }
6098
6099 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6100 if (NULL == pAdapter)
6101 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306102 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306103 "%s: HDD adapter is Null", __func__);
6104 return -ENODEV;
6105 }
6106
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306107 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6108 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
6109 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306110 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
6111 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306113 "%s: HDD adapter magic is invalid", __func__);
6114 return -ENODEV;
6115 }
6116
6117 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306118 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306119
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306120 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306121 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306122 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6123 "%s: HDD context is not valid", __func__);
6124 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306125 }
6126
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306127 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
6128 __func__, hdd_device_modetoString(pAdapter->device_mode),
6129 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306130
6131 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006132 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006133 )
6134 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306135 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006136
6137 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306138
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006139 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306140 {
6141 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
6142 FL("already beacon info added to session(%d)"),
6143 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006144 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306145 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006146
6147 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
6148
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306149 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006150 {
6151 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05306152 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006153 return -EINVAL;
6154 }
6155 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08006156#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07006157 wlan_hdd_cfg80211_set_channel(wiphy, dev,
6158#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
6159 params->channel, params->channel_type);
6160#else
6161 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
6162#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08006163#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006164 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
6165 params->ssid_len, params->hidden_ssid);
6166 }
6167
6168 EXIT();
6169 return status;
6170}
6171
6172
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306173static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006174 struct net_device *dev,
6175 struct cfg80211_beacon_data *params)
6176{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306177 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306178 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306179 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006180
6181 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306182
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306183 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6184 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
6185 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08006186 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006187 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306188
6189 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6190 status = wlan_hdd_validate_context(pHddCtx);
6191
6192 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07006193 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306194 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6195 "%s: HDD context is not valid", __func__);
6196 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07006197 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006198
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306199 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006200 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306201 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006202 {
6203 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306204
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006205 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306206
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006207 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306208 {
6209 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6210 FL("session(%d) beacon data points to NULL"),
6211 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006212 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306213 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006214
6215 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
6216
6217 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306218 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006219 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006220 return -EINVAL;
6221 }
6222
6223 pAdapter->sessionCtx.ap.beacon = new;
6224
6225 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
6226 }
6227
6228 EXIT();
6229 return status;
6230}
6231
6232#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
6233
Jeff Johnson295189b2012-06-20 16:38:30 -07006234
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05306235static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 struct net_device *dev,
6237 struct bss_parameters *params)
6238{
6239 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6240
6241 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306242
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306243 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6244 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
6245 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306246 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6247 __func__, hdd_device_modetoString(pAdapter->device_mode),
6248 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006249
6250 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006251 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306252 )
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 {
6254 /* ap_isolate == -1 means that in change bss, upper layer doesn't
6255 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306256 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 {
6258 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 }
6261
6262 EXIT();
6263 return 0;
6264}
6265
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05306266static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
6267 struct net_device *dev,
6268 struct bss_parameters *params)
6269{
6270 int ret;
6271
6272 vos_ssr_protect(__func__);
6273 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
6274 vos_ssr_unprotect(__func__);
6275
6276 return ret;
6277}
Kiet Lam10841362013-11-01 11:36:50 +05306278/* FUNCTION: wlan_hdd_change_country_code_cd
6279* to wait for contry code completion
6280*/
6281void* wlan_hdd_change_country_code_cb(void *pAdapter)
6282{
6283 hdd_adapter_t *call_back_pAdapter = pAdapter;
6284 complete(&call_back_pAdapter->change_country_code);
6285 return NULL;
6286}
6287
Jeff Johnson295189b2012-06-20 16:38:30 -07006288/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05306289 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
6291 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05306292int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 struct net_device *ndev,
6294 enum nl80211_iftype type,
6295 u32 *flags,
6296 struct vif_params *params
6297 )
6298{
6299 struct wireless_dev *wdev;
6300 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08006301 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07006302 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 tCsrRoamProfile *pRoamProfile = NULL;
6304 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306305 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 eMib_dot11DesiredBssType connectedBssType;
6307 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306308 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006309
6310 ENTER();
6311
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306312 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08006313 {
6314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6315 "%s: Adapter context is null", __func__);
6316 return VOS_STATUS_E_FAILURE;
6317 }
6318
6319 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6320 if (!pHddCtx)
6321 {
6322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6323 "%s: HDD context is null", __func__);
6324 return VOS_STATUS_E_FAILURE;
6325 }
6326
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306327 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6328 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
6329 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306330 status = wlan_hdd_validate_context(pHddCtx);
6331
6332 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306334 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6335 "%s: HDD context is not valid", __func__);
6336 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 }
6338
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306339 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6340 __func__, hdd_device_modetoString(pAdapter->device_mode),
6341 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006342
Agarwal Ashish51325b52014-06-16 16:50:49 +05306343 if (vos_max_concurrent_connections_reached()) {
6344 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
6345 return -EINVAL;
6346 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306347 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 wdev = ndev->ieee80211_ptr;
6349
6350#ifdef WLAN_BTAMP_FEATURE
6351 if((NL80211_IFTYPE_P2P_CLIENT == type)||
6352 (NL80211_IFTYPE_ADHOC == type)||
6353 (NL80211_IFTYPE_AP == type)||
6354 (NL80211_IFTYPE_P2P_GO == type))
6355 {
6356 pHddCtx->isAmpAllowed = VOS_FALSE;
6357 // stop AMP traffic
6358 status = WLANBAP_StopAmp();
6359 if(VOS_STATUS_SUCCESS != status )
6360 {
6361 pHddCtx->isAmpAllowed = VOS_TRUE;
6362 hddLog(VOS_TRACE_LEVEL_FATAL,
6363 "%s: Failed to stop AMP", __func__);
6364 return -EINVAL;
6365 }
6366 }
6367#endif //WLAN_BTAMP_FEATURE
6368 /* Reset the current device mode bit mask*/
6369 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
6370
6371 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07006373 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 )
6375 {
6376 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08006377 if (!pWextState)
6378 {
6379 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6380 "%s: pWextState is null", __func__);
6381 return VOS_STATUS_E_FAILURE;
6382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 pRoamProfile = &pWextState->roamProfile;
6384 LastBSSType = pRoamProfile->BSSType;
6385
6386 switch (type)
6387 {
6388 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 hddLog(VOS_TRACE_LEVEL_INFO,
6391 "%s: setting interface Type to INFRASTRUCTURE", __func__);
6392 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07006393#ifdef WLAN_FEATURE_11AC
6394 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
6395 {
6396 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
6397 }
6398#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306399 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07006400 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08006402 //Check for sub-string p2p to confirm its a p2p interface
6403 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306404 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08006405 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
6406 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
6407 }
6408 else
6409 {
6410 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08006412 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05306413#ifdef FEATURE_WLAN_TDLS
6414 /* The open adapter for the p2p shall skip initializations in
6415 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
6416 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
6417 * tdls_init when the change_iface sets the device mode to
6418 * WLAN_HDD_P2P_CLIENT.
6419 */
6420
6421 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
6422 {
Agarwal Ashish4b87f922014-06-18 03:03:21 +05306423 if (0 != wlan_hdd_sta_tdls_init (pAdapter))
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05306424 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306425 hddLog(VOS_TRACE_LEVEL_ERROR,
6426 "%s: tdls initialization failed", __func__);
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05306427 return -EINVAL;
6428 }
6429 }
6430#endif
6431
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 break;
6433 case NL80211_IFTYPE_ADHOC:
6434 hddLog(VOS_TRACE_LEVEL_INFO,
6435 "%s: setting interface Type to ADHOC", __func__);
6436 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
6437 pRoamProfile->phyMode =
6438 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07006439 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 wdev->iftype = type;
6441 break;
6442
6443 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07006444 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 {
6446 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6447 "%s: setting interface Type to %s", __func__,
6448 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
6449
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08006450 //Cancel any remain on channel for GO mode
6451 if (NL80211_IFTYPE_P2P_GO == type)
6452 {
6453 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
6454 }
Mohit Khanna0f232092012-09-11 14:46:08 -07006455 if (NL80211_IFTYPE_AP == type)
6456 {
6457 /* As Loading WLAN Driver one interface being created for p2p device
6458 * address. This will take one HW STA and the max number of clients
6459 * that can connect to softAP will be reduced by one. so while changing
6460 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
6461 * interface as it is not required in SoftAP mode.
6462 */
6463
6464 // Get P2P Adapter
6465 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
6466
6467 if (pP2pAdapter)
6468 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306469 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07006470 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
6471 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
6472 }
6473 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05306474 //Disable IMPS & BMPS for SAP/GO
6475 if(VOS_STATUS_E_FAILURE ==
6476 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
6477 {
6478 //Fail to Exit BMPS
6479 VOS_ASSERT(0);
6480 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306481#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07006482
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306483 /* A Mutex Lock is introduced while changing the mode to
6484 * protect the concurrent access for the Adapters by TDLS
6485 * module.
6486 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05306487 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306488#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 //De-init the adapter.
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306490 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006491 hdd_deinit_adapter( pHddCtx, pAdapter );
6492 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
6494 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306495#ifdef FEATURE_WLAN_TDLS
6496 mutex_unlock(&pHddCtx->tdls_lock);
6497#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07006498 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
6499 (pConfig->apRandomBssidEnabled))
6500 {
6501 /* To meet Android requirements create a randomized
6502 MAC address of the form 02:1A:11:Fx:xx:xx */
6503 get_random_bytes(&ndev->dev_addr[3], 3);
6504 ndev->dev_addr[0] = 0x02;
6505 ndev->dev_addr[1] = 0x1A;
6506 ndev->dev_addr[2] = 0x11;
6507 ndev->dev_addr[3] |= 0xF0;
6508 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
6509 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08006510 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
6511 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07006512 }
6513
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 hdd_set_ap_ops( pAdapter->dev );
6515
Kiet Lam10841362013-11-01 11:36:50 +05306516 /* This is for only SAP mode where users can
6517 * control country through ini.
6518 * P2P GO follows station country code
6519 * acquired during the STA scanning. */
6520 if((NL80211_IFTYPE_AP == type) &&
6521 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
6522 {
6523 int status = 0;
6524 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
6525 "%s: setting country code from INI ", __func__);
6526 init_completion(&pAdapter->change_country_code);
6527 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
6528 (void *)(tSmeChangeCountryCallback)
6529 wlan_hdd_change_country_code_cb,
6530 pConfig->apCntryCode, pAdapter,
6531 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05306532 eSIR_FALSE,
6533 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05306534 if (eHAL_STATUS_SUCCESS == status)
6535 {
6536 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306537 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05306538 &pAdapter->change_country_code,
6539 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306540 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05306541 {
6542 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306543 FL("SME Timed out while setting country code %ld"),
6544 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08006545
6546 if (pHddCtx->isLogpInProgress)
6547 {
6548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6549 "%s: LOGP in Progress. Ignore!!!", __func__);
6550 return -EAGAIN;
6551 }
Kiet Lam10841362013-11-01 11:36:50 +05306552 }
6553 }
6554 else
6555 {
6556 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006557 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05306558 return -EINVAL;
6559 }
6560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 status = hdd_init_ap_mode(pAdapter);
6562 if(status != VOS_STATUS_SUCCESS)
6563 {
6564 hddLog(VOS_TRACE_LEVEL_FATAL,
6565 "%s: Error initializing the ap mode", __func__);
6566 return -EINVAL;
6567 }
6568 hdd_set_conparam(1);
6569
Jeff Johnson295189b2012-06-20 16:38:30 -07006570 /*interface type changed update in wiphy structure*/
6571 if(wdev)
6572 {
6573 wdev->iftype = type;
6574 pHddCtx->change_iface = type;
6575 }
6576 else
6577 {
6578 hddLog(VOS_TRACE_LEVEL_ERROR,
6579 "%s: ERROR !!!! Wireless dev is NULL", __func__);
6580 return -EINVAL;
6581 }
6582 goto done;
6583 }
6584
6585 default:
6586 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
6587 __func__);
6588 return -EOPNOTSUPP;
6589 }
6590 }
6591 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 )
6594 {
6595 switch(type)
6596 {
6597 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306600#ifdef FEATURE_WLAN_TDLS
6601
6602 /* A Mutex Lock is introduced while changing the mode to
6603 * protect the concurrent access for the Adapters by TDLS
6604 * module.
6605 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05306606 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306607#endif
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05306608 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006609 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006610 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08006611 //Check for sub-string p2p to confirm its a p2p interface
6612 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08006613 {
6614 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
6615 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
6616 }
6617 else
6618 {
6619 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08006621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006622 hdd_set_conparam(0);
6623 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
6625 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306626#ifdef FEATURE_WLAN_TDLS
6627 mutex_unlock(&pHddCtx->tdls_lock);
6628#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05306629 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 if( VOS_STATUS_SUCCESS != status )
6631 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07006632 /* In case of JB, for P2P-GO, only change interface will be called,
6633 * This is the right place to enable back bmps_imps()
6634 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306635 if (pHddCtx->hdd_wlan_suspended)
6636 {
6637 hdd_set_pwrparams(pHddCtx);
6638 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006639 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 goto done;
6641 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07006644 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
6645 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 goto done;
6647 default:
6648 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
6649 __func__);
6650 return -EOPNOTSUPP;
6651
6652 }
6653
6654 }
6655 else
6656 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306657 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
6658 __func__, hdd_device_modetoString(pAdapter->device_mode),
6659 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 return -EOPNOTSUPP;
6661 }
6662
6663
6664 if(pRoamProfile)
6665 {
6666 if ( LastBSSType != pRoamProfile->BSSType )
6667 {
6668 /*interface type changed update in wiphy structure*/
6669 wdev->iftype = type;
6670
6671 /*the BSS mode changed, We need to issue disconnect
6672 if connected or in IBSS disconnect state*/
6673 if ( hdd_connGetConnectedBssType(
6674 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
6675 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
6676 {
6677 /*need to issue a disconnect to CSR.*/
6678 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6679 if( eHAL_STATUS_SUCCESS ==
6680 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6681 pAdapter->sessionId,
6682 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
6683 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306684 ret = wait_for_completion_interruptible_timeout(
6685 &pAdapter->disconnect_comp_var,
6686 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6687 if (ret <= 0)
6688 {
6689 hddLog(VOS_TRACE_LEVEL_ERROR,
6690 FL("wait on disconnect_comp_var failed %ld"), ret);
6691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006692 }
6693 }
6694 }
6695 }
6696
6697done:
6698 /*set bitmask based on updated value*/
6699 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07006700
6701 /* Only STA mode support TM now
6702 * all other mode, TM feature should be disabled */
6703 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
6704 (~VOS_STA & pHddCtx->concurrency_mode) )
6705 {
6706 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
6707 }
6708
Jeff Johnson295189b2012-06-20 16:38:30 -07006709#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306710 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05306711 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07006712 {
6713 //we are ok to do AMP
6714 pHddCtx->isAmpAllowed = VOS_TRUE;
6715 }
6716#endif //WLAN_BTAMP_FEATURE
6717 EXIT();
6718 return 0;
6719}
6720
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05306721/*
6722 * FUNCTION: wlan_hdd_cfg80211_change_iface
6723 * wrapper function to protect the actual implementation from SSR.
6724 */
6725int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
6726 struct net_device *ndev,
6727 enum nl80211_iftype type,
6728 u32 *flags,
6729 struct vif_params *params
6730 )
6731{
6732 int ret;
6733
6734 vos_ssr_protect(__func__);
6735 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
6736 vos_ssr_unprotect(__func__);
6737
6738 return ret;
6739}
6740
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006741#ifdef FEATURE_WLAN_TDLS
6742static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
6743 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
6744{
6745 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6746 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6747 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006748 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306749 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05306750 tANI_U16 numCurrTdlsPeers;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006751
6752 ENTER();
6753
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05306754 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006755 {
6756 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6757 "Invalid arguments");
6758 return -EINVAL;
6759 }
Hoonki Lee27511902013-03-14 18:19:06 -07006760
6761 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
6762 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
6763 {
6764 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
6765 "%s: TDLS mode is disabled OR not enabled in FW."
6766 MAC_ADDRESS_STR " Request declined.",
6767 __func__, MAC_ADDR_ARRAY(mac));
6768 return -ENOTSUPP;
6769 }
6770
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006771 if (pHddCtx->isLogpInProgress)
6772 {
6773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6774 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07006775 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006776 return -EBUSY;
6777 }
6778
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05306779 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006780
6781 if ( NULL == pTdlsPeer ) {
6782 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
6783 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
6784 __func__, MAC_ADDR_ARRAY(mac), update);
6785 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07006786 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006787
6788 /* in add station, we accept existing valid staId if there is */
6789 if ((0 == update) &&
6790 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
6791 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006792 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006793 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006794 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006795 " link_status %d. staId %d. add station ignored.",
6796 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
6797 return 0;
6798 }
6799 /* in change station, we accept only when staId is valid */
6800 if ((1 == update) &&
6801 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
6802 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
6803 {
6804 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
6805 "%s: " MAC_ADDRESS_STR
6806 " link status %d. staId %d. change station %s.",
6807 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
6808 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
6809 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006810 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07006811
6812 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306813 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006814 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006815 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6816 "%s: " MAC_ADDRESS_STR
6817 " TDLS setup is ongoing. Request declined.",
6818 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07006819 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006820 }
6821
6822 /* first to check if we reached to maximum supported TDLS peer.
6823 TODO: for now, return -EPERM looks working fine,
6824 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05306825 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
6826 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006827 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006828 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6829 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05306830 " TDLS Max peer already connected. Request declined."
6831 " Num of peers (%d), Max allowed (%d).",
6832 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
6833 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07006834 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006835 }
6836 else
6837 {
6838 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05306839 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006840 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006841 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006842 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6843 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
6844 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006845 return -EPERM;
6846 }
6847 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006848 if (0 == update)
6849 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006850
Jeff Johnsond75fe012013-04-06 10:53:06 -07006851 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05306852 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006853 {
6854 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
6855 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07006856 if(StaParams->htcap_present)
6857 {
6858 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
6859 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
6860 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
6861 "ht_capa->extended_capabilities: %0x",
6862 StaParams->HTCap.extendedHtCapInfo);
6863 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006864 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
6865 "params->capability: %0x",StaParams->capability);
6866 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07006867 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07006868 if(StaParams->vhtcap_present)
6869 {
6870 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
6871 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
6872 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
6873 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
6874 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006875 {
6876 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07006877 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006878 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
6879 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
6880 "[%d]: %x ", i, StaParams->supported_rates[i]);
6881 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07006882 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05306883 else if ((1 == update) && (NULL == StaParams))
6884 {
6885 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6886 "%s : update is true, but staParams is NULL. Error!", __func__);
6887 return -EPERM;
6888 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006889
6890 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
6891
6892 if (!update)
6893 {
6894 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
6895 pAdapter->sessionId, mac);
6896 }
6897 else
6898 {
6899 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
6900 pAdapter->sessionId, mac, StaParams);
6901 }
6902
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306903 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006904 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
6905
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306906 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006907 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306909 "%s: timeout waiting for tdls add station indication %ld",
6910 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07006911 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006912 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306913
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006914 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
6915 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006916 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006917 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07006918 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006919 }
6920
6921 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07006922
6923error:
6924 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
6925 return -EPERM;
6926
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006927}
6928#endif
6929
Jeff Johnson295189b2012-06-20 16:38:30 -07006930static int wlan_hdd_change_station(struct wiphy *wiphy,
6931 struct net_device *dev,
6932 u8 *mac,
6933 struct station_parameters *params)
6934{
6935 VOS_STATUS status = VOS_STATUS_SUCCESS;
6936 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05306937 hdd_context_t *pHddCtx;
6938 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07006940#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006941 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006942 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05306943 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07006944#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07006945 ENTER();
6946
Gopichand Nakkala29149562013-05-10 21:43:41 +05306947 if ((NULL == pAdapter))
6948 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05306950 "invalid adapter ");
6951 return -EINVAL;
6952 }
6953
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306954 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6955 TRACE_CODE_HDD_CHANGE_STATION,
6956 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05306957 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6958 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6959
6960 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
6961 {
6962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
6963 "invalid HDD state or HDD station context");
6964 return -EINVAL;
6965 }
6966
6967 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006968 {
6969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6970 "%s:LOGP in Progress. Ignore!!!", __func__);
6971 return -EAGAIN;
6972 }
6973
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
6975
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006976 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
6977 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07006978 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006979 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306981 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07006982 WLANTL_STA_AUTHENTICATED);
6983
Gopichand Nakkala29149562013-05-10 21:43:41 +05306984 if (status != VOS_STATUS_SUCCESS)
6985 {
6986 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
6987 "%s: Not able to change TL state to AUTHENTICATED", __func__);
6988 return -EINVAL;
6989 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 }
6991 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07006992 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
6993 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05306994#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07006995 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
6996 StaParams.capability = params->capability;
6997 StaParams.uapsd_queues = params->uapsd_queues;
6998 StaParams.max_sp = params->max_sp;
6999
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307000 /* Convert (first channel , number of channels) tuple to
7001 * the total list of channels. This goes with the assumption
7002 * that if the first channel is < 14, then the next channels
7003 * are an incremental of 1 else an incremental of 4 till the number
7004 * of channels.
7005 */
7006 if (0 != params->supported_channels_len) {
7007 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
7008 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
7009 {
7010 int wifi_chan_index;
7011 StaParams.supported_channels[j] = params->supported_channels[i];
7012 wifi_chan_index =
7013 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
7014 no_of_channels = params->supported_channels[i+1];
7015 for(k=1; k <= no_of_channels; k++)
7016 {
7017 StaParams.supported_channels[j+1] =
7018 StaParams.supported_channels[j] + wifi_chan_index;
7019 j+=1;
7020 }
7021 }
7022 StaParams.supported_channels_len = j;
7023 }
7024 vos_mem_copy(StaParams.supported_oper_classes,
7025 params->supported_oper_classes,
7026 params->supported_oper_classes_len);
7027 StaParams.supported_oper_classes_len =
7028 params->supported_oper_classes_len;
7029
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007030 if (0 != params->ext_capab_len)
7031 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
7032 sizeof(StaParams.extn_capability));
7033
7034 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07007035 {
7036 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007037 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07007038 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007039
7040 StaParams.supported_rates_len = params->supported_rates_len;
7041
7042 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
7043 * The supported_rates array , for all the structures propogating till Add Sta
7044 * to the firmware has to be modified , if the supplicant (ieee80211) is
7045 * modified to send more rates.
7046 */
7047
7048 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
7049 */
7050 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
7051 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
7052
7053 if (0 != StaParams.supported_rates_len) {
7054 int i = 0;
7055 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
7056 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007057 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007058 "Supported Rates with Length %d", StaParams.supported_rates_len);
7059 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007060 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007061 "[%d]: %0x", i, StaParams.supported_rates[i]);
7062 }
7063
7064 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07007065 {
7066 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007067 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07007068 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007069
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007070 if (0 != params->ext_capab_len ) {
7071 /*Define A Macro : TODO Sunil*/
7072 if ((1<<4) & StaParams.extn_capability[3]) {
7073 isBufSta = 1;
7074 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307075 /* TDLS Channel Switching Support */
7076 if ((1<<6) & StaParams.extn_capability[3]) {
7077 isOffChannelSupported = 1;
7078 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007079 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05307080 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
7081 &StaParams, isBufSta,
7082 isOffChannelSupported);
7083
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307084 if (VOS_STATUS_SUCCESS != status) {
7085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7086 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
7087 return -EINVAL;
7088 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007089 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
7090
7091 if (VOS_STATUS_SUCCESS != status) {
7092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7093 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
7094 return -EINVAL;
7095 }
7096 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07007097#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05307098 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007099 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007100 return status;
7101}
7102
7103/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307104 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07007105 * This function is used to initialize the key information
7106 */
7107#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307108static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007109 struct net_device *ndev,
7110 u8 key_index, bool pairwise,
7111 const u8 *mac_addr,
7112 struct key_params *params
7113 )
7114#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307115static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 struct net_device *ndev,
7117 u8 key_index, const u8 *mac_addr,
7118 struct key_params *params
7119 )
7120#endif
7121{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007122 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07007123 tCsrRoamSetKey setKey;
7124 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307125 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007126 v_U32_t roamId= 0xFF;
7127 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 hdd_hostapd_state_t *pHostapdState;
7129 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007130 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307131 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007132
7133 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307134
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307135 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7136 TRACE_CODE_HDD_CFG80211_ADD_KEY,
7137 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307138 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7139 status = wlan_hdd_validate_context(pHddCtx);
7140
7141 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007142 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307143 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7144 "%s: HDD context is not valid", __func__);
7145 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007146 }
7147
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307148 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7149 __func__, hdd_device_modetoString(pAdapter->device_mode),
7150 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007151
7152 if (CSR_MAX_NUM_KEY <= key_index)
7153 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007154 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007155 key_index);
7156
7157 return -EINVAL;
7158 }
7159
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007160 if (CSR_MAX_KEY_LEN < params->key_len)
7161 {
7162 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
7163 params->key_len);
7164
7165 return -EINVAL;
7166 }
7167
7168 hddLog(VOS_TRACE_LEVEL_INFO,
7169 "%s: called with key index = %d & key length %d",
7170 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07007171
7172 /*extract key idx, key len and key*/
7173 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
7174 setKey.keyId = key_index;
7175 setKey.keyLength = params->key_len;
7176 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
7177
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007178 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 {
7180 case WLAN_CIPHER_SUITE_WEP40:
7181 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
7182 break;
7183
7184 case WLAN_CIPHER_SUITE_WEP104:
7185 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
7186 break;
7187
7188 case WLAN_CIPHER_SUITE_TKIP:
7189 {
7190 u8 *pKey = &setKey.Key[0];
7191 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
7192
7193 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
7194
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007195 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07007196
7197 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007198 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07007199 |--------------|----------|----------|
7200 <---16bytes---><--8bytes--><--8bytes-->
7201
7202 */
7203 /*Sme expects the 32 bytes key to be in the below order
7204
7205 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007206 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 |--------------|----------|----------|
7208 <---16bytes---><--8bytes--><--8bytes-->
7209 */
7210 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007211 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07007212
7213 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007214 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07007215
7216 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007217 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07007218
7219
7220 break;
7221 }
7222
7223 case WLAN_CIPHER_SUITE_CCMP:
7224 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
7225 break;
7226
7227#ifdef FEATURE_WLAN_WAPI
7228 case WLAN_CIPHER_SUITE_SMS4:
7229 {
7230 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
7231 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
7232 params->key, params->key_len);
7233 return 0;
7234 }
7235#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007236
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007237#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 case WLAN_CIPHER_SUITE_KRK:
7239 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
7240 break;
7241#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07007242
7243#ifdef WLAN_FEATURE_11W
7244 case WLAN_CIPHER_SUITE_AES_CMAC:
7245 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07007246 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07007247#endif
7248
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007250 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07007251 __func__, params->cipher);
7252 return -EOPNOTSUPP;
7253 }
7254
7255 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
7256 __func__, setKey.encType);
7257
Shailender Karmuchi642e9812013-05-30 14:34:49 -07007258 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07007259#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7260 (!pairwise)
7261#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007262 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07007263#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07007264 )
7265 {
7266 /* set group key*/
7267 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7268 "%s- %d: setting Broadcast key",
7269 __func__, __LINE__);
7270 setKey.keyDirection = eSIR_RX_ONLY;
7271 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
7272 }
7273 else
7274 {
7275 /* set pairwise key*/
7276 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7277 "%s- %d: setting pairwise key",
7278 __func__, __LINE__);
7279 setKey.keyDirection = eSIR_TX_RX;
7280 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
7281 }
7282 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
7283 {
7284 setKey.keyDirection = eSIR_TX_RX;
7285 /*Set the group key*/
7286 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
7287 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007288
Shailender Karmuchi642e9812013-05-30 14:34:49 -07007289 if ( 0 != status )
7290 {
7291 hddLog(VOS_TRACE_LEVEL_ERROR,
7292 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
7293 return -EINVAL;
7294 }
7295 /*Save the keys here and call sme_RoamSetKey for setting
7296 the PTK after peer joins the IBSS network*/
7297 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
7298 &setKey, sizeof(tCsrRoamSetKey));
7299 return status;
7300 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05307301 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
7302 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
7303 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007304 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007305 if( pHostapdState->bssState == BSS_START )
7306 {
c_hpothu7c55da62014-01-23 18:34:02 +05307307 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7308 vos_status = wlan_hdd_check_ula_done(pAdapter);
7309
7310 if ( vos_status != VOS_STATUS_SUCCESS )
7311 {
7312 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7313 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
7314 __LINE__, vos_status );
7315
7316 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
7317
7318 return -EINVAL;
7319 }
7320
Jeff Johnson295189b2012-06-20 16:38:30 -07007321 status = WLANSAP_SetKeySta( pVosContext, &setKey);
7322
7323 if ( status != eHAL_STATUS_SUCCESS )
7324 {
7325 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7326 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
7327 __LINE__, status );
7328 }
7329 }
7330
7331 /* Saving WEP keys */
7332 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
7333 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
7334 {
7335 //Save the wep key in ap context. Issue setkey after the BSS is started.
7336 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7337 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
7338 }
7339 else
7340 {
7341 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007342 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007343 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
7344 }
7345 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007346 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
7347 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 {
7349 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7350 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7351
Gopichand Nakkala3d295922013-05-07 16:19:14 +05307352#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7353 if (!pairwise)
7354#else
7355 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
7356#endif
7357 {
7358 /* set group key*/
7359 if (pHddStaCtx->roam_info.deferKeyComplete)
7360 {
7361 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7362 "%s- %d: Perform Set key Complete",
7363 __func__, __LINE__);
7364 hdd_PerformRoamSetKeyComplete(pAdapter);
7365 }
7366 }
7367
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
7369
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08007370 pWextState->roamProfile.Keys.defaultIndex = key_index;
7371
7372
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07007373 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07007374 params->key, params->key_len);
7375
Gopichand Nakkala3d295922013-05-07 16:19:14 +05307376
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
7378
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307379 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07007380 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307381 __func__, setKey.peerMac[0], setKey.peerMac[1],
7382 setKey.peerMac[2], setKey.peerMac[3],
7383 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 setKey.keyDirection);
7385
7386 vos_status = wlan_hdd_check_ula_done(pAdapter);
7387
7388 if ( vos_status != VOS_STATUS_SUCCESS )
7389 {
7390 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7391 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
7392 __LINE__, vos_status );
7393
7394 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
7395
7396 return -EINVAL;
7397
7398 }
7399
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007400#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05307401 /* The supplicant may attempt to set the PTK once pre-authentication
7402 is done. Save the key in the UMAC and include it in the ADD BSS
7403 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007404 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05307405 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007406 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05307407 hddLog(VOS_TRACE_LEVEL_INFO_MED,
7408 "%s: Update PreAuth Key success", __func__);
7409 return 0;
7410 }
7411 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
7412 {
7413 hddLog(VOS_TRACE_LEVEL_ERROR,
7414 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05307415 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007416 }
7417#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07007418
7419 /* issue set key request to SME*/
7420 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
7421 pAdapter->sessionId, &setKey, &roamId );
7422
7423 if ( 0 != status )
7424 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307425 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
7427 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
7428 return -EINVAL;
7429 }
7430
7431
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307432 /* in case of IBSS as there was no information available about WEP keys during
7433 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07007434 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307435 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
7436 !( ( IW_AUTH_KEY_MGMT_802_1X
7437 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
7439 )
7440 &&
7441 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
7442 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
7443 )
7444 )
7445 {
7446 setKey.keyDirection = eSIR_RX_ONLY;
7447 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
7448
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307449 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07007450 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307451 __func__, setKey.peerMac[0], setKey.peerMac[1],
7452 setKey.peerMac[2], setKey.peerMac[3],
7453 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07007454 setKey.keyDirection);
7455
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307456 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07007457 pAdapter->sessionId, &setKey, &roamId );
7458
7459 if ( 0 != status )
7460 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307461 hddLog(VOS_TRACE_LEVEL_ERROR,
7462 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 __func__, status);
7464 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
7465 return -EINVAL;
7466 }
7467 }
7468 }
7469
7470 return 0;
7471}
7472
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307473#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7474static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
7475 struct net_device *ndev,
7476 u8 key_index, bool pairwise,
7477 const u8 *mac_addr,
7478 struct key_params *params
7479 )
7480#else
7481static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
7482 struct net_device *ndev,
7483 u8 key_index, const u8 *mac_addr,
7484 struct key_params *params
7485 )
7486#endif
7487{
7488 int ret;
7489 vos_ssr_protect(__func__);
7490#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7491 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
7492 mac_addr, params);
7493#else
7494 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
7495 params);
7496#endif
7497 vos_ssr_unprotect(__func__);
7498
7499 return ret;
7500}
7501
Jeff Johnson295189b2012-06-20 16:38:30 -07007502/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307503 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07007504 * This function is used to get the key information
7505 */
7506#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307507static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307508 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307510 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07007511 const u8 *mac_addr, void *cookie,
7512 void (*callback)(void *cookie, struct key_params*)
7513 )
7514#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307515static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307516 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007517 struct net_device *ndev,
7518 u8 key_index, const u8 *mac_addr, void *cookie,
7519 void (*callback)(void *cookie, struct key_params*)
7520 )
7521#endif
7522{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307523 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307524 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7525 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007526 struct key_params params;
7527
7528 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307529
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307530 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7531 __func__, hdd_device_modetoString(pAdapter->device_mode),
7532 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307533
Jeff Johnson295189b2012-06-20 16:38:30 -07007534 memset(&params, 0, sizeof(params));
7535
7536 if (CSR_MAX_NUM_KEY <= key_index)
7537 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307538 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07007539 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007541
7542 switch(pRoamProfile->EncryptionType.encryptionType[0])
7543 {
7544 case eCSR_ENCRYPT_TYPE_NONE:
7545 params.cipher = IW_AUTH_CIPHER_NONE;
7546 break;
7547
7548 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
7549 case eCSR_ENCRYPT_TYPE_WEP40:
7550 params.cipher = WLAN_CIPHER_SUITE_WEP40;
7551 break;
7552
7553 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
7554 case eCSR_ENCRYPT_TYPE_WEP104:
7555 params.cipher = WLAN_CIPHER_SUITE_WEP104;
7556 break;
7557
7558 case eCSR_ENCRYPT_TYPE_TKIP:
7559 params.cipher = WLAN_CIPHER_SUITE_TKIP;
7560 break;
7561
7562 case eCSR_ENCRYPT_TYPE_AES:
7563 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
7564 break;
7565
7566 default:
7567 params.cipher = IW_AUTH_CIPHER_NONE;
7568 break;
7569 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307570
c_hpothuaaf19692014-05-17 17:01:48 +05307571 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7572 TRACE_CODE_HDD_CFG80211_GET_KEY,
7573 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307574
Jeff Johnson295189b2012-06-20 16:38:30 -07007575 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
7576 params.seq_len = 0;
7577 params.seq = NULL;
7578 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
7579 callback(cookie, &params);
7580 return 0;
7581}
7582
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307583#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7584static int wlan_hdd_cfg80211_get_key(
7585 struct wiphy *wiphy,
7586 struct net_device *ndev,
7587 u8 key_index, bool pairwise,
7588 const u8 *mac_addr, void *cookie,
7589 void (*callback)(void *cookie, struct key_params*)
7590 )
7591#else
7592static int wlan_hdd_cfg80211_get_key(
7593 struct wiphy *wiphy,
7594 struct net_device *ndev,
7595 u8 key_index, const u8 *mac_addr, void *cookie,
7596 void (*callback)(void *cookie, struct key_params*)
7597 )
7598#endif
7599{
7600 int ret;
7601
7602 vos_ssr_protect(__func__);
7603#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7604 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
7605 mac_addr, cookie, callback);
7606#else
7607 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
7608 callback);
7609#endif
7610 vos_ssr_unprotect(__func__);
7611
7612 return ret;
7613}
7614
Jeff Johnson295189b2012-06-20 16:38:30 -07007615/*
7616 * FUNCTION: wlan_hdd_cfg80211_del_key
7617 * This function is used to delete the key information
7618 */
7619#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307620static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007621 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307622 u8 key_index,
7623 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07007624 const u8 *mac_addr
7625 )
7626#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307627static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 struct net_device *ndev,
7629 u8 key_index,
7630 const u8 *mac_addr
7631 )
7632#endif
7633{
7634 int status = 0;
7635
7636 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307637 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 //it is observed that this is invalidating peer
7639 //key index whenever re-key is done. This is affecting data link.
7640 //It should be ok to ignore del_key.
7641#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307642 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
7643 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
7645 tCsrRoamSetKey setKey;
7646 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307647
Jeff Johnson295189b2012-06-20 16:38:30 -07007648 ENTER();
7649
7650 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
7651 __func__,pAdapter->device_mode);
7652
7653 if (CSR_MAX_NUM_KEY <= key_index)
7654 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307655 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007656 key_index);
7657
7658 return -EINVAL;
7659 }
7660
7661 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
7662 setKey.keyId = key_index;
7663
7664 if (mac_addr)
7665 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
7666 else
7667 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
7668
7669 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
7670
7671 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307673 )
7674 {
7675
7676 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07007677 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7678 if( pHostapdState->bssState == BSS_START)
7679 {
7680 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307681
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 if ( status != eHAL_STATUS_SUCCESS )
7683 {
7684 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7685 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
7686 __LINE__, status );
7687 }
7688 }
7689 }
7690 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307691 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07007692 )
7693 {
7694 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7695
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307696 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
7697
7698 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07007699 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307700 __func__, setKey.peerMac[0], setKey.peerMac[1],
7701 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07007702 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307703 if(pAdapter->sessionCtx.station.conn_info.connState ==
7704 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07007705 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307706 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07007707 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307708
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 if ( 0 != status )
7710 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307711 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007712 "%s: sme_RoamSetKey failure, returned %d",
7713 __func__, status);
7714 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
7715 return -EINVAL;
7716 }
7717 }
7718 }
7719#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07007720 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007721 return status;
7722}
7723
7724/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307725 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07007726 * This function is used to set the default tx key index
7727 */
7728#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307729static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007730 struct net_device *ndev,
7731 u8 key_index,
7732 bool unicast, bool multicast)
7733#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307734static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007735 struct net_device *ndev,
7736 u8 key_index)
7737#endif
7738{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307739 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307740 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05307741 hdd_wext_state_t *pWextState;
7742 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307743 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007744
7745 ENTER();
7746
Gopichand Nakkala29149562013-05-10 21:43:41 +05307747 if ((NULL == pAdapter))
7748 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05307750 "invalid adapter");
7751 return -EINVAL;
7752 }
7753
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307754 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7755 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
7756 pAdapter->sessionId, key_index));
7757
Gopichand Nakkala29149562013-05-10 21:43:41 +05307758 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7759 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7760
7761 if ((NULL == pWextState) || (NULL == pHddStaCtx))
7762 {
7763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7764 "invalid Wext state or HDD context");
7765 return -EINVAL;
7766 }
7767
Arif Hussain6d2a3322013-11-17 19:50:10 -08007768 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007769 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307770
Jeff Johnson295189b2012-06-20 16:38:30 -07007771 if (CSR_MAX_NUM_KEY <= key_index)
7772 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307773 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007774 key_index);
7775
7776 return -EINVAL;
7777 }
7778
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307779 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7780 status = wlan_hdd_validate_context(pHddCtx);
7781
7782 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007783 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307784 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7785 "%s: HDD context is not valid", __func__);
7786 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007787 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307788
Jeff Johnson295189b2012-06-20 16:38:30 -07007789 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07007790 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307791 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007792 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05307793 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08007794 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307795 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08007796 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307798 {
7799 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07007800 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307801
Jeff Johnson295189b2012-06-20 16:38:30 -07007802 tCsrRoamSetKey setKey;
7803 v_U32_t roamId= 0xFF;
7804 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307805
7806 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007807 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307808
Jeff Johnson295189b2012-06-20 16:38:30 -07007809 Keys->defaultIndex = (u8)key_index;
7810 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
7811 setKey.keyId = key_index;
7812 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307813
7814 vos_mem_copy(&setKey.Key[0],
7815 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07007816 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307817
Gopichand Nakkala29149562013-05-10 21:43:41 +05307818 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307819
7820 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07007821 &pHddStaCtx->conn_info.bssId[0],
7822 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307823
Gopichand Nakkala29149562013-05-10 21:43:41 +05307824 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
7825 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
7826 eCSR_ENCRYPT_TYPE_WEP104)
7827 {
7828 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
7829 even though ap is configured for WEP-40 encryption. In this canse the key length
7830 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
7831 type(104) and switching encryption type to 40*/
7832 pWextState->roamProfile.EncryptionType.encryptionType[0] =
7833 eCSR_ENCRYPT_TYPE_WEP40;
7834 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
7835 eCSR_ENCRYPT_TYPE_WEP40;
7836 }
7837
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307838 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07007839 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307840
Jeff Johnson295189b2012-06-20 16:38:30 -07007841 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307842 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07007843 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307844
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 if ( 0 != status )
7846 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307847 hddLog(VOS_TRACE_LEVEL_ERROR,
7848 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 status);
7850 return -EINVAL;
7851 }
7852 }
7853 }
7854
7855 /* In SoftAp mode setting key direction for default mode */
7856 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
7857 {
7858 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
7859 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
7860 (eCSR_ENCRYPT_TYPE_AES !=
7861 pWextState->roamProfile.EncryptionType.encryptionType[0])
7862 )
7863 {
7864 /* Saving key direction for default key index to TX default */
7865 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
7866 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
7867 }
7868 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307869
Jeff Johnson295189b2012-06-20 16:38:30 -07007870 return status;
7871}
7872
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05307873#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7874static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
7875 struct net_device *ndev,
7876 u8 key_index,
7877 bool unicast, bool multicast)
7878#else
7879static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
7880 struct net_device *ndev,
7881 u8 key_index)
7882#endif
7883{
7884 int ret;
7885 vos_ssr_protect(__func__);
7886#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7887 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
7888 multicast);
7889#else
7890 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
7891#endif
7892 vos_ssr_unprotect(__func__);
7893
7894 return ret;
7895}
7896
Jeff Johnson295189b2012-06-20 16:38:30 -07007897/*
7898 * FUNCTION: wlan_hdd_cfg80211_inform_bss
7899 * This function is used to inform the BSS details to nl80211 interface.
7900 */
7901static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
7902 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
7903{
7904 struct net_device *dev = pAdapter->dev;
7905 struct wireless_dev *wdev = dev->ieee80211_ptr;
7906 struct wiphy *wiphy = wdev->wiphy;
7907 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
7908 int chan_no;
7909 int ie_length;
7910 const char *ie;
7911 unsigned int freq;
7912 struct ieee80211_channel *chan;
7913 int rssi = 0;
7914 struct cfg80211_bss *bss = NULL;
7915
7916 ENTER();
7917
7918 if( NULL == pBssDesc )
7919 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007920 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007921 return bss;
7922 }
7923
7924 chan_no = pBssDesc->channelId;
7925 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
7926 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
7927
7928 if( NULL == ie )
7929 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007930 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 return bss;
7932 }
7933
7934#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
7935 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
7936 {
7937 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
7938 }
7939 else
7940 {
7941 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
7942 }
7943#else
7944 freq = ieee80211_channel_to_frequency(chan_no);
7945#endif
7946
7947 chan = __ieee80211_get_channel(wiphy, freq);
7948
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05307949 if (!chan) {
7950 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
7951 return NULL;
7952 }
7953
Abhishek Singhaee43942014-06-16 18:55:47 +05307954 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07007955
Abhishek Singhaee43942014-06-16 18:55:47 +05307956 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307957 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07007958 pBssDesc->capabilityInfo,
7959 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05307960 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07007961}
7962
7963
7964
7965/*
7966 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
7967 * This function is used to inform the BSS details to nl80211 interface.
7968 */
7969struct cfg80211_bss*
7970wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
7971 tSirBssDescription *bss_desc
7972 )
7973{
7974 /*
7975 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
7976 already exists in bss data base of cfg80211 for that particular BSS ID.
7977 Using cfg80211_inform_bss_frame to update the bss entry instead of
7978 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
7979 now there is no possibility to get the mgmt(probe response) frame from PE,
7980 converting bss_desc to ieee80211_mgmt(probe response) and passing to
7981 cfg80211_inform_bss_frame.
7982 */
7983 struct net_device *dev = pAdapter->dev;
7984 struct wireless_dev *wdev = dev->ieee80211_ptr;
7985 struct wiphy *wiphy = wdev->wiphy;
7986 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08007987#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
7988 qcom_ie_age *qie_age = NULL;
7989 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
7990#else
Jeff Johnson295189b2012-06-20 16:38:30 -07007991 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08007992#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 const char *ie =
7994 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
7995 unsigned int freq;
7996 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05307997 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007998 struct cfg80211_bss *bss_status = NULL;
7999 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
8000 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07008001 hdd_context_t *pHddCtx;
8002 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07008003#ifdef WLAN_OPEN_SOURCE
8004 struct timespec ts;
8005#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008006
Wilson Yangf80a0542013-10-07 13:02:37 -07008007 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8008 status = wlan_hdd_validate_context(pHddCtx);
8009
8010 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05308011 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07008012 {
8013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8014 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
8015 return NULL;
8016 }
8017
8018
8019 if (0 != status)
8020 {
8021 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8022 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07008023 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07008024 }
8025
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05308026 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07008027 if (!mgmt)
8028 {
8029 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8030 "%s: memory allocation failed ", __func__);
8031 return NULL;
8032 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07008033
Jeff Johnson295189b2012-06-20 16:38:30 -07008034 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07008035
8036#ifdef WLAN_OPEN_SOURCE
8037 /* Android does not want the timestamp from the frame.
8038 Instead it wants a monotonic increasing value */
8039 get_monotonic_boottime(&ts);
8040 mgmt->u.probe_resp.timestamp =
8041 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
8042#else
8043 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07008044 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
8045 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07008046
8047#endif
8048
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
8050 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08008051
8052#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
8053 /* GPS Requirement: need age ie per entry. Using vendor specific. */
8054 /* Assuming this is the last IE, copy at the end */
8055 ie_length -=sizeof(qcom_ie_age);
8056 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
8057 qie_age->element_id = QCOM_VENDOR_IE_ID;
8058 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
8059 qie_age->oui_1 = QCOM_OUI1;
8060 qie_age->oui_2 = QCOM_OUI2;
8061 qie_age->oui_3 = QCOM_OUI3;
8062 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
8063 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
8064#endif
8065
Jeff Johnson295189b2012-06-20 16:38:30 -07008066 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05308067 if (bss_desc->fProbeRsp)
8068 {
8069 mgmt->frame_control |=
8070 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
8071 }
8072 else
8073 {
8074 mgmt->frame_control |=
8075 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
8076 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008077
8078#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308079 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
8081 {
8082 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
8083 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308084 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
8086
8087 {
8088 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
8089 }
8090 else
8091 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05308092 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
8093 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07008094 kfree(mgmt);
8095 return NULL;
8096 }
8097#else
8098 freq = ieee80211_channel_to_frequency(chan_no);
8099#endif
8100 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08008101 /*when the band is changed on the fly using the GUI, three things are done
8102 * 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)
8103 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
8104 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
8105 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
8106 * and discards the channels correponding to previous band and calls back with zero bss results.
8107 * 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
8108 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
8109 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
8110 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
8111 * So drop the bss and continue to next bss.
8112 */
8113 if(chan == NULL)
8114 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05308115 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07008116 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08008117 return NULL;
8118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308120 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07008121 * */
8122 if (( eConnectionState_Associated ==
8123 pAdapter->sessionCtx.station.conn_info.connState ) &&
8124 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
8125 pAdapter->sessionCtx.station.conn_info.bssId,
8126 WNI_CFG_BSSID_LEN)))
8127 {
8128 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
8129 rssi = (pAdapter->rssi * 100);
8130 }
8131 else
8132 {
8133 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
8134 }
8135
Nirav Shah20ac06f2013-12-12 18:14:06 +05308136 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
8137 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
8138 chan->center_freq, (int)(rssi/100));
8139
Jeff Johnson295189b2012-06-20 16:38:30 -07008140 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
8141 frame_len, rssi, GFP_KERNEL);
8142 kfree(mgmt);
8143 return bss_status;
8144}
8145
8146/*
8147 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
8148 * This function is used to update the BSS data base of CFG8011
8149 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308150struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 tCsrRoamInfo *pRoamInfo
8152 )
8153{
8154 tCsrRoamConnectedProfile roamProfile;
8155 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8156 struct cfg80211_bss *bss = NULL;
8157
8158 ENTER();
8159
8160 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
8161 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
8162
8163 if (NULL != roamProfile.pBssDesc)
8164 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308165 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 &roamProfile);
8167
8168 if (NULL == bss)
8169 {
8170 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
8171 __func__);
8172 }
8173
8174 sme_RoamFreeConnectProfile(hHal, &roamProfile);
8175 }
8176 else
8177 {
8178 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
8179 __func__);
8180 }
8181 return bss;
8182}
8183
8184/*
8185 * FUNCTION: wlan_hdd_cfg80211_update_bss
8186 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308187static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
8188 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308190{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308191 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008192 tCsrScanResultInfo *pScanResult;
8193 eHalStatus status = 0;
8194 tScanResultHandle pResult;
8195 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07008196 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008197
8198 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308199
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308200 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8201 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
8202 NO_SESSION, pAdapter->sessionId));
8203
Wilson Yangf80a0542013-10-07 13:02:37 -07008204 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8205
8206 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07008207 {
Wilson Yangf80a0542013-10-07 13:02:37 -07008208 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8209 "%s:LOGP in Progress. Ignore!!!",__func__);
8210 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008211 }
8212
Wilson Yangf80a0542013-10-07 13:02:37 -07008213
8214 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05308215 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07008216 {
8217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8218 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
8219 return VOS_STATUS_E_PERM;
8220 }
8221
8222
Jeff Johnson295189b2012-06-20 16:38:30 -07008223 /*
8224 * start getting scan results and populate cgf80211 BSS database
8225 */
8226 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
8227
8228 /* no scan results */
8229 if (NULL == pResult)
8230 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05308231 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
8232 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07008233 return status;
8234 }
8235
8236 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
8237
8238 while (pScanResult)
8239 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308240 /*
8241 * cfg80211_inform_bss() is not updating ie field of bss entry, if
8242 * entry already exists in bss data base of cfg80211 for that
8243 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
8244 * bss entry instead of cfg80211_inform_bss, But this call expects
8245 * mgmt packet as input. As of now there is no possibility to get
8246 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07008247 * ieee80211_mgmt(probe response) and passing to c
8248 * fg80211_inform_bss_frame.
8249 * */
8250
8251 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
8252 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308253
Jeff Johnson295189b2012-06-20 16:38:30 -07008254
8255 if (NULL == bss_status)
8256 {
8257 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008258 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008259 }
8260 else
8261 {
Yue Maf49ba872013-08-19 12:04:25 -07008262 cfg80211_put_bss(
8263#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
8264 wiphy,
8265#endif
8266 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 }
8268
8269 pScanResult = sme_ScanResultGetNext(hHal, pResult);
8270 }
8271
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308272 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07008273
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308274 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008275}
8276
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008277void
8278hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
8279{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308280 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08008281 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008282} /****** end hddPrintMacAddr() ******/
8283
8284void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07008285hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008286{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308287 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008288 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07008289 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
8290 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
8291 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008292} /****** end hddPrintPmkId() ******/
8293
8294//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
8295//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
8296
8297//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
8298//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
8299
8300#define dump_bssid(bssid) \
8301 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07008302 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
8303 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008304 }
8305
8306#define dump_pmkid(pMac, pmkid) \
8307 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07008308 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
8309 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008310 }
8311
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07008312#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008313/*
8314 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
8315 * This function is used to notify the supplicant of a new PMKSA candidate.
8316 */
8317int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308318 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008319 int index, bool preauth )
8320{
Jeff Johnsone7245742012-09-05 17:12:55 -07008321#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008322 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008323 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008324
8325 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07008326 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008327
8328 if( NULL == pRoamInfo )
8329 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008330 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008331 return -EINVAL;
8332 }
8333
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008334 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
8335 {
8336 dump_bssid(pRoamInfo->bssid);
8337 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008338 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07008339 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008340#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308341 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008342}
8343#endif //FEATURE_WLAN_LFR
8344
Yue Maef608272013-04-08 23:09:17 -07008345#ifdef FEATURE_WLAN_LFR_METRICS
8346/*
8347 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
8348 * 802.11r/LFR metrics reporting function to report preauth initiation
8349 *
8350 */
8351#define MAX_LFR_METRICS_EVENT_LENGTH 100
8352VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
8353 tCsrRoamInfo *pRoamInfo)
8354{
8355 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
8356 union iwreq_data wrqu;
8357
8358 ENTER();
8359
8360 if (NULL == pAdapter)
8361 {
8362 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
8363 return VOS_STATUS_E_FAILURE;
8364 }
8365
8366 /* create the event */
8367 memset(&wrqu, 0, sizeof(wrqu));
8368 memset(metrics_notification, 0, sizeof(metrics_notification));
8369
8370 wrqu.data.pointer = metrics_notification;
8371 wrqu.data.length = scnprintf(metrics_notification,
8372 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
8373 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
8374
8375 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
8376
8377 EXIT();
8378
8379 return VOS_STATUS_SUCCESS;
8380}
8381
8382/*
8383 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
8384 * 802.11r/LFR metrics reporting function to report preauth completion
8385 * or failure
8386 */
8387VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
8388 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
8389{
8390 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
8391 union iwreq_data wrqu;
8392
8393 ENTER();
8394
8395 if (NULL == pAdapter)
8396 {
8397 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
8398 return VOS_STATUS_E_FAILURE;
8399 }
8400
8401 /* create the event */
8402 memset(&wrqu, 0, sizeof(wrqu));
8403 memset(metrics_notification, 0, sizeof(metrics_notification));
8404
8405 scnprintf(metrics_notification, sizeof(metrics_notification),
8406 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
8407 MAC_ADDR_ARRAY(pRoamInfo->bssid));
8408
8409 if (1 == preauth_status)
8410 strncat(metrics_notification, " TRUE", 5);
8411 else
8412 strncat(metrics_notification, " FALSE", 6);
8413
8414 wrqu.data.pointer = metrics_notification;
8415 wrqu.data.length = strlen(metrics_notification);
8416
8417 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
8418
8419 EXIT();
8420
8421 return VOS_STATUS_SUCCESS;
8422}
8423
8424/*
8425 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
8426 * 802.11r/LFR metrics reporting function to report handover initiation
8427 *
8428 */
8429VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
8430 tCsrRoamInfo *pRoamInfo)
8431{
8432 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
8433 union iwreq_data wrqu;
8434
8435 ENTER();
8436
8437 if (NULL == pAdapter)
8438 {
8439 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
8440 return VOS_STATUS_E_FAILURE;
8441 }
8442
8443 /* create the event */
8444 memset(&wrqu, 0, sizeof(wrqu));
8445 memset(metrics_notification, 0, sizeof(metrics_notification));
8446
8447 wrqu.data.pointer = metrics_notification;
8448 wrqu.data.length = scnprintf(metrics_notification,
8449 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
8450 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
8451
8452 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
8453
8454 EXIT();
8455
8456 return VOS_STATUS_SUCCESS;
8457}
8458#endif
8459
Jeff Johnson295189b2012-06-20 16:38:30 -07008460/*
8461 * FUNCTION: hdd_cfg80211_scan_done_callback
8462 * scanning callback function, called after finishing scan
8463 *
8464 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308465static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07008466 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
8467{
8468 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308469 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008471 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8472 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 struct cfg80211_scan_request *req = NULL;
8474 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05308475 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308476 long waitRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008477
8478 ENTER();
8479
8480 hddLog(VOS_TRACE_LEVEL_INFO,
8481 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -08008482 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 __func__, halHandle, pContext, (int) scanId, (int) status);
8484
Kiet Lamac06e2c2013-10-23 16:25:07 +05308485 pScanInfo->mScanPendingCounter = 0;
8486
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308488 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07008489 &pScanInfo->scan_req_completion_event,
8490 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308491 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07008492 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308493 hddLog(VOS_TRACE_LEVEL_ERROR,
8494 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -07008495 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07008496 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07008497 }
8498
Yue Maef608272013-04-08 23:09:17 -07008499 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008500 {
8501 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07008502 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07008503 }
8504
8505 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308506 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07008507 {
8508 hddLog(VOS_TRACE_LEVEL_INFO,
8509 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -08008510 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 (int) scanId);
8512 }
8513
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308514 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008515 pAdapter);
8516
8517 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308518 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008519
8520
8521 /* If any client wait scan result through WEXT
8522 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008523 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07008524 {
8525 /* The other scan request waiting for current scan finish
8526 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008527 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008529 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07008530 }
8531 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008532 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 {
8534 struct net_device *dev = pAdapter->dev;
8535 union iwreq_data wrqu;
8536 int we_event;
8537 char *msg;
8538
8539 memset(&wrqu, '\0', sizeof(wrqu));
8540 we_event = SIOCGIWSCAN;
8541 msg = NULL;
8542 wireless_send_event(dev, we_event, &wrqu, msg);
8543 }
8544 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07008545 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008546
8547 /* Get the Scan Req */
8548 req = pAdapter->request;
8549
8550 if (!req)
8551 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008552 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07008553 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008554 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07008555 }
8556
8557 /*
8558 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308559 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008560 req->n_ssids = 0;
8561 req->n_channels = 0;
8562 req->ie = 0;
8563
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07008565 /* Scan is no longer pending */
8566 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008567
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07008568 /*
8569 * cfg80211_scan_done informing NL80211 about completion
8570 * of scanning
8571 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05308572 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
8573 {
8574 aborted = true;
8575 }
8576 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08008577 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07008578
Jeff Johnsone7245742012-09-05 17:12:55 -07008579allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07008580 /* release the wake lock at the end of the scan*/
8581 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07008582
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07008583 /* Acquire wakelock to handle the case where APP's tries to suspend
8584 * immediatly after the driver gets connect request(i.e after scan)
8585 * from supplicant, this result in app's is suspending and not able
8586 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05308587 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07008588
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07008589#ifdef FEATURE_WLAN_TDLS
c_hpothu3c8f8e82014-06-02 18:01:50 +05308590 if (!(eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode))
8591 {
8592 wlan_hdd_tdls_scan_done_callback(pAdapter);
8593 }
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07008594#endif
8595
Jeff Johnson295189b2012-06-20 16:38:30 -07008596 EXIT();
8597 return 0;
8598}
8599
8600/*
Rashmi Ramannab1429032014-04-26 14:59:09 +05308601 * FUNCTION: hdd_isConnectionInProgress
8602 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08008603 *
8604 */
Rashmi Ramannab1429032014-04-26 14:59:09 +05308605v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx )
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08008606{
8607 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
8608 hdd_station_ctx_t *pHddStaCtx = NULL;
8609 hdd_adapter_t *pAdapter = NULL;
8610 VOS_STATUS status = 0;
8611 v_U8_t staId = 0;
8612 v_U8_t *staMac = NULL;
8613
c_hpothu9b781ba2013-12-30 20:57:45 +05308614 if (TRUE == pHddCtx->btCoexModeSet)
8615 {
8616 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +05308617 FL("BTCoex Mode operation in progress"));
8618 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +05308619 }
8620
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08008621 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8622
8623 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8624 {
8625 pAdapter = pAdapterNode->pAdapter;
8626
8627 if( pAdapter )
8628 {
8629 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308630 "%s: Adapter with device mode %s (%d) exists",
8631 __func__, hdd_device_modetoString(pAdapter->device_mode),
8632 pAdapter->device_mode);
Rashmi Ramannab1429032014-04-26 14:59:09 +05308633 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
8634 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
8635 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
8636 (eConnectionState_Connecting ==
8637 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
8638 {
8639 hddLog(VOS_TRACE_LEVEL_ERROR,
8640 "%s: %p(%d) Connection is in progress", __func__,
8641 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
8642 return VOS_TRUE;
8643 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08008644 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308645 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
8646 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08008647 {
8648 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8649 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308650 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08008651 {
8652 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
8653 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08008654 "%s: client " MAC_ADDRESS_STR
8655 " is in the middle of WPS/EAPOL exchange.", __func__,
8656 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05308657 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08008658 }
8659 }
8660 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
8661 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
8662 {
8663 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
8664 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308665 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08008666 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
8667 {
8668 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
8669
8670 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08008671 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
8672 "middle of WPS/EAPOL exchange.", __func__,
8673 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05308674 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08008675 }
8676 }
8677 }
8678 }
8679 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8680 pAdapterNode = pNext;
8681 }
Rashmi Ramannab1429032014-04-26 14:59:09 +05308682 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308683}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08008684
8685/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05308686 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 * this scan respond to scan trigger and update cfg80211 scan database
8688 * later, scan dump command can be used to recieve scan results
8689 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05308690int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08008691#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
8692 struct net_device *dev,
8693#endif
8694 struct cfg80211_scan_request *request)
8695{
Siddharth Bhal0c162d02014-05-06 19:50:42 +05308696 hdd_adapter_t *pAdapter = NULL;
8697 hdd_context_t *pHddCtx = NULL;
8698 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308699 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008700 tCsrScanRequest scanRequest;
8701 tANI_U8 *channelList = NULL, i;
8702 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308703 int status;
8704 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008705 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008706
Siddharth Bhal0c162d02014-05-06 19:50:42 +05308707#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
8708 struct net_device *dev = NULL;
8709 if (NULL == request)
8710 {
8711 hddLog(VOS_TRACE_LEVEL_ERROR,
8712 "%s: scan req param null", __func__);
8713 return -EINVAL;
8714 }
8715 dev = request->wdev->netdev;
8716#endif
8717
8718 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
8719 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
8720 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8721
Jeff Johnson295189b2012-06-20 16:38:30 -07008722 ENTER();
8723
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308724
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308725 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8726 __func__, hdd_device_modetoString(pAdapter->device_mode),
8727 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308728
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308729 status = wlan_hdd_validate_context(pHddCtx);
8730
8731 if (0 != status)
8732 {
8733 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8734 "%s: HDD context is not valid", __func__);
8735 return status;
8736 }
8737
Siddharth Bhal0c162d02014-05-06 19:50:42 +05308738 if (NULL == pwextBuf)
8739 {
8740 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
8741 __func__);
8742 return -EIO;
8743 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308744 cfg_param = pHddCtx->cfg_ini;
8745 pScanInfo = &pHddCtx->scan_info;
8746
Jeff Johnson295189b2012-06-20 16:38:30 -07008747#ifdef WLAN_BTAMP_FEATURE
8748 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008749 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07008750 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08008751 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008752 "%s: No scanning when AMP is on", __func__);
8753 return -EOPNOTSUPP;
8754 }
8755#endif
8756 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008757 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008759 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308760 "%s: Not scanning on device_mode = %s (%d)",
8761 __func__, hdd_device_modetoString(pAdapter->device_mode),
8762 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008763 return -EOPNOTSUPP;
8764 }
8765
8766 if (TRUE == pScanInfo->mScanPending)
8767 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05308768 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
8769 {
8770 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
8771 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008772 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07008773 }
8774
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308775 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07008776 //Channel and action frame is pending
8777 //Otherwise Cancel Remain On Channel and allow Scan
8778 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008779 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07008780 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05308781 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008782 return -EBUSY;
8783 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008784#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07008785 /* if tdls disagree scan right now, return immediately.
8786 tdls will schedule the scan when scan is allowed. (return SUCCESS)
8787 or will reject the scan if any TDLS is in progress. (return -EBUSY)
8788 */
8789 status = wlan_hdd_tdls_scan_callback (pAdapter,
8790 wiphy,
8791#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
8792 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07008793#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07008794 request);
8795 if(status <= 0)
8796 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05308797 if(!status)
8798 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
8799 "scan rejected %d", __func__, status);
8800 else
8801 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
8802 __func__, status);
8803
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07008804 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008805 }
8806#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07008807
Jeff Johnson295189b2012-06-20 16:38:30 -07008808 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
8809 {
8810 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08008811 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008812 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008814 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
8815 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05308816 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008817 "%s: MAX TM Level Scan not allowed", __func__);
8818 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308819 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07008820 }
8821 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
8822
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08008823 /* Check if scan is allowed at this point of time.
8824 */
Rashmi Ramannab1429032014-04-26 14:59:09 +05308825 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08008826 {
8827 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
8828 return -EBUSY;
8829 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308830
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 vos_mem_zero( &scanRequest, sizeof(scanRequest));
8832
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308833 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
8834 (int)request->n_ssids);
8835
8836 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
8837 * Becasue of this, driver is assuming that this is not wildcard scan and so
8838 * is not aging out the scan results.
8839 */
8840 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308842 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008843 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308844
8845 if ((request->ssids) && (0 < request->n_ssids))
8846 {
8847 tCsrSSIDInfo *SsidInfo;
8848 int j;
8849 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
8850 /* Allocate num_ssid tCsrSSIDInfo structure */
8851 SsidInfo = scanRequest.SSIDs.SSIDList =
8852 ( tCsrSSIDInfo *)vos_mem_malloc(
8853 request->n_ssids*sizeof(tCsrSSIDInfo));
8854
8855 if(NULL == scanRequest.SSIDs.SSIDList)
8856 {
8857 hddLog(VOS_TRACE_LEVEL_ERROR,
8858 "%s: memory alloc failed SSIDInfo buffer", __func__);
8859 return -ENOMEM;
8860 }
8861
8862 /* copy all the ssid's and their length */
8863 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
8864 {
8865 /* get the ssid length */
8866 SsidInfo->SSID.length = request->ssids[j].ssid_len;
8867 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
8868 SsidInfo->SSID.length);
8869 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
8870 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
8871 j, SsidInfo->SSID.ssId);
8872 }
8873 /* set the scan type to active */
8874 scanRequest.scanType = eSIR_ACTIVE_SCAN;
8875 }
8876 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07008877 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +05308878 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8879 TRACE_CODE_HDD_CFG80211_SCAN,
8880 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07008881 /* set the scan type to active */
8882 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07008883 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308884 else
8885 {
8886 /*Set the scan type to default type, in this case it is ACTIVE*/
8887 scanRequest.scanType = pScanInfo->scan_mode;
8888 }
8889 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
8890 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07008891
8892 /* set BSSType to default type */
8893 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
8894
8895 /*TODO: scan the requested channels only*/
8896
8897 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308898 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -07008899 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308900 hddLog(VOS_TRACE_LEVEL_WARN,
8901 "No of Scan Channels exceeded limit: %d", request->n_channels);
8902 request->n_channels = MAX_CHANNEL;
8903 }
8904
8905 hddLog(VOS_TRACE_LEVEL_INFO,
8906 "No of Scan Channels: %d", request->n_channels);
8907
8908
8909 if( request->n_channels )
8910 {
8911 char chList [(request->n_channels*5)+1];
8912 int len;
8913 channelList = vos_mem_malloc( request->n_channels );
8914 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +05308915 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308916 hddLog(VOS_TRACE_LEVEL_ERROR,
8917 "%s: memory alloc failed channelList", __func__);
8918 status = -ENOMEM;
8919 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +05308920 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308921
8922 for( i = 0, len = 0; i < request->n_channels ; i++ )
8923 {
8924 channelList[i] = request->channels[i]->hw_value;
8925 len += snprintf(chList+len, 5, "%d ", channelList[i]);
8926 }
8927
Nirav Shah20ac06f2013-12-12 18:14:06 +05308928 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308929 "Channel-List: %s ", chList);
8930 }
c_hpothu53512302014-04-15 18:49:53 +05308931
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308932 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
8933 scanRequest.ChannelInfo.ChannelList = channelList;
8934
8935 /* set requestType to full scan */
8936 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
8937
8938 /* Flush the scan results(only p2p beacons) for STA scan and P2P
8939 * search (Flush on both full scan and social scan but not on single
8940 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
8941 */
8942
8943 /* Supplicant does single channel scan after 8-way handshake
8944 * and in that case driver shoudnt flush scan results. If
8945 * driver flushes the scan results here and unfortunately if
8946 * the AP doesnt respond to our probe req then association
8947 * fails which is not desired
8948 */
8949
8950 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
8951 {
8952 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
8953 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
8954 pAdapter->sessionId );
8955 }
8956
8957 if( request->ie_len )
8958 {
8959 /* save this for future association (join requires this) */
8960 /*TODO: Array needs to be converted to dynamic allocation,
8961 * as multiple ie.s can be sent in cfg80211_scan_request structure
8962 * CR 597966
8963 */
8964 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
8965 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
8966 pScanInfo->scanAddIE.length = request->ie_len;
8967
8968 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
8969 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
8970 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008971 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308972 if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -07008973 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308974 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
8975 memcpy( pwextBuf->roamProfile.addIEScan,
8976 request->ie, request->ie_len);
8977 }
8978 else
8979 {
8980 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
8981 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008982 }
8983
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308984 }
8985 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
8986 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
8987
8988 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
8989 request->ie_len);
8990 if (pP2pIe != NULL)
8991 {
8992#ifdef WLAN_FEATURE_P2P_DEBUG
8993 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
8994 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
8995 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +05308996 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05308997 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
8998 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
8999 "Go nego completed to Connection is started");
9000 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
9001 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +05309002 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309003 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
9004 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07009005 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309006 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
9007 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
9008 "Disconnected state to Connection is started");
9009 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
9010 "for 4way Handshake");
9011 }
9012#endif
9013
9014 /* no_cck will be set during p2p find to disable 11b rates */
9015 if(TRUE == request->no_cck)
9016 {
9017 hddLog(VOS_TRACE_LEVEL_INFO,
9018 "%s: This is a P2P Search", __func__);
9019 scanRequest.p2pSearch = 1;
9020
9021 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +05309022 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309023 /* set requestType to P2P Discovery */
9024 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
9025 }
9026
9027 /*
9028 Skip Dfs Channel in case of P2P Search
9029 if it is set in ini file
9030 */
9031 if(cfg_param->skipDfsChnlInP2pSearch)
9032 {
9033 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +05309034 }
9035 else
9036 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05309037 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05309038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009039
Agarwal Ashish4f616132013-12-30 23:32:50 +05309040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009041 }
9042 }
9043
9044 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
9045
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009046 /* acquire the wakelock to avoid the apps suspend during the scan. To
9047 * address the following issues.
9048 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
9049 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
9050 * for long time, this result in apps running at full power for long time.
9051 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
9052 * be stuck in full power because of resume BMPS
9053 */
9054 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07009055
Nirav Shah20ac06f2013-12-12 18:14:06 +05309056 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
9057 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309058 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
9059 scanRequest.requestType, scanRequest.scanType,
9060 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +05309061 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
9062
Jeff Johnsone7245742012-09-05 17:12:55 -07009063 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009064 pAdapter->sessionId, &scanRequest, &scanId,
9065 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07009066
Jeff Johnson295189b2012-06-20 16:38:30 -07009067 if (eHAL_STATUS_SUCCESS != status)
9068 {
9069 hddLog(VOS_TRACE_LEVEL_ERROR,
9070 "%s: sme_ScanRequest returned error %d", __func__, status);
9071 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07009072 if(eHAL_STATUS_RESOURCES == status)
9073 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309074 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
9075 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07009076 status = -EBUSY;
9077 } else {
9078 status = -EIO;
9079 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07009080 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07009081 goto free_mem;
9082 }
9083
9084 pScanInfo->mScanPending = TRUE;
9085 pAdapter->request = request;
9086 pScanInfo->scanId = scanId;
9087
9088 complete(&pScanInfo->scan_req_completion_event);
9089
9090free_mem:
9091 if( scanRequest.SSIDs.SSIDList )
9092 {
9093 vos_mem_free(scanRequest.SSIDs.SSIDList);
9094 }
9095
9096 if( channelList )
9097 vos_mem_free( channelList );
9098
9099 EXIT();
9100
9101 return status;
9102}
9103
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05309104int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
9105#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9106 struct net_device *dev,
9107#endif
9108 struct cfg80211_scan_request *request)
9109{
9110 int ret;
9111
9112 vos_ssr_protect(__func__);
9113 ret = __wlan_hdd_cfg80211_scan(wiphy,
9114#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
9115 dev,
9116#endif
9117 request);
9118 vos_ssr_unprotect(__func__);
9119
9120 return ret;
9121}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07009122
9123void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
9124{
9125 v_U8_t iniDot11Mode =
9126 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
9127 eHddDot11Mode hddDot11Mode = iniDot11Mode;
9128
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05309129 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
9130 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07009131 switch ( iniDot11Mode )
9132 {
9133 case eHDD_DOT11_MODE_AUTO:
9134 case eHDD_DOT11_MODE_11ac:
9135 case eHDD_DOT11_MODE_11ac_ONLY:
9136#ifdef WLAN_FEATURE_11AC
9137 hddDot11Mode = eHDD_DOT11_MODE_11ac;
9138#else
9139 hddDot11Mode = eHDD_DOT11_MODE_11n;
9140#endif
9141 break;
9142 case eHDD_DOT11_MODE_11n:
9143 case eHDD_DOT11_MODE_11n_ONLY:
9144 hddDot11Mode = eHDD_DOT11_MODE_11n;
9145 break;
9146 default:
9147 hddDot11Mode = iniDot11Mode;
9148 break;
9149 }
9150 /* This call decides required channel bonding mode */
9151 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
9152 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
9153 operationChannel);
9154}
9155
Jeff Johnson295189b2012-06-20 16:38:30 -07009156/*
9157 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309158 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07009159 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309160int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07009161 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07009162{
9163 int status = 0;
9164 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -08009165 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009166 v_U32_t roamId;
9167 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07009168 eCsrAuthType RSNAuthType;
9169
9170 ENTER();
9171
9172 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -08009173 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9174
9175 status = wlan_hdd_validate_context(pHddCtx);
9176 if (status)
9177 {
9178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9179 "%s: HDD context is not valid!", __func__);
9180 return status;
9181 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309182
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
9184 {
9185 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
9186 return -EINVAL;
9187 }
9188
9189 pRoamProfile = &pWextState->roamProfile;
9190
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309191 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07009192 {
Jeff Johnsone7245742012-09-05 17:12:55 -07009193 hdd_station_ctx_t *pHddStaCtx;
9194 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009195
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309196 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07009197 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
9198 {
9199 /*QoS not enabled in cfg file*/
9200 pRoamProfile->uapsd_mask = 0;
9201 }
9202 else
9203 {
9204 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309205 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07009206 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
9207 }
9208
9209 pRoamProfile->SSIDs.numOfSSIDs = 1;
9210 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
9211 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309212 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07009213 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
9214 ssid, ssid_len);
9215
9216 if (bssid)
9217 {
9218 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
9219 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
9220 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309221 /* Save BSSID in seperate variable as well, as RoamProfile
9222 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 case of join failure we should send valid BSSID to supplicant
9224 */
9225 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
9226 WNI_CFG_BSSID_LEN);
9227 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07009228 else
9229 {
9230 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
9231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009232
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05309233 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
9234 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
9236 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309237 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009238 /*set gen ie*/
9239 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
9240 /*set auth*/
9241 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
9242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009243#ifdef FEATURE_WLAN_WAPI
9244 if (pAdapter->wapi_info.nWapiMode)
9245 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009246 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009247 switch (pAdapter->wapi_info.wapiAuthMode)
9248 {
9249 case WAPI_AUTH_MODE_PSK:
9250 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009251 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009252 pAdapter->wapi_info.wapiAuthMode);
9253 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
9254 break;
9255 }
9256 case WAPI_AUTH_MODE_CERT:
9257 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009258 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 pAdapter->wapi_info.wapiAuthMode);
9260 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
9261 break;
9262 }
9263 } // End of switch
9264 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
9265 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
9266 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009267 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009268 pRoamProfile->AuthType.numEntries = 1;
9269 pRoamProfile->EncryptionType.numEntries = 1;
9270 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
9271 pRoamProfile->mcEncryptionType.numEntries = 1;
9272 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
9273 }
9274 }
9275#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309276#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309277 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309278 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
9279 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
9280 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05309281 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
9282 sizeof (tSirGtkOffloadParams));
9283 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309284 }
9285#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009286 pRoamProfile->csrPersona = pAdapter->device_mode;
9287
Jeff Johnson32d95a32012-09-10 13:15:23 -07009288 if( operatingChannel )
9289 {
9290 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
9291 pRoamProfile->ChannelInfo.numOfChannels = 1;
9292 }
Chet Lanctot186b5732013-03-18 10:26:30 -07009293 else
9294 {
9295 pRoamProfile->ChannelInfo.ChannelList = NULL;
9296 pRoamProfile->ChannelInfo.numOfChannels = 0;
9297 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07009298 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
9299 {
9300 hdd_select_cbmode(pAdapter,operatingChannel);
9301 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05309302
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08009303 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
9304 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309305 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08009306 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08009307 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
9308 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05309309 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
9310 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +05309311 {
9312 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9313 "%s: Set HDD connState to eConnectionState_Connecting",
9314 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08009315 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
9316 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +05309317 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309318 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009319 pAdapter->sessionId, pRoamProfile, &roamId);
9320
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05309321 if ((eHAL_STATUS_SUCCESS != status) &&
9322 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
9323 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05309324
9325 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08009326 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
9327 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
9328 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05309329 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08009330 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05309331 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08009332
9333 pRoamProfile->ChannelInfo.ChannelList = NULL;
9334 pRoamProfile->ChannelInfo.numOfChannels = 0;
9335
Jeff Johnson295189b2012-06-20 16:38:30 -07009336 }
9337 else
9338 {
9339 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
9340 return -EINVAL;
9341 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08009342 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 return status;
9344}
9345
9346/*
9347 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
9348 * This function is used to set the authentication type (OPEN/SHARED).
9349 *
9350 */
9351static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
9352 enum nl80211_auth_type auth_type)
9353{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309354 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009355 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9356
9357 ENTER();
9358
9359 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309360 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07009361 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009362 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05309363 hddLog(VOS_TRACE_LEVEL_INFO,
9364 "%s: set authentication type to AUTOSWITCH", __func__);
9365 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
9366 break;
9367
9368 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009369#ifdef WLAN_FEATURE_VOWIFI_11R
9370 case NL80211_AUTHTYPE_FT:
9371#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309372 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009373 "%s: set authentication type to OPEN", __func__);
9374 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
9375 break;
9376
9377 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309378 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009379 "%s: set authentication type to SHARED", __func__);
9380 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
9381 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009382#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009383 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309384 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07009385 "%s: set authentication type to CCKM WPA", __func__);
9386 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
9387 break;
9388#endif
9389
9390
9391 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309392 hddLog(VOS_TRACE_LEVEL_ERROR,
9393 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 auth_type);
9395 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
9396 return -EINVAL;
9397 }
9398
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309399 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 pHddStaCtx->conn_info.authType;
9401 return 0;
9402}
9403
9404/*
9405 * FUNCTION: wlan_hdd_set_akm_suite
9406 * This function is used to set the key mgmt type(PSK/8021x).
9407 *
9408 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309409static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 u32 key_mgmt
9411 )
9412{
9413 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9414 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309415
Jeff Johnson295189b2012-06-20 16:38:30 -07009416 /*set key mgmt type*/
9417 switch(key_mgmt)
9418 {
9419 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05309420#ifdef WLAN_FEATURE_VOWIFI_11R
9421 case WLAN_AKM_SUITE_FT_PSK:
9422#endif
9423 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07009424 __func__);
9425 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
9426 break;
9427
9428 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05309429#ifdef WLAN_FEATURE_VOWIFI_11R
9430 case WLAN_AKM_SUITE_FT_8021X:
9431#endif
9432 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 __func__);
9434 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
9435 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009436#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009437#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
9438#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
9439 case WLAN_AKM_SUITE_CCKM:
9440 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
9441 __func__);
9442 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
9443 break;
9444#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009445#ifndef WLAN_AKM_SUITE_OSEN
9446#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
9447 case WLAN_AKM_SUITE_OSEN:
9448 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
9449 __func__);
9450 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
9451 break;
9452#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009453
9454 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309455 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009456 __func__, key_mgmt);
9457 return -EINVAL;
9458
9459 }
9460 return 0;
9461}
9462
9463/*
9464 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309465 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07009466 * (NONE/WEP40/WEP104/TKIP/CCMP).
9467 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309468static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
9469 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07009470 bool ucast
9471 )
9472{
9473 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309474 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9476
9477 ENTER();
9478
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309479 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309481 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07009482 __func__, cipher);
9483 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
9484 }
9485 else
9486 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309487
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309489 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 {
9491 case IW_AUTH_CIPHER_NONE:
9492 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
9493 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309494
Jeff Johnson295189b2012-06-20 16:38:30 -07009495 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05309496 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309498
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05309500 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309502
Jeff Johnson295189b2012-06-20 16:38:30 -07009503 case WLAN_CIPHER_SUITE_TKIP:
9504 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
9505 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309506
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 case WLAN_CIPHER_SUITE_CCMP:
9508 encryptionType = eCSR_ENCRYPT_TYPE_AES;
9509 break;
9510#ifdef FEATURE_WLAN_WAPI
9511 case WLAN_CIPHER_SUITE_SMS4:
9512 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
9513 break;
9514#endif
9515
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009516#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 case WLAN_CIPHER_SUITE_KRK:
9518 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
9519 break;
9520#endif
9521 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309522 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009523 __func__, cipher);
9524 return -EOPNOTSUPP;
9525 }
9526 }
9527
9528 if (ucast)
9529 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309530 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009531 __func__, encryptionType);
9532 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
9533 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309534 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07009535 encryptionType;
9536 }
9537 else
9538 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309539 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 __func__, encryptionType);
9541 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
9542 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
9543 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
9544 }
9545
9546 return 0;
9547}
9548
9549
9550/*
9551 * FUNCTION: wlan_hdd_cfg80211_set_ie
9552 * This function is used to parse WPA/RSN IE's.
9553 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309554int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
9555 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07009556 size_t ie_len
9557 )
9558{
9559 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9560 u8 *genie = ie;
9561 v_U16_t remLen = ie_len;
9562#ifdef FEATURE_WLAN_WAPI
9563 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
9564 u16 *tmp;
9565 v_U16_t akmsuiteCount;
9566 int *akmlist;
9567#endif
9568 ENTER();
9569
9570 /* clear previous assocAddIE */
9571 pWextState->assocAddIE.length = 0;
9572 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07009573 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009574
9575 while (remLen >= 2)
9576 {
9577 v_U16_t eLen = 0;
9578 v_U8_t elementId;
9579 elementId = *genie++;
9580 eLen = *genie++;
9581 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309582
Arif Hussain6d2a3322013-11-17 19:50:10 -08009583 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309585
9586 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07009587 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309588 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07009589 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 -07009590 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309591 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009592 "%s: Invalid WPA IE", __func__);
9593 return -EINVAL;
9594 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309595 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 {
9597 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309598 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07009599 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309600
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
9602 {
Jeff Johnson902c9832012-12-10 14:28:09 -08009603 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
9604 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07009605 VOS_ASSERT(0);
9606 return -ENOMEM;
9607 }
9608 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
9609 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
9610 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309611
Jeff Johnson295189b2012-06-20 16:38:30 -07009612 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
9613 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
9614 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
9615 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309616 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
9617 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009618 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
9619 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
9620 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
9621 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
9622 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
9623 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309624 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +05309625 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009626 {
9627 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309628 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07009629 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309630
Jeff Johnson295189b2012-06-20 16:38:30 -07009631 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
9632 {
Jeff Johnson902c9832012-12-10 14:28:09 -08009633 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
9634 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07009635 VOS_ASSERT(0);
9636 return -ENOMEM;
9637 }
9638 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
9639 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
9640 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309641
Jeff Johnson295189b2012-06-20 16:38:30 -07009642 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
9643 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
9644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009645#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309646 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
9647 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 /*Consider WFD IE, only for P2P Client */
9649 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
9650 {
9651 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309652 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309654
Jeff Johnson295189b2012-06-20 16:38:30 -07009655 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
9656 {
Jeff Johnson902c9832012-12-10 14:28:09 -08009657 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
9658 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07009659 VOS_ASSERT(0);
9660 return -ENOMEM;
9661 }
9662 // WFD IE is saved to Additional IE ; it should be accumulated to handle
9663 // WPS IE + P2P IE + WFD IE
9664 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
9665 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309666
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
9668 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
9669 }
9670#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07009671 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309672 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07009673 HS20_OUI_TYPE_SIZE)) )
9674 {
9675 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309676 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07009677 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07009678
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07009679 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
9680 {
Jeff Johnson902c9832012-12-10 14:28:09 -08009681 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
9682 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07009683 VOS_ASSERT(0);
9684 return -ENOMEM;
9685 }
9686 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
9687 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07009688
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07009689 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
9690 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
9691 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07009692 /* Appending OSEN Information Element in Assiciation Request */
9693 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
9694 OSEN_OUI_TYPE_SIZE)) )
9695 {
9696 v_U16_t curAddIELen = pWextState->assocAddIE.length;
9697 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
9698 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07009699
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07009700 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
9701 {
9702 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
9703 "Need bigger buffer space");
9704 VOS_ASSERT(0);
9705 return -ENOMEM;
9706 }
9707 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
9708 pWextState->assocAddIE.length += eLen + 2;
9709
9710 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
9711 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
9712 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
9713 }
9714
9715 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07009716 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
9717
9718 /* populating as ADDIE in beacon frames */
9719 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
9720 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
9721 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
9722 {
9723 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
9724 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
9725 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
9726 {
9727 hddLog(LOGE,
9728 "Coldn't pass "
9729 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
9730 }
9731 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
9732 else
9733 hddLog(LOGE,
9734 "Could not pass on "
9735 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
9736
9737 /* IBSS mode doesn't contain params->proberesp_ies still
9738 beaconIE's need to be populated in probe response frames */
9739 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
9740 {
9741 u16 rem_probe_resp_ie_len = eLen + 2;
9742 u8 probe_rsp_ie_len[3] = {0};
9743 u8 counter = 0;
9744
9745 /* Check Probe Resp Length if it is greater then 255 then
9746 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
9747 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
9748 not able Store More then 255 bytes into One Variable */
9749
9750 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
9751 {
9752 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
9753 {
9754 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
9755 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
9756 }
9757 else
9758 {
9759 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
9760 rem_probe_resp_ie_len = 0;
9761 }
9762 }
9763
9764 rem_probe_resp_ie_len = 0;
9765
9766 if (probe_rsp_ie_len[0] > 0)
9767 {
9768 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
9769 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
9770 (tANI_U8*)(genie - 2),
9771 probe_rsp_ie_len[0], NULL,
9772 eANI_BOOLEAN_FALSE)
9773 == eHAL_STATUS_FAILURE)
9774 {
9775 hddLog(LOGE,
9776 "Could not pass"
9777 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
9778 }
9779 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
9780 }
9781
9782 if (probe_rsp_ie_len[1] > 0)
9783 {
9784 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
9785 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
9786 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
9787 probe_rsp_ie_len[1], NULL,
9788 eANI_BOOLEAN_FALSE)
9789 == eHAL_STATUS_FAILURE)
9790 {
9791 hddLog(LOGE,
9792 "Could not pass"
9793 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
9794 }
9795 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
9796 }
9797
9798 if (probe_rsp_ie_len[2] > 0)
9799 {
9800 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
9801 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
9802 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
9803 probe_rsp_ie_len[2], NULL,
9804 eANI_BOOLEAN_FALSE)
9805 == eHAL_STATUS_FAILURE)
9806 {
9807 hddLog(LOGE,
9808 "Could not pass"
9809 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
9810 }
9811 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
9812 }
9813
9814 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
9815 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
9816 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
9817 {
9818 hddLog(LOGE,
9819 "Could not pass"
9820 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
9821 }
9822 }
9823 else
9824 {
9825 // Reset WNI_CFG_PROBE_RSP Flags
9826 wlan_hdd_reset_prob_rspies(pAdapter);
9827
9828 hddLog(VOS_TRACE_LEVEL_INFO,
9829 "%s: No Probe Response IE received in set beacon",
9830 __func__);
9831 }
9832 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 break;
9834 case DOT11F_EID_RSN:
9835 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
9836 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
9837 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
9838 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
9839 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
9840 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07009841 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
9842 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309843 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07009844 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309845 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07009846 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309847
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07009848 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
9849 {
Jeff Johnson902c9832012-12-10 14:28:09 -08009850 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
9851 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07009852 VOS_ASSERT(0);
9853 return -ENOMEM;
9854 }
9855 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
9856 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309857
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07009858 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
9859 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
9860 break;
9861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009862#ifdef FEATURE_WLAN_WAPI
9863 case WLAN_EID_WAPI:
9864 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009865 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07009866 pAdapter->wapi_info.nWapiMode);
9867 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309868 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07009869 akmsuiteCount = WPA_GET_LE16(tmp);
9870 tmp = tmp + 1;
9871 akmlist = (int *)(tmp);
9872 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
9873 {
9874 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
9875 }
9876 else
9877 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009878 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -07009879 VOS_ASSERT(0);
9880 return -EINVAL;
9881 }
9882
9883 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
9884 {
9885 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009886 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309888 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009889 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309890 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009891 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009892 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009893 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
9894 }
9895 break;
9896#endif
9897 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309898 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07009900 /* when Unknown IE is received we should break and continue
9901 * to the next IE in the buffer instead we were returning
9902 * so changing this to break */
9903 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009904 }
9905 genie += eLen;
9906 remLen -= eLen;
9907 }
9908 EXIT();
9909 return 0;
9910}
9911
9912/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05309913 * FUNCTION: hdd_isWPAIEPresent
9914 * Parse the received IE to find the WPA IE
9915 *
9916 */
9917static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
9918{
9919 v_U8_t eLen = 0;
9920 v_U16_t remLen = ie_len;
9921 v_U8_t elementId = 0;
9922
9923 while (remLen >= 2)
9924 {
9925 elementId = *ie++;
9926 eLen = *ie++;
9927 remLen -= 2;
9928 if (eLen > remLen)
9929 {
9930 hddLog(VOS_TRACE_LEVEL_ERROR,
9931 "%s: IE length is wrong %d", __func__, eLen);
9932 return FALSE;
9933 }
9934 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
9935 {
9936 /* OUI - 0x00 0X50 0XF2
9937 WPA Information Element - 0x01
9938 WPA version - 0x01*/
9939 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
9940 return TRUE;
9941 }
9942 ie += eLen;
9943 remLen -= eLen;
9944 }
9945 return FALSE;
9946}
9947
9948/*
Jeff Johnson295189b2012-06-20 16:38:30 -07009949 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309950 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07009951 * parameters during connect operation.
9952 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309953int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 struct cfg80211_connect_params *req
9955 )
9956{
9957 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309958 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 ENTER();
9960
9961 /*set wpa version*/
9962 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
9963
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309964 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07009965 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05309966 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07009967 {
9968 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
9969 }
9970 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
9971 {
9972 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
9973 }
9974 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309975
9976 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009977 pWextState->wpaVersion);
9978
9979 /*set authentication type*/
9980 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
9981
9982 if (0 > status)
9983 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309984 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009985 "%s: failed to set authentication type ", __func__);
9986 return status;
9987 }
9988
9989 /*set key mgmt type*/
9990 if (req->crypto.n_akm_suites)
9991 {
9992 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
9993 if (0 > status)
9994 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309995 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07009996 __func__);
9997 return status;
9998 }
9999 }
10000
10001 /*set pairwise cipher type*/
10002 if (req->crypto.n_ciphers_pairwise)
10003 {
10004 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
10005 req->crypto.ciphers_pairwise[0], true);
10006 if (0 > status)
10007 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010008 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010009 "%s: failed to set unicast cipher type", __func__);
10010 return status;
10011 }
10012 }
10013 else
10014 {
10015 /*Reset previous cipher suite to none*/
10016 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
10017 if (0 > status)
10018 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010019 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010020 "%s: failed to set unicast cipher type", __func__);
10021 return status;
10022 }
10023 }
10024
10025 /*set group cipher type*/
10026 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
10027 false);
10028
10029 if (0 > status)
10030 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010031 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070010032 __func__);
10033 return status;
10034 }
10035
Chet Lanctot186b5732013-03-18 10:26:30 -070010036#ifdef WLAN_FEATURE_11W
10037 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
10038#endif
10039
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
10041 if (req->ie_len)
10042 {
10043 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
10044 if ( 0 > status)
10045 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010046 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070010047 __func__);
10048 return status;
10049 }
10050 }
10051
10052 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010053 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070010054 {
10055 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
10056 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
10057 )
10058 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010059 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070010060 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
10061 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010062 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070010063 __func__);
10064 return -EOPNOTSUPP;
10065 }
10066 else
10067 {
10068 u8 key_len = req->key_len;
10069 u8 key_idx = req->key_idx;
10070
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010071 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070010072 && (CSR_MAX_NUM_KEY > key_idx)
10073 )
10074 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010075 hddLog(VOS_TRACE_LEVEL_INFO,
10076 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010077 __func__, key_idx, key_len);
10078 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010079 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010081 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 (u8)key_len;
10083 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
10084 }
10085 }
10086 }
10087 }
10088
10089 return status;
10090}
10091
10092/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053010093 * FUNCTION: wlan_hdd_try_disconnect
10094 * This function is used to disconnect from previous
10095 * connection
10096 */
10097static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
10098{
10099 long ret = 0;
10100 hdd_station_ctx_t *pHddStaCtx;
10101 eMib_dot11DesiredBssType connectedBssType;
10102
10103 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10104
10105 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
10106
10107 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
10108 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
10109 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
10110 {
10111 /* Issue disconnect to CSR */
10112 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10113 if( eHAL_STATUS_SUCCESS ==
10114 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10115 pAdapter->sessionId,
10116 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
10117 {
10118 ret = wait_for_completion_interruptible_timeout(
10119 &pAdapter->disconnect_comp_var,
10120 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10121 if (0 >= ret)
10122 {
10123 hddLog(LOGE, FL("Failed to receive disconnect event"));
10124 return -EALREADY;
10125 }
10126 }
10127 }
10128 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
10129 {
10130 ret = wait_for_completion_interruptible_timeout(
10131 &pAdapter->disconnect_comp_var,
10132 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
10133 if (0 >= ret)
10134 {
10135 hddLog(LOGE, FL("Failed to receive disconnect event"));
10136 return -EALREADY;
10137 }
10138 }
10139
10140 return 0;
10141}
10142
10143/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053010144 * FUNCTION: __wlan_hdd_cfg80211_connect
10145 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070010146 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010147static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010148 struct net_device *ndev,
10149 struct cfg80211_connect_params *req
10150 )
10151{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010152 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010153 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Sushant Kaushikba6764e2014-06-30 19:52:09 +053010154 hdd_adapter_t *pHostapdAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010155 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053010156 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010157
10158 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010159
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010160 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10161 TRACE_CODE_HDD_CFG80211_CONNECT,
10162 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010163 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010164 "%s: device_mode = %s (%d)", __func__,
10165 hdd_device_modetoString(pAdapter->device_mode),
10166 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010167
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010168 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010169 if (!pHddCtx)
10170 {
10171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10172 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053010173 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080010174 }
10175
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010176 status = wlan_hdd_validate_context(pHddCtx);
10177
10178 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010179 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10181 "%s: HDD context is not valid", __func__);
10182 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010183 }
10184
Agarwal Ashish51325b52014-06-16 16:50:49 +053010185 if (vos_max_concurrent_connections_reached()) {
10186 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10187 return -ECONNREFUSED;
10188 }
10189
Jeff Johnson295189b2012-06-20 16:38:30 -070010190#ifdef WLAN_BTAMP_FEATURE
10191 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010192 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070010193 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010194 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010195 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080010196 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070010197 }
10198#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053010199
10200 //If Device Mode is Station Concurrent Sessions Exit BMps
10201 //P2P Mode will be taken care in Open/close adapter
10202 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053010203 (vos_concurrent_open_sessions_running())) {
10204 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
10205 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053010206 }
10207
10208 /*Try disconnecting if already in connected state*/
10209 status = wlan_hdd_try_disconnect(pAdapter);
10210 if ( 0 > status)
10211 {
10212 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
10213 " connection"));
10214 return -EALREADY;
10215 }
10216
Jeff Johnson295189b2012-06-20 16:38:30 -070010217 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010218 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070010219
10220 if ( 0 > status)
10221 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010222 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 __func__);
10224 return status;
10225 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +053010226 /* For SAP + STA concurrency , driver only supports SCC.
10227 * if SAP is ON, driver will stop it and after assoc completion,
10228 * or failure, SAP will be started on STA channel to force SCC.
10229 */
10230 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
10231 if (pHostapdAdapter != NULL)
10232 {
10233 hddLog(VOS_TRACE_LEVEL_INFO, "Close SAP until STA is connected");
10234 if (test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
10235 {
10236 WLANSAP_StopBss((WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext);
10237 clear_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
10238 }
10239 }
Mohit Khanna765234a2012-09-11 15:08:35 -070010240 if ( req->channel )
10241 {
10242 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
10243 req->ssid_len, req->bssid,
10244 req->channel->hw_value);
10245 }
10246 else
10247 {
10248 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010249 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070010250 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010251
10252 if (0 > status)
10253 {
10254 //ReEnable BMPS if disabled
10255 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
10256 (NULL != pHddCtx))
10257 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053010258 if (pHddCtx->hdd_wlan_suspended)
10259 {
10260 hdd_set_pwrparams(pHddCtx);
10261 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010262 //ReEnable Bmps and Imps back
10263 hdd_enable_bmps_imps(pHddCtx);
10264 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053010265 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010266 return status;
10267 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010268 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010269 EXIT();
10270 return status;
10271}
10272
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010273static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
10274 struct net_device *ndev,
10275 struct cfg80211_connect_params *req)
10276{
10277 int ret;
10278 vos_ssr_protect(__func__);
10279 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
10280 vos_ssr_unprotect(__func__);
10281
10282 return ret;
10283}
Jeff Johnson295189b2012-06-20 16:38:30 -070010284
10285/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010286 * FUNCTION: wlan_hdd_disconnect
10287 * This function is used to issue a disconnect request to SME
10288 */
10289int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
10290{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010291 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010292 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010293 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053010294 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010295
10296 status = wlan_hdd_validate_context(pHddCtx);
10297
10298 if (0 != status)
10299 {
10300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10301 "%s: HDD context is not valid", __func__);
10302 return status;
10303 }
10304
10305 pHddCtx->isAmpAllowed = VOS_TRUE;
Abhishek Singhf4669da2014-05-26 15:07:49 +053010306 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10307 "%s: Set HDD connState to eConnectionState_Disconnecting",
10308 __func__);
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +053010309 pHddStaCtx->conn_info.connState = eConnectionState_Disconnecting;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010310 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010311
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010312 /*issue disconnect*/
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010313
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010314 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
10315 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053010316 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
10317 {
10318 hddLog(VOS_TRACE_LEVEL_INFO,
10319 FL("status = %d, already disconnected"),
10320 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010321
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053010322 }
10323 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010324 {
10325 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010326 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010327 __func__, (int)status );
10328 return -EINVAL;
10329 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053010330 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010331 &pAdapter->disconnect_comp_var,
10332 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053010333 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010334 {
10335 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010336 "%s: Failed to disconnect, timed out", __func__);
10337 return -ETIMEDOUT;
10338 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053010339 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010340 {
10341 hddLog(VOS_TRACE_LEVEL_ERROR,
10342 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053010343 return ret;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010344 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053010345 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10346 FL("Set HDD connState to eConnectionState_NotConnected"));
10347 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
10348
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010349 /*stop tx queues*/
10350 netif_tx_disable(pAdapter->dev);
10351 netif_carrier_off(pAdapter->dev);
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010352 return 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010353}
10354
10355
10356/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010357 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070010358 * This function is used to issue a disconnect request to SME
10359 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010360static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 struct net_device *dev,
10362 u16 reason
10363 )
10364{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010365 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010366 tCsrRoamProfile *pRoamProfile =
10367 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010368 int status;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010369 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10370 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053010371#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080010372 tANI_U8 staIdx;
10373#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010374
Jeff Johnson295189b2012-06-20 16:38:30 -070010375 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010376
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010377 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10378 TRACE_CODE_HDD_CFG80211_DISCONNECT,
10379 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010380 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
10381 __func__, hdd_device_modetoString(pAdapter->device_mode),
10382 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010383
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010384 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
10385 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070010386
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010387 status = wlan_hdd_validate_context(pHddCtx);
10388
10389 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010390 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010391 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10392 "%s: HDD context is not valid", __func__);
10393 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010394 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010395
Jeff Johnson295189b2012-06-20 16:38:30 -070010396 if (NULL != pRoamProfile)
10397 {
10398 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053010399 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
10400 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070010401 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010402 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070010403 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053010404 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 switch(reason)
10406 {
10407 case WLAN_REASON_MIC_FAILURE:
10408 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
10409 break;
10410
10411 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
10412 case WLAN_REASON_DISASSOC_AP_BUSY:
10413 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
10414 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
10415 break;
10416
10417 case WLAN_REASON_PREV_AUTH_NOT_VALID:
10418 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053010419 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070010420 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
10421 break;
10422
Jeff Johnson295189b2012-06-20 16:38:30 -070010423 default:
10424 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
10425 break;
10426 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053010427 pScanInfo = &pHddCtx->scan_info;
10428 if (pScanInfo->mScanPending)
10429 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010430 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053010431 "Aborting Scan");
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010432 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
10433 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053010434 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010435
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080010436#ifdef FEATURE_WLAN_TDLS
10437 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080010438 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080010439 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080010440 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
10441 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080010442 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010443 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080010444 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010445 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010446 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080010447 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010448 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080010449 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -080010450 pAdapter->sessionId,
10451 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080010452 }
10453 }
10454#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010455 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010456 status = wlan_hdd_disconnect(pAdapter, reasonCode);
10457 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070010458 {
10459 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010460 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010461 __func__, (int)status );
10462 return -EINVAL;
10463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010464 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053010465 else
10466 {
10467 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
10468 "called while in %d state", __func__,
10469 pHddStaCtx->conn_info.connState);
10470 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010471 }
10472 else
10473 {
10474 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
10475 }
10476
10477 return status;
10478}
10479
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010480static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
10481 struct net_device *dev,
10482 u16 reason
10483 )
10484{
10485 int ret;
10486 vos_ssr_protect(__func__);
10487 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
10488 vos_ssr_unprotect(__func__);
10489
10490 return ret;
10491}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053010492
Jeff Johnson295189b2012-06-20 16:38:30 -070010493/*
10494 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010495 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070010496 * settings in IBSS mode.
10497 */
10498static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010499 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070010500 struct cfg80211_ibss_params *params
10501 )
10502{
10503 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010504 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010505 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
10506 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010507
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 ENTER();
10509
10510 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070010511 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010512
10513 if (params->ie_len && ( NULL != params->ie) )
10514 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070010515 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
10516 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010517 {
10518 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
10519 encryptionType = eCSR_ENCRYPT_TYPE_AES;
10520 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070010521 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070010522 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010523 tDot11fIEWPA dot11WPAIE;
10524 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070010525 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010526
Wilson Yang00256342013-10-10 23:13:38 -070010527 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070010528 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
10529 params->ie_len, DOT11F_EID_WPA);
10530 if ( NULL != ie )
10531 {
10532 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
10533 // Unpack the WPA IE
10534 //Skip past the EID byte and length byte - and four byte WiFi OUI
10535 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
10536 &ie[2+4],
10537 ie[1] - 4,
10538 &dot11WPAIE);
10539 /*Extract the multicast cipher, the encType for unicast
10540 cipher for wpa-none is none*/
10541 encryptionType =
10542 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
10543 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010544 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070010545
Jeff Johnson295189b2012-06-20 16:38:30 -070010546 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
10547
10548 if (0 > status)
10549 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010550 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 __func__);
10552 return status;
10553 }
10554 }
10555
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010556 pWextState->roamProfile.AuthType.authType[0] =
10557 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 eCSR_AUTH_TYPE_OPEN_SYSTEM;
10559
10560 if (params->privacy)
10561 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010562 /* Security enabled IBSS, At this time there is no information available
10563 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010565 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070010566 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010567 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070010568 *enable privacy bit in beacons */
10569
10570 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
10571 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010572 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
10573 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070010574 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
10575 pWextState->roamProfile.EncryptionType.numEntries = 1;
10576 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070010577 return status;
10578}
10579
10580/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053010581 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010582 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070010583 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053010584static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 struct net_device *dev,
10586 struct cfg80211_ibss_params *params
10587 )
10588{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010589 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070010590 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10591 tCsrRoamProfile *pRoamProfile;
10592 int status;
krunal sonie9002db2013-11-25 14:24:17 -080010593 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010594 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10595 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070010596
10597 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010598
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010599 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10600 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
10601 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010602 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010603 "%s: device_mode = %s (%d)", __func__,
10604 hdd_device_modetoString(pAdapter->device_mode),
10605 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010606
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010607 status = wlan_hdd_validate_context(pHddCtx);
10608
10609 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070010610 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010611 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10612 "%s: HDD context is not valid", __func__);
10613 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010614 }
10615
10616 if (NULL == pWextState)
10617 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010618 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070010619 __func__);
10620 return -EIO;
10621 }
10622
Agarwal Ashish51325b52014-06-16 16:50:49 +053010623 if (vos_max_concurrent_connections_reached()) {
10624 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
10625 return -ECONNREFUSED;
10626 }
10627
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053010628 /*Try disconnecting if already in connected state*/
10629 status = wlan_hdd_try_disconnect(pAdapter);
10630 if ( 0 > status)
10631 {
10632 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
10633 " IBSS connection"));
10634 return -EALREADY;
10635 }
10636
Jeff Johnson295189b2012-06-20 16:38:30 -070010637 pRoamProfile = &pWextState->roamProfile;
10638
10639 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
10640 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010641 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010642 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010643 return -EINVAL;
10644 }
10645
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070010646 /* BSSID is provided by upper layers hence no need to AUTO generate */
10647 if (NULL != params->bssid) {
10648 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
10649 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
10650 hddLog (VOS_TRACE_LEVEL_ERROR,
10651 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
10652 return -EIO;
10653 }
10654 }
krunal sonie9002db2013-11-25 14:24:17 -080010655 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
10656 {
10657 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
10658 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
10659 {
10660 hddLog (VOS_TRACE_LEVEL_ERROR,
10661 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
10662 return -EIO;
10663 }
10664 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
10665 if (!params->bssid)
10666 {
10667 hddLog (VOS_TRACE_LEVEL_ERROR,
10668 "%s:Failed memory allocation", __func__);
10669 return -EIO;
10670 }
10671 vos_mem_copy((v_U8_t *)params->bssid,
10672 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
10673 VOS_MAC_ADDR_SIZE);
10674 alloc_bssid = VOS_TRUE;
10675 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070010676
Jeff Johnson295189b2012-06-20 16:38:30 -070010677 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070010678 if (NULL !=
10679#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
10680 params->chandef.chan)
10681#else
10682 params->channel)
10683#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010684 {
10685 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010686 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
10687 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
10688 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10689 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010690
10691 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010692 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070010693 ieee80211_frequency_to_channel(
10694#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
10695 params->chandef.chan->center_freq);
10696#else
10697 params->channel->center_freq);
10698#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010699
10700 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
10701 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070010702 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010703 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
10704 __func__);
10705 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010706 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010707
10708 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070010709 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010710 if (channelNum == validChan[indx])
10711 {
10712 break;
10713 }
10714 }
10715 if (indx >= numChans)
10716 {
10717 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010718 __func__, channelNum);
10719 return -EINVAL;
10720 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010721 /* Set the Operational Channel */
10722 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
10723 channelNum);
10724 pRoamProfile->ChannelInfo.numOfChannels = 1;
10725 pHddStaCtx->conn_info.operationChannel = channelNum;
10726 pRoamProfile->ChannelInfo.ChannelList =
10727 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070010728 }
10729
10730 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010731 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070010732 if (status < 0)
10733 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010734 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070010735 __func__);
10736 return status;
10737 }
10738
10739 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010740 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010741 params->ssid_len, params->bssid,
10742 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070010743
10744 if (0 > status)
10745 {
10746 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
10747 return status;
10748 }
10749
krunal sonie9002db2013-11-25 14:24:17 -080010750 if (NULL != params->bssid &&
10751 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
10752 alloc_bssid == VOS_TRUE)
10753 {
10754 vos_mem_free(params->bssid);
10755 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010756 return 0;
10757}
10758
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053010759static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
10760 struct net_device *dev,
10761 struct cfg80211_ibss_params *params
10762 )
10763{
10764 int ret = 0;
10765
10766 vos_ssr_protect(__func__);
10767 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
10768 vos_ssr_unprotect(__func__);
10769
10770 return ret;
10771}
10772
Jeff Johnson295189b2012-06-20 16:38:30 -070010773/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053010774 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010775 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070010776 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053010777static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010778 struct net_device *dev
10779 )
10780{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010781 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010782 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10783 tCsrRoamProfile *pRoamProfile;
10784 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010785 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010786
10787 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010788
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010789 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10790 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
10791 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010792 status = wlan_hdd_validate_context(pHddCtx);
10793
10794 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010795 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010796 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10797 "%s: HDD context is not valid", __func__);
10798 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010799 }
10800
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010801 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
10802 hdd_device_modetoString(pAdapter->device_mode),
10803 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010804 if (NULL == pWextState)
10805 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010806 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070010807 __func__);
10808 return -EIO;
10809 }
10810
10811 pRoamProfile = &pWextState->roamProfile;
10812
10813 /* Issue disconnect only if interface type is set to IBSS */
10814 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
10815 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010816 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070010817 __func__);
10818 return -EINVAL;
10819 }
10820
10821 /* Issue Disconnect request */
10822 INIT_COMPLETION(pAdapter->disconnect_comp_var);
10823 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
10824 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
10825
10826 return 0;
10827}
10828
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053010829static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
10830 struct net_device *dev
10831 )
10832{
10833 int ret = 0;
10834
10835 vos_ssr_protect(__func__);
10836 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
10837 vos_ssr_unprotect(__func__);
10838
10839 return ret;
10840}
10841
Jeff Johnson295189b2012-06-20 16:38:30 -070010842/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010843 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070010844 * This function is used to set the phy parameters
10845 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
10846 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010847static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010848 u32 changed)
10849{
10850 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
10851 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010852 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070010853
10854 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010855 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10856 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
10857 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010858 status = wlan_hdd_validate_context(pHddCtx);
10859
10860 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010861 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010862 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10863 "%s: HDD context is not valid", __func__);
10864 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010865 }
10866
Jeff Johnson295189b2012-06-20 16:38:30 -070010867 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
10868 {
10869 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
10870 WNI_CFG_RTS_THRESHOLD_STAMAX :
10871 wiphy->rts_threshold;
10872
10873 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010874 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070010875 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010876 hddLog(VOS_TRACE_LEVEL_ERROR,
10877 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010878 __func__, rts_threshold);
10879 return -EINVAL;
10880 }
10881
10882 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
10883 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010884 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070010885 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010886 hddLog(VOS_TRACE_LEVEL_ERROR,
10887 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010888 __func__, rts_threshold);
10889 return -EIO;
10890 }
10891
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010892 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010893 rts_threshold);
10894 }
10895
10896 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
10897 {
10898 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
10899 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
10900 wiphy->frag_threshold;
10901
10902 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010903 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010904 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010905 hddLog(VOS_TRACE_LEVEL_ERROR,
10906 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070010907 frag_threshold);
10908 return -EINVAL;
10909 }
10910
10911 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
10912 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010913 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070010914 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010915 hddLog(VOS_TRACE_LEVEL_ERROR,
10916 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010917 __func__, frag_threshold);
10918 return -EIO;
10919 }
10920
10921 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
10922 frag_threshold);
10923 }
10924
10925 if ((changed & WIPHY_PARAM_RETRY_SHORT)
10926 || (changed & WIPHY_PARAM_RETRY_LONG))
10927 {
10928 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
10929 wiphy->retry_short :
10930 wiphy->retry_long;
10931
10932 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
10933 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
10934 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010935 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010936 __func__, retry_value);
10937 return -EINVAL;
10938 }
10939
10940 if (changed & WIPHY_PARAM_RETRY_SHORT)
10941 {
10942 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
10943 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010944 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070010945 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010946 hddLog(VOS_TRACE_LEVEL_ERROR,
10947 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010948 __func__, retry_value);
10949 return -EIO;
10950 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010951 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010952 __func__, retry_value);
10953 }
10954 else if (changed & WIPHY_PARAM_RETRY_SHORT)
10955 {
10956 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
10957 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010958 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070010959 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010960 hddLog(VOS_TRACE_LEVEL_ERROR,
10961 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010962 __func__, retry_value);
10963 return -EIO;
10964 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010965 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 __func__, retry_value);
10967 }
10968 }
10969
10970 return 0;
10971}
10972
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010973static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
10974 u32 changed)
10975{
10976 int ret;
10977
10978 vos_ssr_protect(__func__);
10979 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
10980 vos_ssr_unprotect(__func__);
10981
10982 return ret;
10983}
10984
Jeff Johnson295189b2012-06-20 16:38:30 -070010985/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010986 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070010987 * This function is used to set the txpower
10988 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053010989static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070010990#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
10991 struct wireless_dev *wdev,
10992#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010993#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010994 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070010995#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010996 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070010997#endif
10998 int dbm)
10999{
11000 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011001 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070011002 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
11003 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011004 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011005
11006 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011007 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11008 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
11009 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011010 status = wlan_hdd_validate_context(pHddCtx);
11011
11012 if (0 != status)
11013 {
11014 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11015 "%s: HDD context is not valid", __func__);
11016 return status;
11017 }
11018
11019 hHal = pHddCtx->hHal;
11020
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011021 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
11022 dbm, ccmCfgSetCallback,
11023 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011024 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011025 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011026 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
11027 return -EIO;
11028 }
11029
11030 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
11031 dbm);
11032
11033 switch(type)
11034 {
11035 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
11036 /* Fall through */
11037 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
11038 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
11039 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011040 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
11041 __func__);
11042 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070011043 }
11044 break;
11045 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011046 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070011047 __func__);
11048 return -EOPNOTSUPP;
11049 break;
11050 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011051 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
11052 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011053 return -EIO;
11054 }
11055
11056 return 0;
11057}
11058
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053011059static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
11060#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
11061 struct wireless_dev *wdev,
11062#endif
11063#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
11064 enum tx_power_setting type,
11065#else
11066 enum nl80211_tx_power_setting type,
11067#endif
11068 int dbm)
11069{
11070 int ret;
11071 vos_ssr_protect(__func__);
11072 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
11073#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
11074 wdev,
11075#endif
11076#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
11077 type,
11078#else
11079 type,
11080#endif
11081 dbm);
11082 vos_ssr_unprotect(__func__);
11083
11084 return ret;
11085}
11086
Jeff Johnson295189b2012-06-20 16:38:30 -070011087/*
11088 * FUNCTION: wlan_hdd_cfg80211_get_txpower
11089 * This function is used to read the txpower
11090 */
Yue Maf49ba872013-08-19 12:04:25 -070011091static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
11092#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
11093 struct wireless_dev *wdev,
11094#endif
11095 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070011096{
11097
11098 hdd_adapter_t *pAdapter;
11099 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011100 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011101
Jeff Johnsone7245742012-09-05 17:12:55 -070011102 ENTER();
11103
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011104 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070011105
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011106 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011107 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011108 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11109 "%s: HDD context is not valid", __func__);
11110 *dbm = 0;
11111 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011112 }
11113
Jeff Johnson295189b2012-06-20 16:38:30 -070011114 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
11115 if (NULL == pAdapter)
11116 {
11117 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
11118 return -ENOENT;
11119 }
11120
11121 wlan_hdd_get_classAstats(pAdapter);
11122 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
11123
Jeff Johnsone7245742012-09-05 17:12:55 -070011124 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011125 return 0;
11126}
11127
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011128static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070011129 u8* mac, struct station_info *sinfo)
11130{
11131 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
11132 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11133 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053011134 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070011135
11136 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
11137 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070011138
11139 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
11140 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
11141 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
11142 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
11143 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
11144 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
11145 tANI_U16 maxRate = 0;
11146 tANI_U16 myRate;
11147 tANI_U16 currentRate = 0;
11148 tANI_U8 maxSpeedMCS = 0;
11149 tANI_U8 maxMCSIdx = 0;
11150 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053011151 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070011152 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011153 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011154
Leo Chang6f8870f2013-03-26 18:11:36 -070011155#ifdef WLAN_FEATURE_11AC
11156 tANI_U32 vht_mcs_map;
11157 eDataRate11ACMaxMcs vhtMaxMcs;
11158#endif /* WLAN_FEATURE_11AC */
11159
Jeff Johnsone7245742012-09-05 17:12:55 -070011160 ENTER();
11161
Jeff Johnson295189b2012-06-20 16:38:30 -070011162 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
11163 (0 == ssidlen))
11164 {
11165 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
11166 " Invalid ssidlen, %d", __func__, ssidlen);
11167 /*To keep GUI happy*/
11168 return 0;
11169 }
11170
Mukul Sharma811205f2014-07-09 21:07:30 +053011171 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
11172 {
11173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11174 "%s: Roaming in progress, so unable to proceed this request", __func__);
11175 return 0;
11176 }
11177
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011178 status = wlan_hdd_validate_context(pHddCtx);
11179
11180 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011181 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011182 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11183 "%s: HDD context is not valid", __func__);
11184 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011185 }
11186
Jeff Johnson295189b2012-06-20 16:38:30 -070011187
Kiet Lam3b17fc82013-09-27 05:24:08 +053011188 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
11189 sinfo->filled |= STATION_INFO_SIGNAL;
11190
c_hpothu09f19542014-05-30 21:53:31 +053011191 wlan_hdd_get_station_stats(pAdapter);
11192 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
11193
11194 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053011195 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
11196 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053011197 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053011198 {
11199 rate_flags = pAdapter->maxRateFlags;
11200 }
c_hpothu44ff4e02014-05-08 00:13:57 +053011201
Jeff Johnson295189b2012-06-20 16:38:30 -070011202 //convert to the UI units of 100kbps
11203 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
11204
11205#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070011206 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 -070011207 sinfo->signal,
11208 pCfg->reportMaxLinkSpeed,
11209 myRate,
11210 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070011211 (int) pCfg->linkSpeedRssiMid,
11212 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070011213 (int) rate_flags,
11214 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070011215#endif //LINKSPEED_DEBUG_ENABLED
11216
11217 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
11218 {
11219 // we do not want to necessarily report the current speed
11220 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
11221 {
11222 // report the max possible speed
11223 rssidx = 0;
11224 }
11225 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
11226 {
11227 // report the max possible speed with RSSI scaling
11228 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
11229 {
11230 // report the max possible speed
11231 rssidx = 0;
11232 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070011233 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070011234 {
11235 // report middle speed
11236 rssidx = 1;
11237 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070011238 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
11239 {
11240 // report middle speed
11241 rssidx = 2;
11242 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011243 else
11244 {
11245 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070011246 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070011247 }
11248 }
11249 else
11250 {
11251 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
11252 hddLog(VOS_TRACE_LEVEL_ERROR,
11253 "%s: Invalid value for reportMaxLinkSpeed: %u",
11254 __func__, pCfg->reportMaxLinkSpeed);
11255 rssidx = 0;
11256 }
11257
11258 maxRate = 0;
11259
11260 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053011261 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
11262 OperationalRates, &ORLeng))
11263 {
11264 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
11265 /*To keep GUI happy*/
11266 return 0;
11267 }
11268
Jeff Johnson295189b2012-06-20 16:38:30 -070011269 for (i = 0; i < ORLeng; i++)
11270 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011271 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070011272 {
11273 /* Validate Rate Set */
11274 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
11275 {
11276 currentRate = supported_data_rate[j].supported_rate[rssidx];
11277 break;
11278 }
11279 }
11280 /* Update MAX rate */
11281 maxRate = (currentRate > maxRate)?currentRate:maxRate;
11282 }
11283
11284 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053011285 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
11286 ExtendedRates, &ERLeng))
11287 {
11288 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
11289 /*To keep GUI happy*/
11290 return 0;
11291 }
11292
Jeff Johnson295189b2012-06-20 16:38:30 -070011293 for (i = 0; i < ERLeng; i++)
11294 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011295 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070011296 {
11297 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
11298 {
11299 currentRate = supported_data_rate[j].supported_rate[rssidx];
11300 break;
11301 }
11302 }
11303 /* Update MAX rate */
11304 maxRate = (currentRate > maxRate)?currentRate:maxRate;
11305 }
c_hpothu79aab322014-07-14 21:11:01 +053011306
Kiet Lamb69f8dc2013-11-15 15:34:27 +053011307 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053011308 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053011309 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053011310 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070011311 {
c_hpothu79aab322014-07-14 21:11:01 +053011312 if (rate_flags & eHAL_TX_RATE_VHT80)
11313 mode = 2;
11314 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
11315 mode = 1;
11316 else
11317 mode = 0;
11318
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053011319 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
11320 MCSRates, &MCSLeng))
11321 {
11322 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
11323 /*To keep GUI happy*/
11324 return 0;
11325 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011326 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070011327#ifdef WLAN_FEATURE_11AC
11328 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053011329 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070011330 {
Leo Chang6f8870f2013-03-26 18:11:36 -070011331 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053011332 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070011333 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070011334 {
Leo Chang6f8870f2013-03-26 18:11:36 -070011335 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011336 }
Leo Chang6f8870f2013-03-26 18:11:36 -070011337 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070011338 {
Leo Chang6f8870f2013-03-26 18:11:36 -070011339 maxMCSIdx = 7;
11340 }
11341 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
11342 {
11343 maxMCSIdx = 8;
11344 }
11345 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
11346 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053011347 //VHT20 is supporting 0~8
11348 if (rate_flags & eHAL_TX_RATE_VHT20)
11349 maxMCSIdx = 8;
11350 else
11351 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070011352 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053011353
c_hpothu79aab322014-07-14 21:11:01 +053011354 if (0 != rssidx)/*check for scaled */
11355 {
11356 //get middle rate MCS index if rssi=1/2
11357 for (i=0; i <= maxMCSIdx; i++)
11358 {
11359 if (sinfo->signal <= rssiMcsTbl[mode][i])
11360 {
11361 maxMCSIdx = i;
11362 break;
11363 }
11364 }
11365 }
11366
Gopichand Nakkala4c705372013-04-24 13:20:33 +053011367 if (rate_flags & eHAL_TX_RATE_VHT80)
11368 {
11369 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
11370 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
11371 }
11372 else if (rate_flags & eHAL_TX_RATE_VHT40)
11373 {
11374 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
11375 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
11376 }
11377 else if (rate_flags & eHAL_TX_RATE_VHT20)
11378 {
11379 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
11380 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
11381 }
11382
Leo Chang6f8870f2013-03-26 18:11:36 -070011383 maxSpeedMCS = 1;
11384 if (currentRate > maxRate)
11385 {
11386 maxRate = currentRate;
11387 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053011388
Leo Chang6f8870f2013-03-26 18:11:36 -070011389 }
11390 else
11391#endif /* WLAN_FEATURE_11AC */
11392 {
11393 if (rate_flags & eHAL_TX_RATE_HT40)
11394 {
11395 rateFlag |= 1;
11396 }
11397 if (rate_flags & eHAL_TX_RATE_SGI)
11398 {
11399 rateFlag |= 2;
11400 }
11401
c_hpothu79aab322014-07-14 21:11:01 +053011402 if (rssidx == 1 || rssidx == 2)
11403 {
11404 //get middle rate MCS index if rssi=1/2
11405 for (i=0; i <= 7; i++)
11406 {
11407 if (sinfo->signal <= rssiMcsTbl[mode][i])
11408 {
11409 temp = i+1;
11410 break;
11411 }
11412 }
11413 }
11414 else
Leo Chang6f8870f2013-03-26 18:11:36 -070011415 {
11416 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053011417 }
11418
11419 for (i = 0; i < MCSLeng; i++)
11420 {
Leo Chang6f8870f2013-03-26 18:11:36 -070011421 for (j = 0; j < temp; j++)
11422 {
11423 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
11424 {
11425 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
11426 break;
11427 }
11428 }
11429 if ((j < temp) && (currentRate > maxRate))
11430 {
11431 maxRate = currentRate;
11432 maxSpeedMCS = 1;
11433 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
11434 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011435 }
11436 }
11437 }
11438
Gopichand Nakkala4c705372013-04-24 13:20:33 +053011439 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
11440 {
11441 maxRate = myRate;
11442 maxSpeedMCS = 1;
11443 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
11444 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053011446 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070011447 {
11448 maxRate = myRate;
11449 if (rate_flags & eHAL_TX_RATE_LEGACY)
11450 {
11451 maxSpeedMCS = 0;
11452 }
11453 else
11454 {
11455 maxSpeedMCS = 1;
11456 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
11457 }
11458 }
11459
Gopichand Nakkala4c705372013-04-24 13:20:33 +053011460 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070011461 {
11462 sinfo->txrate.legacy = maxRate;
11463#ifdef LINKSPEED_DEBUG_ENABLED
11464 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
11465#endif //LINKSPEED_DEBUG_ENABLED
11466 }
11467 else
11468 {
11469 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070011470#ifdef WLAN_FEATURE_11AC
11471 sinfo->txrate.nss = 1;
11472 if (rate_flags & eHAL_TX_RATE_VHT80)
11473 {
11474 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053011475 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070011476 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053011477 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070011478 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053011479 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
11480 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
11481 }
11482 else if (rate_flags & eHAL_TX_RATE_VHT20)
11483 {
11484 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
11485 }
11486#endif /* WLAN_FEATURE_11AC */
11487 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
11488 {
11489 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
11490 if (rate_flags & eHAL_TX_RATE_HT40)
11491 {
11492 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
11493 }
Leo Chang6f8870f2013-03-26 18:11:36 -070011494 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011495 if (rate_flags & eHAL_TX_RATE_SGI)
11496 {
11497 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
11498 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053011499
Jeff Johnson295189b2012-06-20 16:38:30 -070011500#ifdef LINKSPEED_DEBUG_ENABLED
11501 pr_info("Reporting MCS rate %d flags %x\n",
11502 sinfo->txrate.mcs,
11503 sinfo->txrate.flags );
11504#endif //LINKSPEED_DEBUG_ENABLED
11505 }
11506 }
11507 else
11508 {
11509 // report current rate instead of max rate
11510
11511 if (rate_flags & eHAL_TX_RATE_LEGACY)
11512 {
11513 //provide to the UI in units of 100kbps
11514 sinfo->txrate.legacy = myRate;
11515#ifdef LINKSPEED_DEBUG_ENABLED
11516 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
11517#endif //LINKSPEED_DEBUG_ENABLED
11518 }
11519 else
11520 {
11521 //must be MCS
11522 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070011523#ifdef WLAN_FEATURE_11AC
11524 sinfo->txrate.nss = 1;
11525 if (rate_flags & eHAL_TX_RATE_VHT80)
11526 {
11527 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
11528 }
11529 else
11530#endif /* WLAN_FEATURE_11AC */
11531 {
11532 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
11533 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011534 if (rate_flags & eHAL_TX_RATE_SGI)
11535 {
11536 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
11537 }
11538 if (rate_flags & eHAL_TX_RATE_HT40)
11539 {
11540 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
11541 }
Leo Chang6f8870f2013-03-26 18:11:36 -070011542#ifdef WLAN_FEATURE_11AC
11543 else if (rate_flags & eHAL_TX_RATE_VHT80)
11544 {
11545 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
11546 }
11547#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070011548#ifdef LINKSPEED_DEBUG_ENABLED
11549 pr_info("Reporting actual MCS rate %d flags %x\n",
11550 sinfo->txrate.mcs,
11551 sinfo->txrate.flags );
11552#endif //LINKSPEED_DEBUG_ENABLED
11553 }
11554 }
11555 sinfo->filled |= STATION_INFO_TX_BITRATE;
11556
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070011557 sinfo->tx_packets =
11558 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
11559 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
11560 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
11561 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
11562
11563 sinfo->tx_retries =
11564 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
11565 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
11566 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
11567 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
11568
11569 sinfo->tx_failed =
11570 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
11571 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
11572 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
11573 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
11574
11575 sinfo->filled |=
11576 STATION_INFO_TX_PACKETS |
11577 STATION_INFO_TX_RETRIES |
11578 STATION_INFO_TX_FAILED;
11579
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011580 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11581 TRACE_CODE_HDD_CFG80211_GET_STA,
11582 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070011583 EXIT();
11584 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070011585}
11586
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011587static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
11588 u8* mac, struct station_info *sinfo)
11589{
11590 int ret;
11591
11592 vos_ssr_protect(__func__);
11593 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
11594 vos_ssr_unprotect(__func__);
11595
11596 return ret;
11597}
11598
11599static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070011600 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070011601{
11602 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053011603 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011604 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011605 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011606
Jeff Johnsone7245742012-09-05 17:12:55 -070011607 ENTER();
11608
Jeff Johnson295189b2012-06-20 16:38:30 -070011609 if (NULL == pAdapter)
11610 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011611 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 return -ENODEV;
11613 }
11614
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011615 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11616 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
11617 pAdapter->sessionId, timeout));
11618
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053011619 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011620 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053011621
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011622 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011623 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011624 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11625 "%s: HDD context is not valid", __func__);
11626 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011627 }
11628
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053011629 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
11630 (TRUE == pHddCtx->hdd_wlan_suspended) &&
11631 (pHddCtx->cfg_ini->fhostArpOffload) &&
11632 (eConnectionState_Associated ==
11633 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
11634 {
Amar Singhald53568e2013-09-26 11:03:45 -070011635
11636 hddLog(VOS_TRACE_LEVEL_INFO,
11637 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053011638 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053011639 if (!VOS_IS_STATUS_SUCCESS(vos_status))
11640 {
11641 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080011642 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053011643 __func__, vos_status);
11644 }
11645 }
11646
Jeff Johnson295189b2012-06-20 16:38:30 -070011647 /**The get power cmd from the supplicant gets updated by the nl only
11648 *on successful execution of the function call
11649 *we are oppositely mapped w.r.t mode in the driver
11650 **/
11651 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
11652
Jeff Johnsone7245742012-09-05 17:12:55 -070011653 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011654 if (VOS_STATUS_E_FAILURE == vos_status)
11655 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011656 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11657 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011658 return -EINVAL;
11659 }
11660 return 0;
11661}
11662
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011663static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
11664 struct net_device *dev, bool mode, int timeout)
11665{
11666 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070011667
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011668 vos_ssr_protect(__func__);
11669 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
11670 vos_ssr_unprotect(__func__);
11671
11672 return ret;
11673}
Jeff Johnson295189b2012-06-20 16:38:30 -070011674#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11675static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
11676 struct net_device *netdev,
11677 u8 key_index)
11678{
Jeff Johnsone7245742012-09-05 17:12:55 -070011679 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070011680 return 0;
11681}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011682#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070011683
11684#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
11685static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
11686 struct net_device *dev,
11687 struct ieee80211_txq_params *params)
11688{
Jeff Johnsone7245742012-09-05 17:12:55 -070011689 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070011690 return 0;
11691}
11692#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11693static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
11694 struct ieee80211_txq_params *params)
11695{
Jeff Johnsone7245742012-09-05 17:12:55 -070011696 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 return 0;
11698}
11699#endif //LINUX_VERSION_CODE
11700
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011701static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070011702 struct net_device *dev, u8 *mac)
11703{
11704 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011705 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011706 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011707 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011708 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011709
Jeff Johnsone7245742012-09-05 17:12:55 -070011710 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011711
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011712 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070011713 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011714 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011715 return -EINVAL;
11716 }
11717
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011718 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11719 TRACE_CODE_HDD_CFG80211_DEL_STA,
11720 pAdapter->sessionId, pAdapter->device_mode));
11721
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011722 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11723 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -070011724
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011725 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011726 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011727 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11728 "%s: HDD context is not valid", __func__);
11729 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011730 }
11731
Jeff Johnson295189b2012-06-20 16:38:30 -070011732 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070011733 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070011734 )
11735 {
11736 if( NULL == mac )
11737 {
11738 v_U16_t i;
11739 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
11740 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070011741 if ((pAdapter->aStaInfo[i].isUsed) &&
11742 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070011743 {
11744 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
11745 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080011746 "%s: Delete STA with MAC::"
11747 MAC_ADDRESS_STR,
11748 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070011749 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
11750 if (VOS_IS_STATUS_SUCCESS(vos_status))
11751 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011752 }
11753 }
11754 }
11755 else
11756 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011757
11758 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
11759 if (!VOS_IS_STATUS_SUCCESS(vos_status))
11760 {
11761 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080011762 "%s: Skip this DEL STA as this is not used::"
11763 MAC_ADDRESS_STR,
11764 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011765 return -ENOENT;
11766 }
11767
11768 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
11769 {
11770 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080011771 "%s: Skip this DEL STA as deauth is in progress::"
11772 MAC_ADDRESS_STR,
11773 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011774 return -ENOENT;
11775 }
11776
11777 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
11778
Jeff Johnson295189b2012-06-20 16:38:30 -070011779 hddLog(VOS_TRACE_LEVEL_INFO,
11780 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080011781 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011782 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -080011783 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011784
11785 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
11786 if (!VOS_IS_STATUS_SUCCESS(vos_status))
11787 {
11788 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
11789 hddLog(VOS_TRACE_LEVEL_INFO,
11790 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080011791 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011792 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -080011793 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011794 return -ENOENT;
11795 }
11796
Jeff Johnson295189b2012-06-20 16:38:30 -070011797 }
11798 }
11799
11800 EXIT();
11801
11802 return 0;
11803}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011804static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
11805 struct net_device *dev, u8 *mac)
11806{
11807 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070011808
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011809 vos_ssr_protect(__func__);
11810 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, mac);
11811 vos_ssr_unprotect(__func__);
11812
11813 return ret;
11814}
11815
11816static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080011817 struct net_device *dev, u8 *mac, struct station_parameters *params)
11818{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011819 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalab977a972013-02-18 19:15:09 -080011820 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080011821#ifdef FEATURE_WLAN_TDLS
11822 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080011823 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053011824
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011825 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11826 TRACE_CODE_HDD_CFG80211_ADD_STA,
11827 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011828 mask = params->sta_flags_mask;
11829
11830 set = params->sta_flags_set;
11831
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070011832#ifdef WLAN_FEATURE_TDLS_DEBUG
11833 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11834 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
11835 __func__, mask, set, MAC_ADDR_ARRAY(mac));
11836#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011837
11838 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
11839 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080011840 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011841 }
11842 }
11843#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -080011844 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070011845}
11846
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011847static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
11848 struct net_device *dev, u8 *mac, struct station_parameters *params)
11849{
11850 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011851
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053011852 vos_ssr_protect(__func__);
11853 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
11854 vos_ssr_unprotect(__func__);
11855
11856 return ret;
11857}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011858#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070011859
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053011860static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070011861 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011862{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011863 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011864 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Agarwal Ashish3da95242014-05-21 14:57:17 +053011865 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011866 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011867 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011868 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011869 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011870 hdd_context_t *pHddCtx;
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011871 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
11872 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070011873
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011874 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011875 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011876 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011877 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011878 return -EINVAL;
11879 }
11880
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011881 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11882 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011883
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011884 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011885 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053011886 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11887 "%s: HDD context is not valid", __func__);
11888 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011889 }
11890
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011891 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011892 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Agarwal Ashish3da95242014-05-21 14:57:17 +053011893 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011894
Agarwal Ashish3da95242014-05-21 14:57:17 +053011895 for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011896 {
Agarwal Ashish3da95242014-05-21 14:57:17 +053011897 if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011898 pmksa->bssid, WNI_CFG_BSSID_LEN))
11899 {
11900 /* BSSID matched previous entry. Overwrite it. */
11901 BSSIDMatched = 1;
Agarwal Ashish3da95242014-05-21 14:57:17 +053011902 vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011903 pmksa->bssid, WNI_CFG_BSSID_LEN);
Agarwal Ashish3da95242014-05-21 14:57:17 +053011904 vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011905 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011906 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011907 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011908 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011909 dump_bssid(pmksa->bssid);
11910 dump_pmkid(halHandle, pmksa->pmkid);
11911 break;
11912 }
11913 }
11914
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -070011915 /* Check we compared all entries,if then take the first slot now */
Agarwal Ashish3da95242014-05-21 14:57:17 +053011916 if (j == MAX_PMKSAIDS_IN_CACHE) pHddStaCtx->PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -070011917
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011918 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011919 {
11920 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Agarwal Ashish3da95242014-05-21 14:57:17 +053011921 vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011922 pmksa->bssid, ETHER_ADDR_LEN);
Agarwal Ashish3da95242014-05-21 14:57:17 +053011923 vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011924 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011925 CSR_RSN_PMKID_SIZE);
Agarwal Ashish3da95242014-05-21 14:57:17 +053011926 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Adding a new cache entry %d.",
11927 __func__, pHddStaCtx->PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011928 dump_bssid(pmksa->bssid);
11929 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011930 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011931 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Agarwal Ashish3da95242014-05-21 14:57:17 +053011932 if (pHddStaCtx->PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1))
11933 pHddStaCtx->PMKIDCacheIndex++;
11934 else
11935 pHddStaCtx->PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011936 }
11937
11938
11939 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Agarwal Ashish3da95242014-05-21 14:57:17 +053011940 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
11941 __func__, pHddStaCtx->PMKIDCacheIndex );
11942
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011943 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011944 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Agarwal Ashish3da95242014-05-21 14:57:17 +053011945 pHddStaCtx->PMKIDCache,
11946 pHddStaCtx->PMKIDCacheIndex);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053011947 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
11948 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
11949 pAdapter->sessionId, result));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011950 return 0;
11951}
11952
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053011953static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
11954 struct cfg80211_pmksa *pmksa)
11955{
11956 int ret;
11957
11958 vos_ssr_protect(__func__);
11959 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
11960 vos_ssr_unprotect(__func__);
11961
11962 return ret;
11963}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011964
Wilson Yang6507c4e2013-10-01 20:11:19 -070011965
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053011966static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070011967 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011968{
Wilson Yang6507c4e2013-10-01 20:11:19 -070011969 tANI_U32 j=0;
11970 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Agarwal Ashish3da95242014-05-21 14:57:17 +053011971 hdd_station_ctx_t *pHddStaCtx;
Wilson Yang6507c4e2013-10-01 20:11:19 -070011972 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070011973 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070011974 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080011975 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070011976
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011977 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
11978 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -070011979
11980 /* Validate pAdapter */
11981 if (NULL == pAdapter)
11982 {
11983 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
11984 return -EINVAL;
11985 }
11986
11987 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11988 status = wlan_hdd_validate_context(pHddCtx);
11989
11990 if (0 != status)
11991 {
11992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11993 "%s: HDD context is not valid", __func__);
11994 return status;
11995 }
11996
11997 /*Retrieve halHandle*/
11998 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Agarwal Ashish3da95242014-05-21 14:57:17 +053011999 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Wilson Yang6507c4e2013-10-01 20:11:19 -070012000
12001 /*in case index is 0,no entry to delete*/
Agarwal Ashish3da95242014-05-21 14:57:17 +053012002 if (0 == pHddStaCtx->PMKIDCacheIndex)
Wilson Yang6507c4e2013-10-01 20:11:19 -070012003 {
Agarwal Ashish3da95242014-05-21 14:57:17 +053012004 hddLog(VOS_TRACE_LEVEL_INFO, FL("No entries to flush"));
12005 return 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012006 }
12007
12008 /*find the matching PMKSA entry from j=0 to (index-1),
12009 * and delete the matched one
12010 */
Agarwal Ashish3da95242014-05-21 14:57:17 +053012011 for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
Wilson Yang6507c4e2013-10-01 20:11:19 -070012012 {
Agarwal Ashish3da95242014-05-21 14:57:17 +053012013 if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID,
Wilson Yang6507c4e2013-10-01 20:11:19 -070012014 pmksa->bssid,
12015 WNI_CFG_BSSID_LEN))
12016 {
12017 /* BSSID matched entry */
12018 BSSIDMatched = 1;
Agarwal Ashish3da95242014-05-21 14:57:17 +053012019 if (j < pHddStaCtx->PMKIDCacheIndex-1)
Wilson Yang6507c4e2013-10-01 20:11:19 -070012020 {
12021 /*replace the matching entry with the last entry in HDD local cache*/
Agarwal Ashish3da95242014-05-21 14:57:17 +053012022 vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID,
12023 pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID,
12024 VOS_MAC_ADDR_SIZE);
12025 vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID,
12026 pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID,
12027 CSR_RSN_PMKID_SIZE);
12028 }
Wilson Yang6507c4e2013-10-01 20:11:19 -070012029
12030 /*clear the last entry in HDD cache ---[index-1]*/
Agarwal Ashish3da95242014-05-21 14:57:17 +053012031 vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID,
12032 VOS_MAC_ADDR_SIZE);
12033 vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID,
12034 CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -070012035 /*reduce the PMKID array index*/
Agarwal Ashish3da95242014-05-21 14:57:17 +053012036 pHddStaCtx->PMKIDCacheIndex--;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012037 /*delete the last PMKID cache in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -080012038 if (eHAL_STATUS_SUCCESS !=
12039 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid))
Wilson Yang6507c4e2013-10-01 20:11:19 -070012040 {
12041 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
Agarwal Ashish3da95242014-05-21 14:57:17 +053012042 __func__, pHddStaCtx->PMKIDCacheIndex);
Wilson Yangef657d32014-01-15 19:19:23 -080012043 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012044 }
12045
12046 dump_bssid(pmksa->bssid);
12047 dump_pmkid(halHandle,pmksa->pmkid);
12048
12049 break;
12050 }
12051 }
12052
12053 /* we compare all entries,but cannot find matching entry */
12054 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
12055 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012056 hddLog(VOS_TRACE_LEVEL_FATAL,
12057 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
12058 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -070012059 dump_bssid(pmksa->bssid);
12060 dump_pmkid(halHandle, pmksa->pmkid);
12061 return -EINVAL;
12062 }
Wilson Yangef657d32014-01-15 19:19:23 -080012063 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012064}
12065
Wilson Yang6507c4e2013-10-01 20:11:19 -070012066
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012067static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
12068 struct cfg80211_pmksa *pmksa)
12069{
12070 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012071
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012072 vos_ssr_protect(__func__);
12073 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
12074 vos_ssr_unprotect(__func__);
12075
12076 return ret;
12077
12078}
12079
12080static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012081{
Wilson Yang6507c4e2013-10-01 20:11:19 -070012082 tANI_U32 j=0;
12083 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Agarwal Ashish3da95242014-05-21 14:57:17 +053012084 hdd_station_ctx_t *pHddStaCtx;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012085 tHalHandle halHandle;
12086 hdd_context_t *pHddCtx;
12087 tANI_U8 *pBSSId;
Wilson Yangef657d32014-01-15 19:19:23 -080012088 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012089
12090 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
12091
12092 /* Validate pAdapter */
12093 if (NULL == pAdapter)
12094 {
12095 hddLog(VOS_TRACE_LEVEL_ERROR,
12096 "%s: Invalid Adapter" ,__func__);
12097 return -EINVAL;
12098 }
12099
12100 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12101 status = wlan_hdd_validate_context(pHddCtx);
12102
12103 if (0 != status)
12104 {
12105 hddLog(VOS_TRACE_LEVEL_ERROR,
12106 "%s: HDD context is not valid", __func__);
12107 return status;
12108 }
12109
12110 /*Retrieve halHandle*/
12111 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Agarwal Ashish3da95242014-05-21 14:57:17 +053012112 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Wilson Yang6507c4e2013-10-01 20:11:19 -070012113
12114 /*in case index is 0,no entry to delete*/
Agarwal Ashish3da95242014-05-21 14:57:17 +053012115 if (0 == pHddStaCtx->PMKIDCacheIndex)
Wilson Yang6507c4e2013-10-01 20:11:19 -070012116 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053012117 hddLog(VOS_TRACE_LEVEL_ERROR, FL("No entries to flush"));
Agarwal Ashish3da95242014-05-21 14:57:17 +053012118 return 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012119 }
12120
12121 /*delete all the PMKSA one by one */
Agarwal Ashish3da95242014-05-21 14:57:17 +053012122 for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
Wilson Yang6507c4e2013-10-01 20:11:19 -070012123 {
Agarwal Ashish3da95242014-05-21 14:57:17 +053012124 pBSSId =(tANI_U8 *)(pHddStaCtx->PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -070012125 /*delete the PMKID in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -080012126 if (eHAL_STATUS_SUCCESS !=
12127 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId))
Wilson Yang6507c4e2013-10-01 20:11:19 -070012128 {
12129 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
12130 __func__,j);
Wilson Yangef657d32014-01-15 19:19:23 -080012131 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070012132 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +053012133 /*clear the entry in HDD cache 0--index-1 */
Agarwal Ashish3da95242014-05-21 14:57:17 +053012134 vos_mem_zero(pHddStaCtx->PMKIDCache[j].BSSID, VOS_MAC_ADDR_SIZE);
12135 vos_mem_zero(pHddStaCtx->PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
12136 }
Wilson Yang6507c4e2013-10-01 20:11:19 -070012137
Agarwal Ashish3da95242014-05-21 14:57:17 +053012138 pHddStaCtx->PMKIDCacheIndex = 0;
Wilson Yangef657d32014-01-15 19:19:23 -080012139 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012140}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053012141
12142static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
12143{
12144 int ret;
12145
12146 vos_ssr_protect(__func__);
12147 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
12148 vos_ssr_unprotect(__func__);
12149
12150 return ret;
12151}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012152#endif
12153
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012154#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012155static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
12156 struct net_device *dev,
12157 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012158{
12159 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12160 hdd_station_ctx_t *pHddStaCtx;
12161
12162 if (NULL == pAdapter)
12163 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012164 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012165 return -ENODEV;
12166 }
12167
12168 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12169
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012170 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12171 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
12172 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012173 // Added for debug on reception of Re-assoc Req.
12174 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
12175 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012176 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012177 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080012178 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012179 }
12180
12181#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080012182 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012183 ftie->ie_len);
12184#endif
12185
12186 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053012187 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12188 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012189 ftie->ie_len);
12190 return 0;
12191}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012192
12193static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
12194 struct net_device *dev,
12195 struct cfg80211_update_ft_ies_params *ftie)
12196{
12197 int ret;
12198
12199 vos_ssr_protect(__func__);
12200 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
12201 vos_ssr_unprotect(__func__);
12202
12203 return ret;
12204}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070012205#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012206
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012207#ifdef FEATURE_WLAN_SCAN_PNO
12208
12209void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
12210 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
12211{
12212 int ret;
12213 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
12214 hdd_context_t *pHddCtx;
12215
Nirav Shah80830bf2013-12-31 16:35:12 +053012216 ENTER();
12217
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012218 if (NULL == pAdapter)
12219 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053012220 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012221 "%s: HDD adapter is Null", __func__);
12222 return ;
12223 }
12224
12225 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12226 if (NULL == pHddCtx)
12227 {
12228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12229 "%s: HDD context is Null!!!", __func__);
12230 return ;
12231 }
12232
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012233 spin_lock(&pHddCtx->schedScan_lock);
12234 if (TRUE == pHddCtx->isWiphySuspended)
12235 {
12236 pHddCtx->isSchedScanUpdatePending = TRUE;
12237 spin_unlock(&pHddCtx->schedScan_lock);
12238 hddLog(VOS_TRACE_LEVEL_INFO,
12239 "%s: Update cfg80211 scan database after it resume", __func__);
12240 return ;
12241 }
12242 spin_unlock(&pHddCtx->schedScan_lock);
12243
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012244 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
12245
12246 if (0 > ret)
12247 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
12248
12249 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012250 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12251 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012252}
12253
12254/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012255 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053012256 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012257 */
12258static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
12259{
12260 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
12261 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012262 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012263 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12264 int status = 0;
12265 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
12266
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053012267 /* The current firmware design does not allow PNO during any
12268 * active sessions. Hence, determine the active sessions
12269 * and return a failure.
12270 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012271 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
12272 {
12273 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012274 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012275
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012276 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
12277 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
12278 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
12279 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
12280 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
12281 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012282 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012283 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012284 }
12285 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
12286 pAdapterNode = pNext;
12287 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012288 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012289}
12290
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012291void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
12292{
12293 hdd_adapter_t *pAdapter = callbackContext;
12294 hdd_context_t *pHddCtx;
12295
12296 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
12297 {
12298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12299 FL("Invalid adapter or adapter has invalid magic"));
12300 return;
12301 }
12302
12303 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12304 if (0 != wlan_hdd_validate_context(pHddCtx))
12305 {
12306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12307 FL("HDD context is not valid"));
12308 return;
12309 }
12310
12311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12312 FL("PNO enable response status = %d"), status);
12313
12314 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
12315 complete(&pAdapter->pno_comp_var);
12316}
12317
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012318/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053012319 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
12320 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012321 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053012322static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012323 struct net_device *dev, struct cfg80211_sched_scan_request *request)
12324{
12325 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12326 tpSirPNOScanReq pPnoRequest = NULL;
12327 hdd_context_t *pHddCtx;
12328 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053012329 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053012330 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
12331 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012332 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12333 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012334 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012335
12336 if (NULL == pAdapter)
12337 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012338 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012339 "%s: HDD adapter is Null", __func__);
12340 return -ENODEV;
12341 }
12342
12343 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012344 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012345
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012346 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012347 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053012348 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12349 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012350 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012351 }
12352
12353 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12354 if (NULL == hHal)
12355 {
12356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12357 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012358 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012359 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012360
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053012361 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053012362 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053012363 {
12364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12365 "%s: aborting the existing scan is unsuccessfull", __func__);
12366 return -EBUSY;
12367 }
12368
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012369 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012370 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053012371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053012372 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053012373 return -EBUSY;
12374 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012375
c_hpothu37f21312014-04-09 21:49:54 +053012376 if (TRUE == pHddCtx->isPnoEnable)
12377 {
12378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
12379 FL("already PNO is enabled"));
12380 return -EBUSY;
12381 }
12382 pHddCtx->isPnoEnable = TRUE;
12383
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012384 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
12385 if (NULL == pPnoRequest)
12386 {
12387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
12388 "%s: vos_mem_malloc failed", __func__);
c_hpothu37f21312014-04-09 21:49:54 +053012389 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012390 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012391 }
12392
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +053012393 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012394 pPnoRequest->enable = 1; /*Enable PNO */
12395 pPnoRequest->ucNetworksCount = request->n_match_sets;
12396
12397 if (( !pPnoRequest->ucNetworksCount ) ||
12398 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
12399 {
12400 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053012401 "%s: Network input is not correct %d Max Network supported is %d",
12402 __func__, pPnoRequest->ucNetworksCount,
12403 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012404 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012405 goto error;
12406 }
12407
12408 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
12409 {
12410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053012411 "%s: Incorrect number of channels %d",
12412 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012413 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012414 goto error;
12415 }
12416
12417 /* Framework provides one set of channels(all)
12418 * common for all saved profile */
12419 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12420 channels_allowed, &num_channels_allowed))
12421 {
12422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12423 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012424 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012425 goto error;
12426 }
12427 /* Checking each channel against allowed channel list */
12428 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053012429 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012430 {
Nirav Shah80830bf2013-12-31 16:35:12 +053012431 char chList [(request->n_channels*5)+1];
12432 int len;
12433 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012434 {
Nirav Shah80830bf2013-12-31 16:35:12 +053012435 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012436 {
Nirav Shah80830bf2013-12-31 16:35:12 +053012437 if (request->channels[i]->hw_value == channels_allowed[indx])
12438 {
12439 valid_ch[num_ch++] = request->channels[i]->hw_value;
12440 len += snprintf(chList+len, 5, "%d ",
12441 request->channels[i]->hw_value);
12442 break ;
12443 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012444 }
12445 }
Nirav Shah80830bf2013-12-31 16:35:12 +053012446 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
12447 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012448
12449 /* Filling per profile params */
12450 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
12451 {
12452 pPnoRequest->aNetworks[i].ssId.length =
12453 request->match_sets[i].ssid.ssid_len;
12454
12455 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
12456 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
12457 {
12458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053012459 "%s: SSID Len %d is not correct for network %d",
12460 __func__, pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012461 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012462 goto error;
12463 }
12464
12465 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
12466 request->match_sets[i].ssid.ssid,
12467 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053012468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12469 "%s: SSID of network %d is %s ", __func__,
12470 i, pPnoRequest->aNetworks[i].ssId.ssId);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012471 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
12472 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
12473 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
12474
12475 /*Copying list of valid channel into request */
12476 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
12477 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
12478
12479 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
12480 }
12481
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053012482 for (i = 0; i < request->n_ssids; i++)
12483 {
12484 j = 0;
12485 while (j < pPnoRequest->ucNetworksCount)
12486 {
12487 if ((pPnoRequest->aNetworks[j].ssId.length ==
12488 request->ssids[i].ssid_len) &&
12489 (0 == memcmp(pPnoRequest->aNetworks[j].ssId.ssId,
12490 request->ssids[i].ssid,
12491 pPnoRequest->aNetworks[j].ssId.length)))
12492 {
12493 pPnoRequest->aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
12494 break;
12495 }
12496 j++;
12497 }
12498 }
12499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12500 "Number of hidden networks being Configured = %d",
12501 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053012502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080012503 "request->ie_len = %zu", request->ie_len);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053012504 if ((0 < request->ie_len) && (NULL != request->ie))
12505 {
12506 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
12507 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
12508 pPnoRequest->us24GProbeTemplateLen);
12509
12510 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
12511 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
12512 pPnoRequest->us5GProbeTemplateLen);
12513 }
12514
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053012515 /* Driver gets only one time interval which is hardcoded in
12516 * supplicant for 10000ms. Taking power consumption into account 6 timers
12517 * will be used, Timervalue is increased exponentially i.e 10,20,40,
12518 * 80,160,320 secs. And number of scan cycle for each timer
12519 * is configurable through INI param gPNOScanTimerRepeatValue.
12520 * If it is set to 0 only one timer will be used and PNO scan cycle
12521 * will be repeated after each interval specified by supplicant
12522 * till PNO is disabled.
12523 */
12524 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
12525 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
12526 else
12527 pPnoRequest->scanTimers.ucScanTimersCount =
12528 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
12529
12530 tempInterval = (request->interval)/1000;
12531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12532 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
12533 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
12534 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
12535 {
12536 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
12537 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
12538 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
12539 tempInterval *= 2;
12540 }
12541 //Repeat last timer until pno disabled.
12542 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
12543
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +053012544 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012545
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012546 INIT_COMPLETION(pAdapter->pno_comp_var);
12547 pPnoRequest->statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
12548 pPnoRequest->callbackContext = pAdapter;
12549 pAdapter->pno_req_status = 0;
12550
Nirav Shah80830bf2013-12-31 16:35:12 +053012551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12552 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
12553 pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO,
12554 pPnoRequest->scanTimers.ucScanTimersCount);
12555
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012556 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
12557 pPnoRequest, pAdapter->sessionId,
12558 hdd_cfg80211_sched_scan_done_callback, pAdapter);
12559 if (eHAL_STATUS_SUCCESS != status)
12560 {
12561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053012562 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012563 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012564 goto error;
12565 }
12566
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012567 ret = wait_for_completion_timeout(
12568 &pAdapter->pno_comp_var,
12569 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
12570 if (0 >= ret)
12571 {
12572 // Did not receive the response for PNO enable in time.
12573 // Assuming the PNO enable was success.
12574 // Returning error from here, because we timeout, results
12575 // in side effect of Wifi (Wifi Setting) not to work.
12576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12577 FL("Timed out waiting for PNO to be Enabled"));
12578 ret = 0;
12579 goto error;
12580 }
12581
c_hpothu3c986b22014-07-09 14:45:09 +053012582 vos_mem_free(pPnoRequest);
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012583 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053012584 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012585
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012586error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12588 FL("PNO scanRequest offloaded ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012589 vos_mem_free(pPnoRequest);
c_hpothu37f21312014-04-09 21:49:54 +053012590 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012591 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012592}
12593
12594/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053012595 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
12596 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012597 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053012598static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
12599 struct net_device *dev, struct cfg80211_sched_scan_request *request)
12600{
12601 int ret;
12602
12603 vos_ssr_protect(__func__);
12604 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
12605 vos_ssr_unprotect(__func__);
12606
12607 return ret;
12608}
12609
12610/*
12611 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
12612 * Function to disable PNO
12613 */
12614static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012615 struct net_device *dev)
12616{
12617 eHalStatus status = eHAL_STATUS_FAILURE;
12618 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12619 hdd_context_t *pHddCtx;
12620 tHalHandle hHal;
12621 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012622 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012623
12624 ENTER();
12625
12626 if (NULL == pAdapter)
12627 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012629 "%s: HDD adapter is Null", __func__);
12630 return -ENODEV;
12631 }
12632
12633 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012634
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012635 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012636 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053012637 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012638 "%s: HDD context is Null", __func__);
12639 return -ENODEV;
12640 }
12641
12642 /* The return 0 is intentional when isLogpInProgress and
12643 * isLoadUnloadInProgress. We did observe a crash due to a return of
12644 * failure in sched_scan_stop , especially for a case where the unload
12645 * of the happens at the same time. The function __cfg80211_stop_sched_scan
12646 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
12647 * success. If it returns a failure , then its next invocation due to the
12648 * clean up of the second interface will have the dev pointer corresponding
12649 * to the first one leading to a crash.
12650 */
12651 if (pHddCtx->isLogpInProgress)
12652 {
12653 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12654 "%s: LOGP in Progress. Ignore!!!", __func__);
12655 return ret;
12656 }
12657
Mihir Shete18156292014-03-11 15:38:30 +053012658 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012659 {
12660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12661 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
12662 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012663 }
12664
12665 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12666 if (NULL == hHal)
12667 {
12668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12669 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012670 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012671 }
12672
12673 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
12674 if (NULL == pPnoRequest)
12675 {
12676 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
12677 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012678 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012679 }
12680
12681 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
12682 pPnoRequest->enable = 0; /* Disable PNO */
12683 pPnoRequest->ucNetworksCount = 0;
12684
12685 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
12686 pAdapter->sessionId,
12687 NULL, pAdapter);
12688 if (eHAL_STATUS_SUCCESS != status)
12689 {
12690 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12691 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012692 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012693 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012694 }
c_hpothu37f21312014-04-09 21:49:54 +053012695 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012696
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012697error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053012698 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053012699 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012700 vos_mem_free(pPnoRequest);
12701
12702 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053012703 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012704}
12705
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053012706/*
12707 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
12708 * NL interface to disable PNO
12709 */
12710static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
12711 struct net_device *dev)
12712{
12713 int ret;
12714
12715 vos_ssr_protect(__func__);
12716 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
12717 vos_ssr_unprotect(__func__);
12718
12719 return ret;
12720}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053012721#endif /*FEATURE_WLAN_SCAN_PNO*/
12722
12723
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012724#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053012725#if TDLS_MGMT_VERSION2
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012726static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
12727 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053012728 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
12729#else
12730static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
12731 u8 *peer, u8 action_code, u8 dialog_token,
12732 u16 status_code, const u8 *buf, size_t len)
12733#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012734{
12735
12736 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12737 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012738 u8 peerMac[6];
12739 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070012740 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080012741 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070012742 long rc;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053012743#if !(TDLS_MGMT_VERSION2)
12744 u32 peer_capability = 0;
12745#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012746 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012747
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012748 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12749 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
12750 pAdapter->sessionId, action_code));
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012751 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012752 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012754 "Invalid arguments");
12755 return -EINVAL;
12756 }
12757
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080012758 if (pHddCtx->isLogpInProgress)
12759 {
12760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12761 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -070012762 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080012763 return -EBUSY;
12764 }
12765
Hoonki Lee27511902013-03-14 18:19:06 -070012766 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012767 {
Hoonki Lee27511902013-03-14 18:19:06 -070012768 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
12769 "%s: TDLS mode is disabled OR not enabled in FW."
12770 MAC_ADDRESS_STR " action %d declined.",
12771 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012772 return -ENOTSUPP;
12773 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080012774
Hoonki Lee27511902013-03-14 18:19:06 -070012775 /* other than teardown frame, other mgmt frames are not sent if disabled */
12776 if (SIR_MAC_TDLS_TEARDOWN != action_code)
12777 {
12778 /* if tdls_mode is disabled to respond to peer's request */
12779 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
12780 {
12781 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
12782 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070012783 " TDLS mode is disabled. action %d declined.",
12784 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070012785
12786 return -ENOTSUPP;
12787 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053012788
12789 if (vos_max_concurrent_connections_reached())
12790 {
12791 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12792 return -EINVAL;
12793 }
Hoonki Lee27511902013-03-14 18:19:06 -070012794 }
12795
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012796 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
12797 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012798 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012799 {
12800 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012801 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070012802 " TDLS setup is ongoing. action %d declined.",
12803 __func__, MAC_ADDR_ARRAY(peer), action_code);
12804 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012805 }
12806 }
12807
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012808 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
12809 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080012810 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012811 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
12812 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080012813 {
12814 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
12815 we return error code at 'add_station()'. Hence we have this
12816 check again in addtion to add_station().
12817 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012818 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080012819 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012820 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12821 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012822 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
12823 __func__, MAC_ADDR_ARRAY(peer), action_code,
12824 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053012825 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080012826 }
12827 else
12828 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012829 /* maximum reached. tweak to send error code to peer and return
12830 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080012831 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012832 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12833 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053012834 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
12835 __func__, MAC_ADDR_ARRAY(peer), status_code,
12836 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070012837 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012838 /* fall through to send setup resp with failure status
12839 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080012840 }
12841 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012842 else
12843 {
12844 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012845 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070012846 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012847 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012848 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070012849 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
12850 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012851 return -EPERM;
12852 }
12853 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080012854 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012855 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012856
Hoonki Lee1090c6a2013-01-16 17:40:54 -080012857#ifdef WLAN_FEATURE_TDLS_DEBUG
12858 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053012859 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012860 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
12861 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -080012862#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012863
Hoonki Leea34dd892013-02-05 22:56:02 -080012864 /*Except teardown responder will not be used so just make 0*/
12865 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012866 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080012867 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070012868
12869 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053012870 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070012871
12872 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
12873 responder = pTdlsPeer->is_responder;
12874 else
Hoonki Leea34dd892013-02-05 22:56:02 -080012875 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070012876 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053012877 "%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 -070012878 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
12879 dialog_token, status_code, len);
12880 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080012881 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012882 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012883
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053012884 /* For explicit trigger of DIS_REQ come out of BMPS for
12885 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070012886 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053012887 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
12888 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070012889 {
12890 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
12891 {
12892 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053012893 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -070012894 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
12895 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053012896 if (SIR_MAC_TDLS_DIS_REQ != action_code)
12897 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -070012898 }
12899
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012900 /* make sure doesn't call send_mgmt() while it is pending */
12901 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
12902 {
12903 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012904 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012905 __func__, MAC_ADDR_ARRAY(peer), action_code);
12906 return -EBUSY;
12907 }
12908
12909 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012910 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
12911
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012912 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053012913 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012914
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012915 if (VOS_STATUS_SUCCESS != status)
12916 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012917 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12918 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012919 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -070012920 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053012921 return -EINVAL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012922 }
12923
Hoonki Leed37cbb32013-04-20 00:31:14 -070012924 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
12925 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
12926
12927 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012928 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070012929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070012930 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070012931 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012932 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080012933
12934 if (pHddCtx->isLogpInProgress)
12935 {
12936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12937 "%s: LOGP in Progress. Ignore!!!", __func__);
12938 return -EAGAIN;
12939 }
12940
Hoonki Leed37cbb32013-04-20 00:31:14 -070012941 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053012942 return -EINVAL;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012943 }
12944
Gopichand Nakkala05922802013-03-14 12:23:19 -070012945 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070012946 {
12947 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -070012948 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070012949 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012950
Hoonki Leea34dd892013-02-05 22:56:02 -080012951 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
12952 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012953 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -080012954 }
12955 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
12956 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012957 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -080012958 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012959
12960 return 0;
12961}
12962
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012963static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012964 u8 *peer, enum nl80211_tdls_operation oper)
12965{
12966 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
12967 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012968 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070012969 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012970
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012971 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12972 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
12973 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012974 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012975 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080012976 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070012977 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012978 return -EINVAL;
12979 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080012980
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012981 status = wlan_hdd_validate_context(pHddCtx);
12982
12983 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080012984 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012985 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12986 "%s: HDD context is not valid", __func__);
12987 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080012988 }
12989
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012990
12991 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080012992 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012993 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080012994 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070012995 "TDLS Disabled in INI OR not enabled in FW. "
12996 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -080012997 return -ENOTSUPP;
12998 }
12999
13000 switch (oper) {
13001 case NL80211_TDLS_ENABLE_LINK:
13002 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013003 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013004 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013005 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013006
Sunil Dutt41de4e22013-11-14 18:09:02 +053013007 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
13008
13009 if ( NULL == pTdlsPeer ) {
13010 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
13011 " (oper %d) not exsting. ignored",
13012 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
13013 return -EINVAL;
13014 }
13015
13016 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13017 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
13018 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
13019 "NL80211_TDLS_ENABLE_LINK");
13020
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070013021 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
13022 {
13023 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
13024 MAC_ADDRESS_STR " failed",
13025 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
13026 return -EINVAL;
13027 }
13028
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013029 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013030 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053013031 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053013032
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053013033 if (0 != wlan_hdd_tdls_get_link_establish_params(
13034 pAdapter, peer,&tdlsLinkEstablishParams)) {
13035 return -EINVAL;
13036 }
13037 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013038
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053013039 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
13040 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
13041 /* Send TDLS peer UAPSD capabilities to the firmware and
13042 * register with the TL on after the response for this operation
13043 * is received .
13044 */
13045 ret = wait_for_completion_interruptible_timeout(
13046 &pAdapter->tdls_link_establish_req_comp,
13047 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
13048 if (ret <= 0)
13049 {
13050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13051 "%s: Link Establish Request Faled Status %ld",
13052 __func__, ret);
13053 return -EINVAL;
13054 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013055 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070013056 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +053013057 /* Mark TDLS client Authenticated .*/
13058 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
13059 pTdlsPeer->staId,
13060 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070013061 if (VOS_STATUS_SUCCESS == status)
13062 {
Hoonki Lee14621352013-04-16 17:51:19 -070013063 if (pTdlsPeer->is_responder == 0)
13064 {
13065 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
13066
13067 wlan_hdd_tdls_timer_restart(pAdapter,
13068 &pTdlsPeer->initiatorWaitTimeoutTimer,
13069 WAIT_TIME_TDLS_INITIATOR);
13070 /* suspend initiator TX until it receives direct packet from the
13071 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
13072 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
13073 &staId, NULL);
13074 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070013075 wlan_hdd_tdls_increment_peer_count(pAdapter);
13076 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013077 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013078
13079 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053013080 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
13081 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013082 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053013083 int ac;
13084 uint8 ucAc[4] = { WLANTL_AC_VO,
13085 WLANTL_AC_VI,
13086 WLANTL_AC_BK,
13087 WLANTL_AC_BE };
13088 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
13089 for(ac=0; ac < 4; ac++)
13090 {
13091 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
13092 pTdlsPeer->staId, ucAc[ac],
13093 tlTid[ac], tlTid[ac], 0, 0,
13094 WLANTL_BI_DIR );
13095 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053013096 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013097 }
13098
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013099 }
13100 break;
13101 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080013102 {
Sunil Dutt41de4e22013-11-14 18:09:02 +053013103 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
13104
13105 if ( NULL == pTdlsPeer ) {
13106 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
13107 " (oper %d) not exsting. ignored",
13108 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
13109 return -EINVAL;
13110 }
13111
13112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13113 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
13114 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
13115 "NL80211_TDLS_DISABLE_LINK");
13116
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013117 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080013118 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013119 long status;
13120
13121 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
13122
Lee Hoonkic1262f22013-01-24 21:59:00 -080013123 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
13124 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013125
13126 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
13127 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
13128 if (status <= 0)
13129 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013130 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070013131 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13132 "%s: Del station failed status %ld",
13133 __func__, status);
13134 return -EPERM;
13135 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070013136 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -080013137 }
13138 else
13139 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13141 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080013142 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080013143 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013144 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013145 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053013146 {
13147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13148 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
13149 __func__, MAC_ADDR_ARRAY(peer));
13150
13151 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
13152 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
13153
13154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13155 " %s TDLS External control and Implicit Trigger not enabled ",
13156 __func__);
13157 return -ENOTSUPP;
13158 }
13159
Sunil Dutt41de4e22013-11-14 18:09:02 +053013160
13161 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
13162
13163 if ( NULL == pTdlsPeer ) {
13164 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
13165 " peer not exsting",
13166 __func__, MAC_ADDR_ARRAY(peer));
Naresh Jayaram937abdf2013-11-26 19:50:25 +053013167 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +053013168 }
13169 else {
13170 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
13171 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
13172 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +053013173
13174 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) )
13175 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +053013176 break;
13177 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013178 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053013179 {
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053013180 hddTdlsPeer_t *pTdlsPeer;
Sunil Dutt41de4e22013-11-14 18:09:02 +053013181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13182 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
13183 __func__, MAC_ADDR_ARRAY(peer));
13184
13185 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
13186 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
13187
13188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13189 " %s TDLS External control and Implicit Trigger not enabled ",
13190 __func__);
13191 return -ENOTSUPP;
13192 }
13193
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053013194 /* To cater the requirement of establishing the TDLS link
13195 * irrespective of the data traffic , get an entry of TDLS peer.
13196 */
13197 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
13198 if (pTdlsPeer == NULL) {
13199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13200 "%s: peer " MAC_ADDRESS_STR " not existing",
13201 __func__, MAC_ADDR_ARRAY(peer));
13202 return -EINVAL;
13203 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +053013204
13205 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
13206
13207 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13208 " %s TDLS Add Force Peer Failed",
13209 __func__);
13210 return -EINVAL;
13211 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053013212 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053013213 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013214 case NL80211_TDLS_DISCOVERY_REQ:
13215 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
13217 "%s: We don't support in-driver setup/teardown/discovery "
13218 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013219 return -ENOTSUPP;
13220 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13222 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013223 return -ENOTSUPP;
13224 }
13225 return 0;
13226}
Chilam NG571c65a2013-01-19 12:27:36 +053013227
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013228static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
13229 u8 *peer, enum nl80211_tdls_operation oper)
13230{
13231 int ret;
13232
13233 vos_ssr_protect(__func__);
13234 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
13235 vos_ssr_unprotect(__func__);
13236
13237 return ret;
13238}
13239
Chilam NG571c65a2013-01-19 12:27:36 +053013240int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
13241 struct net_device *dev, u8 *peer)
13242{
Arif Hussaina7c8e412013-11-20 11:06:42 -080013243 hddLog(VOS_TRACE_LEVEL_INFO,
13244 "tdls send discover req: "MAC_ADDRESS_STR,
13245 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053013246
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013247#if TDLS_MGMT_VERSION2
13248 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
13249 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
13250#else
Chilam NG571c65a2013-01-19 12:27:36 +053013251 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
13252 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053013253#endif
Chilam NG571c65a2013-01-19 12:27:36 +053013254}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013255#endif
13256
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013257#ifdef WLAN_FEATURE_GTK_OFFLOAD
13258/*
13259 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
13260 * Callback rountine called upon receiving response for
13261 * get offload info
13262 */
13263void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
13264 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
13265{
13266
13267 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013268 tANI_U8 tempReplayCounter[8];
13269 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013270
13271 ENTER();
13272
13273 if (NULL == pAdapter)
13274 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053013275 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013276 "%s: HDD adapter is Null", __func__);
13277 return ;
13278 }
13279
13280 if (NULL == pGtkOffloadGetInfoRsp)
13281 {
13282 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13283 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
13284 return ;
13285 }
13286
13287 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
13288 {
13289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13290 "%s: wlan Failed to get replay counter value",
13291 __func__);
13292 return ;
13293 }
13294
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013295 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13296 /* Update replay counter */
13297 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
13298 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
13299
13300 {
13301 /* changing from little to big endian since supplicant
13302 * works on big endian format
13303 */
13304 int i;
13305 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
13306
13307 for (i = 0; i < 8; i++)
13308 {
13309 tempReplayCounter[7-i] = (tANI_U8)p[i];
13310 }
13311 }
13312
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013313 /* Update replay counter to NL */
13314 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013315 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013316}
13317
13318/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013319 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013320 * This function is used to offload GTK rekeying job to the firmware.
13321 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013322int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013323 struct cfg80211_gtk_rekey_data *data)
13324{
13325 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13326 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
13327 hdd_station_ctx_t *pHddStaCtx;
13328 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013329 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013330 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013331 eHalStatus status = eHAL_STATUS_FAILURE;
13332
13333 ENTER();
13334
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013335
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013336 if (NULL == pAdapter)
13337 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013338 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013339 "%s: HDD adapter is Null", __func__);
13340 return -ENODEV;
13341 }
13342
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013343 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13344 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
13345 pAdapter->sessionId, pAdapter->device_mode));
13346
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013347 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013348
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013349 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013350 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013351 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13352 "%s: HDD context is not valid", __func__);
13353 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013354 }
13355
13356 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13357 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
13358 if (NULL == hHal)
13359 {
13360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13361 "%s: HAL context is Null!!!", __func__);
13362 return -EAGAIN;
13363 }
13364
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013365 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
13366 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
13367 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
13368 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013369 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013370 {
13371 /* changing from big to little endian since driver
13372 * works on little endian format
13373 */
13374 tANI_U8 *p =
13375 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
13376 int i;
13377
13378 for (i = 0; i < 8; i++)
13379 {
13380 p[7-i] = data->replay_ctr[i];
13381 }
13382 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013383
13384 if (TRUE == pHddCtx->hdd_wlan_suspended)
13385 {
13386 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013387 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
13388 sizeof (tSirGtkOffloadParams));
13389 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013390 pAdapter->sessionId);
13391
13392 if (eHAL_STATUS_SUCCESS != status)
13393 {
13394 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13395 "%s: sme_SetGTKOffload failed, returned %d",
13396 __func__, status);
13397 return status;
13398 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013399 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13400 "%s: sme_SetGTKOffload successfull", __func__);
13401 }
13402 else
13403 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13405 "%s: wlan not suspended GTKOffload request is stored",
13406 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013407 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053013408
13409 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013410}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053013411
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013412int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
13413 struct cfg80211_gtk_rekey_data *data)
13414{
13415 int ret;
13416
13417 vos_ssr_protect(__func__);
13418 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
13419 vos_ssr_unprotect(__func__);
13420
13421 return ret;
13422}
13423#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053013424/*
13425 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
13426 * This function is used to set access control policy
13427 */
13428static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
13429 struct net_device *dev, const struct cfg80211_acl_data *params)
13430{
13431 int i;
13432 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13433 hdd_hostapd_state_t *pHostapdState;
13434 tsap_Config_t *pConfig;
13435 v_CONTEXT_t pVosContext = NULL;
13436 hdd_context_t *pHddCtx;
13437 int status;
13438
13439 ENTER();
13440
13441 if (NULL == pAdapter)
13442 {
13443 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13444 "%s: HDD adapter is Null", __func__);
13445 return -ENODEV;
13446 }
13447
13448 if (NULL == params)
13449 {
13450 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13451 "%s: params is Null", __func__);
13452 return -EINVAL;
13453 }
13454
13455 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13456 status = wlan_hdd_validate_context(pHddCtx);
13457
13458 if (0 != status)
13459 {
13460 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13461 "%s: HDD context is not valid", __func__);
13462 return status;
13463 }
13464
13465 pVosContext = pHddCtx->pvosContext;
13466 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
13467
13468 if (NULL == pHostapdState)
13469 {
13470 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13471 "%s: pHostapdState is Null", __func__);
13472 return -EINVAL;
13473 }
13474
13475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
13476 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
13477
13478 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
13479 {
13480 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
13481
13482 /* default value */
13483 pConfig->num_accept_mac = 0;
13484 pConfig->num_deny_mac = 0;
13485
13486 /**
13487 * access control policy
13488 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
13489 * listed in hostapd.deny file.
13490 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
13491 * listed in hostapd.accept file.
13492 */
13493 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
13494 {
13495 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
13496 }
13497 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
13498 {
13499 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
13500 }
13501 else
13502 {
13503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13504 "%s:Acl Policy : %d is not supported",
13505 __func__, params->acl_policy);
13506 return -ENOTSUPP;
13507 }
13508
13509 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
13510 {
13511 pConfig->num_accept_mac = params->n_acl_entries;
13512 for (i = 0; i < params->n_acl_entries; i++)
13513 {
13514 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13515 "** Add ACL MAC entry %i in WhiletList :"
13516 MAC_ADDRESS_STR, i,
13517 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
13518
13519 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
13520 sizeof(qcmacaddr));
13521 }
13522 }
13523 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
13524 {
13525 pConfig->num_deny_mac = params->n_acl_entries;
13526 for (i = 0; i < params->n_acl_entries; i++)
13527 {
13528 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13529 "** Add ACL MAC entry %i in BlackList :"
13530 MAC_ADDRESS_STR, i,
13531 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
13532
13533 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
13534 sizeof(qcmacaddr));
13535 }
13536 }
13537
13538 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
13539 {
13540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13541 "%s: SAP Set Mac Acl fail", __func__);
13542 return -EINVAL;
13543 }
13544 }
13545 else
13546 {
13547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053013548 "%s: Invalid device_mode = %s (%d)",
13549 __func__, hdd_device_modetoString(pAdapter->device_mode),
13550 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053013551 return -EINVAL;
13552 }
13553
13554 return 0;
13555}
13556
Leo Chang9056f462013-08-01 19:21:11 -070013557#ifdef WLAN_NL80211_TESTMODE
13558#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070013559void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070013560(
13561 void *pAdapter,
13562 void *indCont
13563)
13564{
Leo Changd9df8aa2013-09-26 13:32:26 -070013565 tSirLPHBInd *lphbInd;
13566 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053013567 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070013568
13569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070013570 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070013571
c_hpothu73f35e62014-04-18 13:40:08 +053013572 if (pAdapter == NULL)
13573 {
13574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13575 "%s: pAdapter is NULL\n",__func__);
13576 return;
13577 }
13578
Leo Chang9056f462013-08-01 19:21:11 -070013579 if (NULL == indCont)
13580 {
13581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070013582 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070013583 return;
13584 }
13585
c_hpothu73f35e62014-04-18 13:40:08 +053013586 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070013587 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070013588 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053013589 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070013590 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070013591 GFP_ATOMIC);
13592 if (!skb)
13593 {
13594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13595 "LPHB timeout, NL buffer alloc fail");
13596 return;
13597 }
13598
Leo Changac3ba772013-10-07 09:47:04 -070013599 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070013600 {
13601 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13602 "WLAN_HDD_TM_ATTR_CMD put fail");
13603 goto nla_put_failure;
13604 }
Leo Changac3ba772013-10-07 09:47:04 -070013605 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070013606 {
13607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13608 "WLAN_HDD_TM_ATTR_TYPE put fail");
13609 goto nla_put_failure;
13610 }
Leo Changac3ba772013-10-07 09:47:04 -070013611 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070013612 sizeof(tSirLPHBInd), lphbInd))
13613 {
13614 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13615 "WLAN_HDD_TM_ATTR_DATA put fail");
13616 goto nla_put_failure;
13617 }
Leo Chang9056f462013-08-01 19:21:11 -070013618 cfg80211_testmode_event(skb, GFP_ATOMIC);
13619 return;
13620
13621nla_put_failure:
13622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13623 "NLA Put fail");
13624 kfree_skb(skb);
13625
13626 return;
13627}
13628#endif /* FEATURE_WLAN_LPHB */
13629
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013630static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070013631{
13632 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
13633 int err = 0;
13634#ifdef FEATURE_WLAN_LPHB
13635 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070013636 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -070013637#endif /* FEATURE_WLAN_LPHB */
13638
13639 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
13640 if (err)
13641 {
13642 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13643 "%s Testmode INV ATTR", __func__);
13644 return err;
13645 }
13646
13647 if (!tb[WLAN_HDD_TM_ATTR_CMD])
13648 {
13649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13650 "%s Testmode INV CMD", __func__);
13651 return -EINVAL;
13652 }
13653
13654 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
13655 {
13656#ifdef FEATURE_WLAN_LPHB
13657 /* Low Power Heartbeat configuration request */
13658 case WLAN_HDD_TM_CMD_WLAN_HB:
13659 {
13660 int buf_len;
13661 void *buf;
13662 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080013663 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070013664
13665 if (!tb[WLAN_HDD_TM_ATTR_DATA])
13666 {
13667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13668 "%s Testmode INV DATA", __func__);
13669 return -EINVAL;
13670 }
13671
13672 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
13673 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080013674
13675 hb_params_temp =(tSirLPHBReq *)buf;
13676 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
13677 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
13678 return -EINVAL;
13679
Leo Chang9056f462013-08-01 19:21:11 -070013680 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
13681 if (NULL == hb_params)
13682 {
13683 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13684 "%s Request Buffer Alloc Fail", __func__);
13685 return -EINVAL;
13686 }
13687
13688 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070013689 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
13690 hb_params,
13691 wlan_hdd_cfg80211_lphb_ind_handler);
13692 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070013693 {
Leo Changd9df8aa2013-09-26 13:32:26 -070013694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13695 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070013696 vos_mem_free(hb_params);
13697 }
Leo Chang9056f462013-08-01 19:21:11 -070013698 return 0;
13699 }
13700#endif /* FEATURE_WLAN_LPHB */
13701 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013702 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13703 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070013704 return -EOPNOTSUPP;
13705 }
13706
13707 return err;
13708}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013709
13710static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
13711{
13712 int ret;
13713
13714 vos_ssr_protect(__func__);
13715 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
13716 vos_ssr_unprotect(__func__);
13717
13718 return ret;
13719}
Leo Chang9056f462013-08-01 19:21:11 -070013720#endif /* CONFIG_NL80211_TESTMODE */
13721
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013722static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013723 struct net_device *dev,
13724 int idx, struct survey_info *survey)
13725{
13726 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13727 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053013728 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013729 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053013730 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013731 v_S7_t snr,rssi;
13732 int status, i, j, filled = 0;
13733
13734 ENTER();
13735
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013736 if (NULL == pAdapter)
13737 {
13738 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13739 "%s: HDD adapter is Null", __func__);
13740 return -ENODEV;
13741 }
13742
13743 if (NULL == wiphy)
13744 {
13745 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13746 "%s: wiphy is Null", __func__);
13747 return -ENODEV;
13748 }
13749
13750 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13751 status = wlan_hdd_validate_context(pHddCtx);
13752
13753 if (0 != status)
13754 {
13755 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13756 "%s: HDD context is not valid", __func__);
13757 return status;
13758 }
13759
Mihir Sheted9072e02013-08-21 17:02:29 +053013760 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13761
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013762 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053013763 0 != pAdapter->survey_idx ||
13764 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053013765 {
13766 /* The survey dump ops when implemented completely is expected to
13767 * return a survey of all channels and the ops is called by the
13768 * kernel with incremental values of the argument 'idx' till it
13769 * returns -ENONET. But we can only support the survey for the
13770 * operating channel for now. survey_idx is used to track
13771 * that the ops is called only once and then return -ENONET for
13772 * the next iteration
13773 */
13774 pAdapter->survey_idx = 0;
13775 return -ENONET;
13776 }
13777
13778 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13779
13780 wlan_hdd_get_snr(pAdapter, &snr);
13781 wlan_hdd_get_rssi(pAdapter, &rssi);
13782
13783 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
13784 hdd_wlan_get_freq(channel, &freq);
13785
13786
13787 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
13788 {
13789 if (NULL == wiphy->bands[i])
13790 {
13791 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
13792 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
13793 continue;
13794 }
13795
13796 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
13797 {
13798 struct ieee80211_supported_band *band = wiphy->bands[i];
13799
13800 if (band->channels[j].center_freq == (v_U16_t)freq)
13801 {
13802 survey->channel = &band->channels[j];
13803 /* The Rx BDs contain SNR values in dB for the received frames
13804 * while the supplicant expects noise. So we calculate and
13805 * return the value of noise (dBm)
13806 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
13807 */
13808 survey->noise = rssi - snr;
13809 survey->filled = SURVEY_INFO_NOISE_DBM;
13810 filled = 1;
13811 }
13812 }
13813 }
13814
13815 if (filled)
13816 pAdapter->survey_idx = 1;
13817 else
13818 {
13819 pAdapter->survey_idx = 0;
13820 return -ENONET;
13821 }
13822
13823 return 0;
13824}
13825
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013826static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
13827 struct net_device *dev,
13828 int idx, struct survey_info *survey)
13829{
13830 int ret;
13831
13832 vos_ssr_protect(__func__);
13833 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
13834 vos_ssr_unprotect(__func__);
13835
13836 return ret;
13837}
13838
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013839/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053013840 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013841 * this is called when cfg80211 driver resume
13842 * driver updates latest sched_scan scan result(if any) to cfg80211 database
13843 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053013844int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013845{
13846 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
13847 hdd_adapter_t *pAdapter;
13848 hdd_adapter_list_node_t *pAdapterNode, *pNext;
13849 VOS_STATUS status = VOS_STATUS_SUCCESS;
13850
13851 ENTER();
13852
13853 if ( NULL == pHddCtx )
13854 {
13855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13856 "%s: HddCtx validation failed", __func__);
13857 return 0;
13858 }
13859
13860 if (pHddCtx->isLogpInProgress)
13861 {
13862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13863 "%s: LOGP in Progress. Ignore!!!", __func__);
13864 return 0;
13865 }
13866
Mihir Shete18156292014-03-11 15:38:30 +053013867 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013868 {
13869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13870 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
13871 return 0;
13872 }
13873
13874 spin_lock(&pHddCtx->schedScan_lock);
13875 pHddCtx->isWiphySuspended = FALSE;
13876 if (TRUE != pHddCtx->isSchedScanUpdatePending)
13877 {
13878 spin_unlock(&pHddCtx->schedScan_lock);
13879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13880 "%s: Return resume is not due to PNO indication", __func__);
13881 return 0;
13882 }
13883 // Reset flag to avoid updatating cfg80211 data old results again
13884 pHddCtx->isSchedScanUpdatePending = FALSE;
13885 spin_unlock(&pHddCtx->schedScan_lock);
13886
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053013887
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013888 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
13889
13890 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
13891 {
13892 pAdapter = pAdapterNode->pAdapter;
13893 if ( (NULL != pAdapter) &&
13894 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
13895 {
13896 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053013897 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013898 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
13899 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053013900 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013901 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053013902 {
13903 /* Acquire wakelock to handle the case where APP's tries to
13904 * suspend immediately after updating the scan results. Whis
13905 * results in app's is in suspended state and not able to
13906 * process the connect request to AP
13907 */
13908 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013909 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053013910 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013911
13912 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13913 "%s : cfg80211 scan result database updated", __func__);
13914
13915 return 0;
13916
13917 }
13918 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
13919 pAdapterNode = pNext;
13920 }
13921
13922 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13923 "%s: Failed to find Adapter", __func__);
13924 return 0;
13925}
13926
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053013927int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
13928{
13929 int ret;
13930
13931 vos_ssr_protect(__func__);
13932 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
13933 vos_ssr_unprotect(__func__);
13934
13935 return ret;
13936}
13937
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013938/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053013939 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013940 * this is called when cfg80211 driver suspends
13941 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053013942int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053013943 struct cfg80211_wowlan *wow)
13944{
13945 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
13946
13947 ENTER();
13948 if (NULL == pHddCtx)
13949 {
13950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
13951 "%s: HddCtx validation failed", __func__);
13952 return 0;
13953 }
13954
13955 pHddCtx->isWiphySuspended = TRUE;
13956
13957 EXIT();
13958
13959 return 0;
13960}
13961
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053013962int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
13963 struct cfg80211_wowlan *wow)
13964{
13965 int ret;
13966
13967 vos_ssr_protect(__func__);
13968 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
13969 vos_ssr_unprotect(__func__);
13970
13971 return ret;
13972}
Jeff Johnson295189b2012-06-20 16:38:30 -070013973/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013974static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070013975{
13976 .add_virtual_intf = wlan_hdd_add_virtual_intf,
13977 .del_virtual_intf = wlan_hdd_del_virtual_intf,
13978 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
13979 .change_station = wlan_hdd_change_station,
13980#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
13981 .add_beacon = wlan_hdd_cfg80211_add_beacon,
13982 .del_beacon = wlan_hdd_cfg80211_del_beacon,
13983 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013984#else
13985 .start_ap = wlan_hdd_cfg80211_start_ap,
13986 .change_beacon = wlan_hdd_cfg80211_change_beacon,
13987 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070013988#endif
13989 .change_bss = wlan_hdd_cfg80211_change_bss,
13990 .add_key = wlan_hdd_cfg80211_add_key,
13991 .get_key = wlan_hdd_cfg80211_get_key,
13992 .del_key = wlan_hdd_cfg80211_del_key,
13993 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080013994#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070013995 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080013996#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013997 .scan = wlan_hdd_cfg80211_scan,
13998 .connect = wlan_hdd_cfg80211_connect,
13999 .disconnect = wlan_hdd_cfg80211_disconnect,
14000 .join_ibss = wlan_hdd_cfg80211_join_ibss,
14001 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
14002 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
14003 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
14004 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070014005 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
14006 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053014007 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070014008#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14009 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
14010 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
14011 .set_txq_params = wlan_hdd_set_txq_params,
14012#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 .get_station = wlan_hdd_cfg80211_get_station,
14014 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
14015 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014016 .add_station = wlan_hdd_cfg80211_add_station,
14017#ifdef FEATURE_WLAN_LFR
14018 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
14019 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
14020 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
14021#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014022#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
14023 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
14024#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014025#ifdef FEATURE_WLAN_TDLS
14026 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
14027 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
14028#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053014029#ifdef WLAN_FEATURE_GTK_OFFLOAD
14030 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
14031#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014032#ifdef FEATURE_WLAN_SCAN_PNO
14033 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
14034 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
14035#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014036 .resume = wlan_hdd_cfg80211_resume_wlan,
14037 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014038 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070014039#ifdef WLAN_NL80211_TESTMODE
14040 .testmode_cmd = wlan_hdd_cfg80211_testmode,
14041#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014042 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070014043};
14044