blob: f56c80796e3970429d6de2e522204e33beb47064 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -080023 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
Kiet Lam842dad02014-02-18 18:44:02 -080026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/**========================================================================
31
32 \file wlan_hdd_cfg80211.c
33
34 \brief WLAN Host Device Driver implementation
35
Jeff Johnson295189b2012-06-20 16:38:30 -070036 ========================================================================*/
37
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070038/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070039
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070043 This section contains comments describing changes made to the module.
44 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070045
46
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070047 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070048
49
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070050 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070051 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070053
54 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070055 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070056 ==========================================================================*/
57
Jeff Johnson295189b2012-06-20 16:38:30 -070058
59#include <linux/version.h>
60#include <linux/module.h>
61#include <linux/kernel.h>
62#include <linux/init.h>
63#include <linux/wireless.h>
64#include <wlan_hdd_includes.h>
65#include <net/arp.h>
66#include <net/cfg80211.h>
67#include <linux/wireless.h>
68#include <wlan_hdd_wowl.h>
69#include <aniGlobal.h>
70#include "ccmApi.h"
71#include "sirParams.h"
72#include "dot11f.h"
73#include "wlan_hdd_assoc.h"
74#include "wlan_hdd_wext.h"
75#include "sme_Api.h"
76#include "wlan_hdd_p2p.h"
77#include "wlan_hdd_cfg80211.h"
78#include "wlan_hdd_hostapd.h"
79#include "sapInternal.h"
80#include "wlan_hdd_softap_tx_rx.h"
81#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053082#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053083#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053084#include "wlan_hdd_trace.h"
85#include "vos_types.h"
86#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070087#ifdef WLAN_BTAMP_FEATURE
88#include "bap_hdd_misc.h"
89#endif
90#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080091#ifdef FEATURE_WLAN_TDLS
92#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053093#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053094#include "wlan_qct_wda.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080095#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Lee Hoonkic1262f22013-01-24 21:59:00 -0800133#ifndef WLAN_FEATURE_TDLS_DEBUG
134#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
135#else
136#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
137#endif
138
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530139#ifdef WLAN_FEATURE_VOWIFI_11R
140#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
141#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
142#endif
143
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530144#define HDD_CHANNEL_14 14
145
Sunil Duttc69bccb2014-05-26 21:30:20 +0530146#ifdef WLAN_FEATURE_LINK_LAYER_STATS
147/*
148 * Used to allocate the size of 4096 for the link layer stats.
149 * The size of 4096 is considered assuming that all data per
150 * respective event fit with in the limit.Please take a call
151 * on the limit based on the data requirements on link layer
152 * statistics.
153 */
154#define LL_STATS_EVENT_BUF_SIZE 4096
155#endif
156
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530157static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700158{
159 WLAN_CIPHER_SUITE_WEP40,
160 WLAN_CIPHER_SUITE_WEP104,
161 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800162#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700163#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
164 WLAN_CIPHER_SUITE_KRK,
165 WLAN_CIPHER_SUITE_CCMP,
166#else
167 WLAN_CIPHER_SUITE_CCMP,
168#endif
169#ifdef FEATURE_WLAN_WAPI
170 WLAN_CIPHER_SUITE_SMS4,
171#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700172#ifdef WLAN_FEATURE_11W
173 WLAN_CIPHER_SUITE_AES_CMAC,
174#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700175};
176
177static inline int is_broadcast_ether_addr(const u8 *addr)
178{
179 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
180 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
181}
182
183static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530184{
Jeff Johnson295189b2012-06-20 16:38:30 -0700185 HDD2GHZCHAN(2412, 1, 0) ,
186 HDD2GHZCHAN(2417, 2, 0) ,
187 HDD2GHZCHAN(2422, 3, 0) ,
188 HDD2GHZCHAN(2427, 4, 0) ,
189 HDD2GHZCHAN(2432, 5, 0) ,
190 HDD2GHZCHAN(2437, 6, 0) ,
191 HDD2GHZCHAN(2442, 7, 0) ,
192 HDD2GHZCHAN(2447, 8, 0) ,
193 HDD2GHZCHAN(2452, 9, 0) ,
194 HDD2GHZCHAN(2457, 10, 0) ,
195 HDD2GHZCHAN(2462, 11, 0) ,
196 HDD2GHZCHAN(2467, 12, 0) ,
197 HDD2GHZCHAN(2472, 13, 0) ,
198 HDD2GHZCHAN(2484, 14, 0) ,
199};
200
Jeff Johnson295189b2012-06-20 16:38:30 -0700201static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
202{
203 HDD2GHZCHAN(2412, 1, 0) ,
204 HDD2GHZCHAN(2437, 6, 0) ,
205 HDD2GHZCHAN(2462, 11, 0) ,
206};
Jeff Johnson295189b2012-06-20 16:38:30 -0700207
208static struct ieee80211_channel hdd_channels_5_GHZ[] =
209{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700210 HDD5GHZCHAN(4920, 240, 0) ,
211 HDD5GHZCHAN(4940, 244, 0) ,
212 HDD5GHZCHAN(4960, 248, 0) ,
213 HDD5GHZCHAN(4980, 252, 0) ,
214 HDD5GHZCHAN(5040, 208, 0) ,
215 HDD5GHZCHAN(5060, 212, 0) ,
216 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 HDD5GHZCHAN(5180, 36, 0) ,
218 HDD5GHZCHAN(5200, 40, 0) ,
219 HDD5GHZCHAN(5220, 44, 0) ,
220 HDD5GHZCHAN(5240, 48, 0) ,
221 HDD5GHZCHAN(5260, 52, 0) ,
222 HDD5GHZCHAN(5280, 56, 0) ,
223 HDD5GHZCHAN(5300, 60, 0) ,
224 HDD5GHZCHAN(5320, 64, 0) ,
225 HDD5GHZCHAN(5500,100, 0) ,
226 HDD5GHZCHAN(5520,104, 0) ,
227 HDD5GHZCHAN(5540,108, 0) ,
228 HDD5GHZCHAN(5560,112, 0) ,
229 HDD5GHZCHAN(5580,116, 0) ,
230 HDD5GHZCHAN(5600,120, 0) ,
231 HDD5GHZCHAN(5620,124, 0) ,
232 HDD5GHZCHAN(5640,128, 0) ,
233 HDD5GHZCHAN(5660,132, 0) ,
234 HDD5GHZCHAN(5680,136, 0) ,
235 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800236#ifdef FEATURE_WLAN_CH144
237 HDD5GHZCHAN(5720,144, 0) ,
238#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 HDD5GHZCHAN(5745,149, 0) ,
240 HDD5GHZCHAN(5765,153, 0) ,
241 HDD5GHZCHAN(5785,157, 0) ,
242 HDD5GHZCHAN(5805,161, 0) ,
243 HDD5GHZCHAN(5825,165, 0) ,
244};
245
246static struct ieee80211_rate g_mode_rates[] =
247{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530248 HDD_G_MODE_RATETAB(10, 0x1, 0),
249 HDD_G_MODE_RATETAB(20, 0x2, 0),
250 HDD_G_MODE_RATETAB(55, 0x4, 0),
251 HDD_G_MODE_RATETAB(110, 0x8, 0),
252 HDD_G_MODE_RATETAB(60, 0x10, 0),
253 HDD_G_MODE_RATETAB(90, 0x20, 0),
254 HDD_G_MODE_RATETAB(120, 0x40, 0),
255 HDD_G_MODE_RATETAB(180, 0x80, 0),
256 HDD_G_MODE_RATETAB(240, 0x100, 0),
257 HDD_G_MODE_RATETAB(360, 0x200, 0),
258 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700259 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530260};
Jeff Johnson295189b2012-06-20 16:38:30 -0700261
262static struct ieee80211_rate a_mode_rates[] =
263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530264 HDD_G_MODE_RATETAB(60, 0x10, 0),
265 HDD_G_MODE_RATETAB(90, 0x20, 0),
266 HDD_G_MODE_RATETAB(120, 0x40, 0),
267 HDD_G_MODE_RATETAB(180, 0x80, 0),
268 HDD_G_MODE_RATETAB(240, 0x100, 0),
269 HDD_G_MODE_RATETAB(360, 0x200, 0),
270 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 HDD_G_MODE_RATETAB(540, 0x800, 0),
272};
273
274static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
275{
276 .channels = hdd_channels_2_4_GHZ,
277 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
278 .band = IEEE80211_BAND_2GHZ,
279 .bitrates = g_mode_rates,
280 .n_bitrates = g_mode_rates_size,
281 .ht_cap.ht_supported = 1,
282 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
283 | IEEE80211_HT_CAP_GRN_FLD
284 | IEEE80211_HT_CAP_DSSSCCK40
285 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
286 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
287 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
288 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
289 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
290 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
291};
292
Jeff Johnson295189b2012-06-20 16:38:30 -0700293static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
294{
295 .channels = hdd_social_channels_2_4_GHZ,
296 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
297 .band = IEEE80211_BAND_2GHZ,
298 .bitrates = g_mode_rates,
299 .n_bitrates = g_mode_rates_size,
300 .ht_cap.ht_supported = 1,
301 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
302 | IEEE80211_HT_CAP_GRN_FLD
303 | IEEE80211_HT_CAP_DSSSCCK40
304 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
305 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
306 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
307 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
308 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
309 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
310};
Jeff Johnson295189b2012-06-20 16:38:30 -0700311
312static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
313{
314 .channels = hdd_channels_5_GHZ,
315 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
316 .band = IEEE80211_BAND_5GHZ,
317 .bitrates = a_mode_rates,
318 .n_bitrates = a_mode_rates_size,
319 .ht_cap.ht_supported = 1,
320 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
321 | IEEE80211_HT_CAP_GRN_FLD
322 | IEEE80211_HT_CAP_DSSSCCK40
323 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
324 | IEEE80211_HT_CAP_SGI_40
325 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
326 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
327 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
328 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
329 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
330 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
331};
332
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530333/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 TX/RX direction for each kind of interface */
335static const struct ieee80211_txrx_stypes
336wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
337 [NL80211_IFTYPE_STATION] = {
338 .tx = 0xffff,
339 .rx = BIT(SIR_MAC_MGMT_ACTION) |
340 BIT(SIR_MAC_MGMT_PROBE_REQ),
341 },
342 [NL80211_IFTYPE_AP] = {
343 .tx = 0xffff,
344 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
345 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
346 BIT(SIR_MAC_MGMT_PROBE_REQ) |
347 BIT(SIR_MAC_MGMT_DISASSOC) |
348 BIT(SIR_MAC_MGMT_AUTH) |
349 BIT(SIR_MAC_MGMT_DEAUTH) |
350 BIT(SIR_MAC_MGMT_ACTION),
351 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700352 [NL80211_IFTYPE_ADHOC] = {
353 .tx = 0xffff,
354 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
355 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
356 BIT(SIR_MAC_MGMT_PROBE_REQ) |
357 BIT(SIR_MAC_MGMT_DISASSOC) |
358 BIT(SIR_MAC_MGMT_AUTH) |
359 BIT(SIR_MAC_MGMT_DEAUTH) |
360 BIT(SIR_MAC_MGMT_ACTION),
361 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700362 [NL80211_IFTYPE_P2P_CLIENT] = {
363 .tx = 0xffff,
364 .rx = BIT(SIR_MAC_MGMT_ACTION) |
365 BIT(SIR_MAC_MGMT_PROBE_REQ),
366 },
367 [NL80211_IFTYPE_P2P_GO] = {
368 /* This is also same as for SoftAP */
369 .tx = 0xffff,
370 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
371 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
372 BIT(SIR_MAC_MGMT_PROBE_REQ) |
373 BIT(SIR_MAC_MGMT_DISASSOC) |
374 BIT(SIR_MAC_MGMT_AUTH) |
375 BIT(SIR_MAC_MGMT_DEAUTH) |
376 BIT(SIR_MAC_MGMT_ACTION),
377 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700378};
379
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800380#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800381static const struct ieee80211_iface_limit
382wlan_hdd_iface_limit[] = {
383 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800384 /* max = 3 ; Our driver create two interfaces during driver init
385 * wlan0 and p2p0 interfaces. p2p0 is considered as station
386 * interface until a group is formed. In JB architecture, once the
387 * group is formed, interface type of p2p0 is changed to P2P GO or
388 * Client.
389 * When supplicant remove the group, it first issue a set interface
390 * cmd to change the mode back to Station. In JB this works fine as
391 * we advertize two station type interface during driver init.
392 * Some vendors create separate interface for P2P GO/Client,
393 * after group formation(Third one). But while group remove
394 * supplicant first tries to change the mode(3rd interface) to STATION
395 * But as we advertized only two sta type interfaces nl80211 was
396 * returning error for the third one which was leading to failure in
397 * delete interface. Ideally while removing the group, supplicant
398 * should not try to change the 3rd interface mode to Station type.
399 * Till we get a fix in wpa_supplicant, we advertize max STA
400 * interface type to 3
401 */
402 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800403 .types = BIT(NL80211_IFTYPE_STATION),
404 },
405 {
406 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700407 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800408 },
409 {
410 .max = 1,
411 .types = BIT(NL80211_IFTYPE_P2P_GO) |
412 BIT(NL80211_IFTYPE_P2P_CLIENT),
413 },
414};
415
416/* By default, only single channel concurrency is allowed */
417static struct ieee80211_iface_combination
418wlan_hdd_iface_combination = {
419 .limits = wlan_hdd_iface_limit,
420 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800421 /*
422 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
423 * and p2p0 interfaces during driver init
424 * Some vendors create separate interface for P2P operations.
425 * wlan0: STA interface
426 * p2p0: P2P Device interface, action frames goes
427 * through this interface.
428 * p2p-xx: P2P interface, After GO negotiation this interface is
429 * created for p2p operations(GO/CLIENT interface).
430 */
431 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800432 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
433 .beacon_int_infra_match = false,
434};
435#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800436
Jeff Johnson295189b2012-06-20 16:38:30 -0700437static struct cfg80211_ops wlan_hdd_cfg80211_ops;
438
439/* Data rate 100KBPS based on IE Index */
440struct index_data_rate_type
441{
442 v_U8_t beacon_rate_index;
443 v_U16_t supported_rate[4];
444};
445
446/* 11B, 11G Rate table include Basic rate and Extended rate
447 The IDX field is the rate index
448 The HI field is the rate when RSSI is strong or being ignored
449 (in this case we report actual rate)
450 The MID field is the rate when RSSI is moderate
451 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
452 The LO field is the rate when RSSI is low
453 (in this case we don't report rates, actual current rate used)
454 */
455static const struct
456{
457 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700458 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700459} supported_data_rate[] =
460{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700461/* IDX HI HM LM LO (RSSI-based index */
462 {2, { 10, 10, 10, 0}},
463 {4, { 20, 20, 10, 0}},
464 {11, { 55, 20, 10, 0}},
465 {12, { 60, 55, 20, 0}},
466 {18, { 90, 55, 20, 0}},
467 {22, {110, 55, 20, 0}},
468 {24, {120, 90, 60, 0}},
469 {36, {180, 120, 60, 0}},
470 {44, {220, 180, 60, 0}},
471 {48, {240, 180, 90, 0}},
472 {66, {330, 180, 90, 0}},
473 {72, {360, 240, 90, 0}},
474 {96, {480, 240, 120, 0}},
475 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700476};
477
478/* MCS Based rate table */
479static struct index_data_rate_type supported_mcs_rate[] =
480{
481/* MCS L20 L40 S20 S40 */
482 {0, {65, 135, 72, 150}},
483 {1, {130, 270, 144, 300}},
484 {2, {195, 405, 217, 450}},
485 {3, {260, 540, 289, 600}},
486 {4, {390, 810, 433, 900}},
487 {5, {520, 1080, 578, 1200}},
488 {6, {585, 1215, 650, 1350}},
489 {7, {650, 1350, 722, 1500}}
490};
491
Leo Chang6f8870f2013-03-26 18:11:36 -0700492#ifdef WLAN_FEATURE_11AC
493
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530494#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700495
496struct index_vht_data_rate_type
497{
498 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530499 v_U16_t supported_VHT80_rate[2];
500 v_U16_t supported_VHT40_rate[2];
501 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700502};
503
504typedef enum
505{
506 DATA_RATE_11AC_MAX_MCS_7,
507 DATA_RATE_11AC_MAX_MCS_8,
508 DATA_RATE_11AC_MAX_MCS_9,
509 DATA_RATE_11AC_MAX_MCS_NA
510} eDataRate11ACMaxMcs;
511
512/* MCS Based VHT rate table */
513static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
514{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530515/* MCS L80 S80 L40 S40 L20 S40*/
516 {0, {293, 325}, {135, 150}, {65, 72}},
517 {1, {585, 650}, {270, 300}, {130, 144}},
518 {2, {878, 975}, {405, 450}, {195, 217}},
519 {3, {1170, 1300}, {540, 600}, {260, 289}},
520 {4, {1755, 1950}, {810, 900}, {390, 433}},
521 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
522 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
523 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
524 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
525 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700526};
527#endif /* WLAN_FEATURE_11AC */
528
Jeff Johnson295189b2012-06-20 16:38:30 -0700529extern struct net_device_ops net_ops_struct;
530
Leo Chang9056f462013-08-01 19:21:11 -0700531#ifdef WLAN_NL80211_TESTMODE
532enum wlan_hdd_tm_attr
533{
534 WLAN_HDD_TM_ATTR_INVALID = 0,
535 WLAN_HDD_TM_ATTR_CMD = 1,
536 WLAN_HDD_TM_ATTR_DATA = 2,
537 WLAN_HDD_TM_ATTR_TYPE = 3,
538 /* keep last */
539 WLAN_HDD_TM_ATTR_AFTER_LAST,
540 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
541};
542
543enum wlan_hdd_tm_cmd
544{
545 WLAN_HDD_TM_CMD_WLAN_HB = 1,
546};
547
548#define WLAN_HDD_TM_DATA_MAX_LEN 5000
549
550static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
551{
552 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
553 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
554 .len = WLAN_HDD_TM_DATA_MAX_LEN },
555};
556#endif /* WLAN_NL80211_TESTMODE */
557
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800558#ifdef FEATURE_WLAN_CH_AVOID
559/*
560 * FUNCTION: wlan_hdd_send_avoid_freq_event
561 * This is called when wlan driver needs to send vendor specific
562 * avoid frequency range event to userspace
563 */
564int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
565 tHddAvoidFreqList *pAvoidFreqList)
566{
567 struct sk_buff *vendor_event;
568
569 ENTER();
570
571 if (!pHddCtx)
572 {
573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
574 "%s: HDD context is null", __func__);
575 return -1;
576 }
577
578 if (!pAvoidFreqList)
579 {
580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
581 "%s: pAvoidFreqList is null", __func__);
582 return -1;
583 }
584
585 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
586 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530587 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800588 GFP_KERNEL);
589 if (!vendor_event)
590 {
591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
592 "%s: cfg80211_vendor_event_alloc failed", __func__);
593 return -1;
594 }
595
596 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
597 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
598
599 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
600
601 EXIT();
602 return 0;
603}
604#endif /* FEATURE_WLAN_CH_AVOID */
605
Sunil Duttc69bccb2014-05-26 21:30:20 +0530606#ifdef WLAN_FEATURE_LINK_LAYER_STATS
607
608static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
609 struct sk_buff *vendor_event)
610{
611 if (nla_put_u8(vendor_event,
612 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
613 stats->rate.preamble) ||
614 nla_put_u8(vendor_event,
615 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
616 stats->rate.nss) ||
617 nla_put_u8(vendor_event,
618 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
619 stats->rate.bw) ||
620 nla_put_u8(vendor_event,
621 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
622 stats->rate.rateMcsIdx) ||
623 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
624 stats->rate.bitrate ) ||
625 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
626 stats->txMpdu ) ||
627 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
628 stats->rxMpdu ) ||
629 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
630 stats->mpduLost ) ||
631 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
632 stats->retries) ||
633 nla_put_u32(vendor_event,
634 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
635 stats->retriesShort ) ||
636 nla_put_u32(vendor_event,
637 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
638 stats->retriesLong))
639 {
640 hddLog(VOS_TRACE_LEVEL_ERROR,
641 FL("QCA_WLAN_VENDOR_ATTR put fail"));
642 return FALSE;
643 }
644 return TRUE;
645}
646
647static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
648 struct sk_buff *vendor_event)
649{
650 u32 i = 0;
651 struct nlattr *rateInfo;
652 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
653 stats->type) ||
654 nla_put(vendor_event,
655 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
656 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
657 nla_put_u32(vendor_event,
658 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
659 stats->capabilities) ||
660 nla_put_u32(vendor_event,
661 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
662 stats->numRate))
663 {
664 hddLog(VOS_TRACE_LEVEL_ERROR,
665 FL("QCA_WLAN_VENDOR_ATTR put fail"));
666 goto error;
667 }
668
669 rateInfo = nla_nest_start(vendor_event,
670 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
671 for (i = 0; i < stats->numRate; i++)
672 {
673 struct nlattr *rates;
674 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
675 stats->rateStats +
676 (i * sizeof(tSirWifiRateStat)));
677 rates = nla_nest_start(vendor_event, i);
678
679 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
680 {
681 hddLog(VOS_TRACE_LEVEL_ERROR,
682 FL("QCA_WLAN_VENDOR_ATTR put fail"));
683 return FALSE;
684 }
685 nla_nest_end(vendor_event, rates);
686 }
687 nla_nest_end(vendor_event, rateInfo);
688
689 return TRUE;
690error:
691 return FALSE;
692}
693
694static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
695 struct sk_buff *vendor_event)
696{
697 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
698 stats->ac ) ||
699 nla_put_u32(vendor_event,
700 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
701 stats->txMpdu ) ||
702 nla_put_u32(vendor_event,
703 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
704 stats->rxMpdu ) ||
705 nla_put_u32(vendor_event,
706 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
707 stats->txMcast ) ||
708 nla_put_u32(vendor_event,
709 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
710 stats->rxMcast ) ||
711 nla_put_u32(vendor_event,
712 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
713 stats->rxAmpdu ) ||
714 nla_put_u32(vendor_event,
715 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
716 stats->txAmpdu ) ||
717 nla_put_u32(vendor_event,
718 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
719 stats->mpduLost )||
720 nla_put_u32(vendor_event,
721 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
722 stats->retries ) ||
723 nla_put_u32(vendor_event,
724 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
725 stats->retriesShort ) ||
726 nla_put_u32(vendor_event,
727 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
728 stats->retriesLong ) ||
729 nla_put_u32(vendor_event,
730 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
731 stats->contentionTimeMin ) ||
732 nla_put_u32(vendor_event,
733 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
734 stats->contentionTimeMax ) ||
735 nla_put_u32(vendor_event,
736 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
737 stats->contentionTimeAvg ) ||
738 nla_put_u32(vendor_event,
739 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
740 stats->contentionNumSamples ))
741 {
742 hddLog(VOS_TRACE_LEVEL_ERROR,
743 FL("QCA_WLAN_VENDOR_ATTR put fail") );
744 return FALSE;
745 }
746 return TRUE;
747}
748
749static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
750 struct sk_buff *vendor_event)
751{
752 if (nla_put_u32(vendor_event,
753 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
754 nla_put(vendor_event,
755 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
756 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
757 nla_put_u32(vendor_event,
758 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
759 stats->state ) ||
760 nla_put_u32(vendor_event,
761 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
762 stats->roaming ) ||
763 nla_put_u32(vendor_event,
764 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
765 stats->capabilities ) ||
766 nla_put(vendor_event,
767 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
768 strlen(stats->ssid), stats->ssid) ||
769 nla_put(vendor_event,
770 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
771 WNI_CFG_BSSID_LEN, stats->bssid) ||
772 nla_put(vendor_event,
773 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
774 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
775 nla_put(vendor_event,
776 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
777 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
778 )
779 {
780 hddLog(VOS_TRACE_LEVEL_ERROR,
781 FL("QCA_WLAN_VENDOR_ATTR put fail") );
782 return FALSE;
783 }
784 return TRUE;
785}
786
787static v_BOOL_t put_wifi_iface_stats(tpSirWifiIfaceStat pWifiIfaceStat,
788 struct sk_buff *vendor_event)
789{
790 int i = 0;
791 struct nlattr *wmmInfo;
792 if (FALSE == put_wifi_interface_info(
793 &pWifiIfaceStat->info,
794 vendor_event))
795 {
796 hddLog(VOS_TRACE_LEVEL_ERROR,
797 FL("QCA_WLAN_VENDOR_ATTR put fail") );
798 return FALSE;
799
800 }
801
802 if (nla_put_u32(vendor_event,
803 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
804 pWifiIfaceStat->beaconRx) ||
805 nla_put_u32(vendor_event,
806 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
807 pWifiIfaceStat->mgmtRx) ||
808 nla_put_u32(vendor_event,
809 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
810 pWifiIfaceStat->mgmtActionRx) ||
811 nla_put_u32(vendor_event,
812 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
813 pWifiIfaceStat->mgmtActionTx) ||
814 nla_put_u32(vendor_event,
815 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
816 pWifiIfaceStat->rssiMgmt) ||
817 nla_put_u32(vendor_event,
818 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
819 pWifiIfaceStat->rssiData) ||
820 nla_put_u32(vendor_event,
821 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
822 pWifiIfaceStat->rssiAck))
823 {
824 hddLog(VOS_TRACE_LEVEL_ERROR,
825 FL("QCA_WLAN_VENDOR_ATTR put fail"));
826 return FALSE;
827 }
828
829 wmmInfo = nla_nest_start(vendor_event,
830 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
831 for (i = 0; i < WIFI_AC_MAX; i++)
832 {
833 struct nlattr *wmmStats;
834 wmmStats = nla_nest_start(vendor_event, i);
835 if (FALSE == put_wifi_wmm_ac_stat(
836 &pWifiIfaceStat->AccessclassStats[i],
837 vendor_event))
838 {
839 hddLog(VOS_TRACE_LEVEL_ERROR,
840 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
841 return FALSE;
842 }
843
844 nla_nest_end(vendor_event, wmmStats);
845 }
846 nla_nest_end(vendor_event, wmmInfo);
847 return TRUE;
848}
849
850static tSirWifiInterfaceMode
851 hdd_map_device_to_ll_iface_mode ( int deviceMode )
852{
853 switch (deviceMode)
854 {
855 case WLAN_HDD_INFRA_STATION:
856 return WIFI_INTERFACE_STA;
857 case WLAN_HDD_SOFTAP:
858 return WIFI_INTERFACE_SOFTAP;
859 case WLAN_HDD_P2P_CLIENT:
860 return WIFI_INTERFACE_P2P_CLIENT;
861 case WLAN_HDD_P2P_GO:
862 return WIFI_INTERFACE_P2P_GO;
863 case WLAN_HDD_IBSS:
864 return WIFI_INTERFACE_IBSS;
865 default:
866 /* Return Interface Mode as STA for all the unsupported modes */
867 return WIFI_INTERFACE_STA;
868 }
869}
870
871static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
872 tpSirWifiInterfaceInfo pInfo)
873{
874 v_U8_t *staMac = NULL;
875 hdd_station_ctx_t *pHddStaCtx;
876 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
877 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
878
879 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
880
881 vos_mem_copy(pInfo->macAddr,
882 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
883
884 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
885 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
886 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
887 {
888 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
889 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
890 {
891 pInfo->state = WIFI_DISCONNECTED;
892 }
893 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
894 {
895 hddLog(VOS_TRACE_LEVEL_ERROR,
896 "%s: Session ID %d, Connection is in progress", __func__,
897 pAdapter->sessionId);
898 pInfo->state = WIFI_ASSOCIATING;
899 }
900 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
901 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
902 {
903 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
904 hddLog(VOS_TRACE_LEVEL_ERROR,
905 "%s: client " MAC_ADDRESS_STR
906 " is in the middle of WPS/EAPOL exchange.", __func__,
907 MAC_ADDR_ARRAY(staMac));
908 pInfo->state = WIFI_AUTHENTICATING;
909 }
910 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
911 {
912 pInfo->state = WIFI_ASSOCIATED;
913 vos_mem_copy(pInfo->bssid,
914 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
915 vos_mem_copy(pInfo->ssid,
916 pHddStaCtx->conn_info.SSID.SSID.ssId,
917 pHddStaCtx->conn_info.SSID.SSID.length);
918 //NULL Terminate the string.
919 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
920 }
921 }
922 vos_mem_copy(pInfo->countryStr,
923 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
924
925 vos_mem_copy(pInfo->apCountryStr,
926 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
927
928 return TRUE;
929}
930
931/*
932 * hdd_link_layer_process_peer_stats () - This function is called after
933 * receiving Link Layer Peer statistics from FW.This function converts
934 * the firmware data to the NL data and sends the same to the kernel/upper
935 * layers.
936 */
937static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
938 v_VOID_t *pData)
939{
940 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
941 tpSirWifiRateStat pWifiRateStat;
942 tpSirWifiPeerStat pWifiPeerStat;
943 tpSirWifiPeerInfo pWifiPeerInfo;
944 struct nlattr *peerInfo;
945 struct sk_buff *vendor_event;
946 int status, i;
947
948 status = wlan_hdd_validate_context(pHddCtx);
949 if (0 != status)
950 {
951 hddLog(VOS_TRACE_LEVEL_ERROR,
952 FL("HDD context is not valid") );
953 return;
954 }
955
956 pWifiPeerStat = (tpSirWifiPeerStat) pData;
957
958 hddLog(VOS_TRACE_LEVEL_INFO,
959 "LL_STATS_PEER_ALL : numPeers %u",
960 pWifiPeerStat->numPeers);
961 {
962 for (i = 0; i < pWifiPeerStat->numPeers; i++)
963 {
964 pWifiPeerInfo = (tpSirWifiPeerInfo)
965 ((uint8 *)pWifiPeerStat->peerInfo +
966 ( i * sizeof(tSirWifiPeerInfo)));
967
968 hddLog(VOS_TRACE_LEVEL_INFO,
969 " %d) LL_STATS Channel Stats "
970 " Peer Type %u "
971 " peerMacAddress %pM "
972 " capabilities 0x%x "
973 " numRate %u ",
974 i,
975 pWifiPeerInfo->type,
976 pWifiPeerInfo->peerMacAddress,
977 pWifiPeerInfo->capabilities,
978 pWifiPeerInfo->numRate);
979 {
980 int j;
981 for (j = 0; j < pWifiPeerInfo->numRate; j++)
982 {
983 pWifiRateStat = (tpSirWifiRateStat)
984 ((tANI_U8 *) pWifiPeerInfo->rateStats +
985 ( j * sizeof(tSirWifiRateStat)));
986
987 hddLog(VOS_TRACE_LEVEL_INFO,
988 " peer Rate Stats "
989 " preamble %u "
990 " nss %u "
991 " bw %u "
992 " rateMcsIdx %u "
993 " reserved %u "
994 " bitrate %u "
995 " txMpdu %u "
996 " rxMpdu %u "
997 " mpduLost %u "
998 " retries %u "
999 " retriesShort %u "
1000 " retriesLong %u",
1001 pWifiRateStat->rate.preamble,
1002 pWifiRateStat->rate.nss,
1003 pWifiRateStat->rate.bw,
1004 pWifiRateStat->rate.rateMcsIdx,
1005 pWifiRateStat->rate.reserved,
1006 pWifiRateStat->rate.bitrate,
1007 pWifiRateStat->txMpdu,
1008 pWifiRateStat->rxMpdu,
1009 pWifiRateStat->mpduLost,
1010 pWifiRateStat->retries,
1011 pWifiRateStat->retriesShort,
1012 pWifiRateStat->retriesLong);
1013 }
1014 }
1015 }
1016 }
1017
1018 /*
1019 * Allocate a size of 4096 for the peer stats comprising
1020 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1021 * sizeof (tSirWifiRateStat).Each field is put with an
1022 * NL attribute.The size of 4096 is considered assuming
1023 * that number of rates shall not exceed beyond 50 with
1024 * the sizeof (tSirWifiRateStat) being 32.
1025 */
1026 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1027 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1028 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1029 GFP_KERNEL);
1030 if (!vendor_event)
1031 {
1032 hddLog(VOS_TRACE_LEVEL_ERROR,
1033 "%s: cfg80211_vendor_event_alloc failed",
1034 __func__);
1035 return;
1036 }
1037 if (nla_put_u32(vendor_event,
1038 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1039 pWifiPeerStat->numPeers))
1040 {
1041 hddLog(VOS_TRACE_LEVEL_ERROR,
1042 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1043 kfree_skb(vendor_event);
1044 return;
1045 }
1046
1047 peerInfo = nla_nest_start(vendor_event,
1048 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
1049
1050 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1051 pWifiPeerStat->peerInfo);
1052
1053 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1054 {
1055 struct nlattr *peers = nla_nest_start(vendor_event, i);
1056 int numRate = pWifiPeerInfo->numRate;
1057
1058 if (FALSE == put_wifi_peer_info(
1059 pWifiPeerInfo, vendor_event))
1060 {
1061 hddLog(VOS_TRACE_LEVEL_ERROR,
1062 "%s: put_wifi_peer_info put fail", __func__);
1063 kfree_skb(vendor_event);
1064 return;
1065 }
1066
1067 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1068 pWifiPeerStat->peerInfo +
1069 (i * sizeof(tSirWifiPeerInfo)) +
1070 (numRate * sizeof (tSirWifiRateStat)));
1071 nla_nest_end(vendor_event, peers);
1072 }
1073 nla_nest_end(vendor_event, peerInfo);
1074 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1075}
1076
1077/*
1078 * hdd_link_layer_process_iface_stats () - This function is called after
1079 * receiving Link Layer Interface statistics from FW.This function converts
1080 * the firmware data to the NL data and sends the same to the kernel/upper
1081 * layers.
1082 */
1083static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1084 v_VOID_t *pData)
1085{
1086 tpSirWifiIfaceStat pWifiIfaceStat;
1087 struct sk_buff *vendor_event;
1088 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1089 int status;
1090
1091 status = wlan_hdd_validate_context(pHddCtx);
1092 if (0 != status)
1093 {
1094 hddLog(VOS_TRACE_LEVEL_ERROR,
1095 FL("HDD context is not valid") );
1096 return;
1097 }
1098 /*
1099 * Allocate a size of 4096 for the interface stats comprising
1100 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1101 * assuming that all these fit with in the limit.Please take
1102 * a call on the limit based on the data requirements on
1103 * interface statistics.
1104 */
1105 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1106 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1107 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1108 GFP_KERNEL);
1109 if (!vendor_event)
1110 {
1111 hddLog(VOS_TRACE_LEVEL_ERROR,
1112 FL("cfg80211_vendor_event_alloc failed") );
1113 return;
1114 }
1115
1116 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1117
1118 hddLog(VOS_TRACE_LEVEL_INFO,
1119 "WMI_LINK_STATS_IFACE Data");
1120
1121 hddLog(VOS_TRACE_LEVEL_INFO,
1122 "LL_STATS_IFACE: "
1123 " Mode %u "
1124 " MAC %pM "
1125 " State %u "
1126 " Roaming %u "
1127 " capabilities 0x%x "
1128 " SSID %s "
1129 " BSSID %pM",
1130 pWifiIfaceStat->info.mode,
1131 pWifiIfaceStat->info.macAddr,
1132 pWifiIfaceStat->info.state,
1133 pWifiIfaceStat->info.roaming,
1134 pWifiIfaceStat->info.capabilities,
1135 pWifiIfaceStat->info.ssid,
1136 pWifiIfaceStat->info.bssid);
1137
1138 hddLog(VOS_TRACE_LEVEL_INFO,
1139 " AP country str: %c%c%c",
1140 pWifiIfaceStat->info.apCountryStr[0],
1141 pWifiIfaceStat->info.apCountryStr[1],
1142 pWifiIfaceStat->info.apCountryStr[2]);
1143
1144
1145 hddLog(VOS_TRACE_LEVEL_INFO,
1146 " Country Str Association: %c%c%c",
1147 pWifiIfaceStat->info.countryStr[0],
1148 pWifiIfaceStat->info.countryStr[1],
1149 pWifiIfaceStat->info.countryStr[2]);
1150
1151 hddLog(VOS_TRACE_LEVEL_INFO,
1152 " beaconRx %u "
1153 " mgmtRx %u "
1154 " mgmtActionRx %u "
1155 " mgmtActionTx %u "
1156 " rssiMgmt %u "
1157 " rssiData %u "
1158 " rssiAck %u",
1159 pWifiIfaceStat->beaconRx,
1160 pWifiIfaceStat->mgmtRx,
1161 pWifiIfaceStat->mgmtActionRx,
1162 pWifiIfaceStat->mgmtActionTx,
1163 pWifiIfaceStat->rssiMgmt,
1164 pWifiIfaceStat->rssiData,
1165 pWifiIfaceStat->rssiAck );
1166
1167
1168 {
1169 int i;
1170 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1171 {
1172 hddLog(VOS_TRACE_LEVEL_INFO,
1173
1174 " %d) LL_STATS IFACE: "
1175 " ac: %u txMpdu: %u "
1176 " rxMpdu: %u txMcast: %u "
1177 " rxMcast: %u rxAmpdu: %u "
1178 " txAmpdu: %u mpduLost: %u "
1179 " retries: %u retriesShort: %u "
1180 " retriesLong: %u contentionTimeMin: %u "
1181 " contentionTimeMax: %u contentionTimeAvg: %u "
1182 " contentionNumSamples: %u",
1183 i,
1184 pWifiIfaceStat->AccessclassStats[i].ac,
1185 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1186 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1187 pWifiIfaceStat->AccessclassStats[i].txMcast,
1188 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1189 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1190 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1191 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1192 pWifiIfaceStat->AccessclassStats[i].retries,
1193 pWifiIfaceStat->
1194 AccessclassStats[i].retriesShort,
1195 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1196 pWifiIfaceStat->
1197 AccessclassStats[i].contentionTimeMin,
1198 pWifiIfaceStat->
1199 AccessclassStats[i].contentionTimeMax,
1200 pWifiIfaceStat->
1201 AccessclassStats[i].contentionTimeAvg,
1202 pWifiIfaceStat->
1203 AccessclassStats[i].contentionNumSamples);
1204
1205 }
1206 }
1207
1208 if (FALSE == hdd_get_interface_info( pAdapter,
1209 &pWifiIfaceStat->info))
1210 {
1211 hddLog(VOS_TRACE_LEVEL_ERROR,
1212 FL("hdd_get_interface_info get fail") );
1213 kfree_skb(vendor_event);
1214 return;
1215 }
1216
1217 if (FALSE == put_wifi_iface_stats( pWifiIfaceStat,
1218 vendor_event))
1219 {
1220 hddLog(VOS_TRACE_LEVEL_ERROR,
1221 FL("put_wifi_iface_stats fail") );
1222 kfree_skb(vendor_event);
1223 return;
1224 }
1225 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1226}
1227
1228/*
1229 * hdd_link_layer_process_radio_stats () - This function is called after
1230 * receiving Link Layer Radio statistics from FW.This function converts
1231 * the firmware data to the NL data and sends the same to the kernel/upper
1232 * layers.
1233 */
1234static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1235 v_VOID_t *pData)
1236{
1237 int status, i;
1238 tpSirWifiRadioStat pWifiRadioStat;
1239 tpSirWifiChannelStats pWifiChannelStats;
1240 struct sk_buff *vendor_event;
1241 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1242 struct nlattr *chList;
1243
1244 status = wlan_hdd_validate_context(pHddCtx);
1245 if (0 != status)
1246 {
1247 hddLog(VOS_TRACE_LEVEL_ERROR,
1248 FL("HDD context is not valid") );
1249 return;
1250 }
1251 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1252
1253 hddLog(VOS_TRACE_LEVEL_INFO,
1254 "LL_STATS_RADIO"
1255 " radio is %d onTime is %u "
1256 " txTime is %u rxTime is %u "
1257 " onTimeScan is %u onTimeNbd is %u "
1258 " onTimeGscan is %u onTimeRoamScan is %u "
1259 " onTimePnoScan is %u onTimeHs20 is %u "
1260 " numChannels is %u",
1261 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1262 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1263 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
1264 pWifiRadioStat->onTimeGscan,
1265 pWifiRadioStat->onTimeRoamScan,
1266 pWifiRadioStat->onTimePnoScan,
1267 pWifiRadioStat->onTimeHs20,
1268 pWifiRadioStat->numChannels);
1269 /*
1270 * Allocate a size of 4096 for the Radio stats comprising
1271 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1272 * (tSirWifiChannelStats).Each channel data is put with an
1273 * NL attribute.The size of 4096 is considered assuming that
1274 * number of channels shall not exceed beyond 60 with the
1275 * sizeof (tSirWifiChannelStats) being 24 bytes.
1276 */
1277
1278 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1279 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1280 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1281 GFP_KERNEL);
1282
1283 if (!vendor_event)
1284 {
1285 hddLog(VOS_TRACE_LEVEL_ERROR,
1286 FL("cfg80211_vendor_event_alloc failed") );
1287 return;
1288 }
1289
1290 if (nla_put_u32(vendor_event,
1291 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1292 pWifiRadioStat->radio) ||
1293 nla_put_u32(vendor_event,
1294 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1295 pWifiRadioStat->onTime) ||
1296 nla_put_u32(vendor_event,
1297 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1298 pWifiRadioStat->txTime) ||
1299 nla_put_u32(vendor_event,
1300 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1301 pWifiRadioStat->rxTime) ||
1302 nla_put_u32(vendor_event,
1303 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1304 pWifiRadioStat->onTimeScan) ||
1305 nla_put_u32(vendor_event,
1306 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1307 pWifiRadioStat->onTimeNbd) ||
1308 nla_put_u32(vendor_event,
1309 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_GSCAN,
1310 pWifiRadioStat->onTimeGscan)||
1311 nla_put_u32(vendor_event,
1312 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1313 pWifiRadioStat->onTimeRoamScan) ||
1314 nla_put_u32(vendor_event,
1315 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1316 pWifiRadioStat->onTimePnoScan) ||
1317 nla_put_u32(vendor_event,
1318 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1319 pWifiRadioStat->onTimeHs20) ||
1320 nla_put_u32(vendor_event,
1321 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1322 pWifiRadioStat->numChannels))
1323 {
1324 hddLog(VOS_TRACE_LEVEL_ERROR,
1325 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1326 kfree_skb(vendor_event);
1327 return ;
1328 }
1329
1330 chList = nla_nest_start(vendor_event,
1331 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
1332 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1333 {
1334 struct nlattr *chInfo;
1335
1336 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1337 pWifiRadioStat->channels +
1338 (i * sizeof(tSirWifiChannelStats)));
1339
1340 hddLog(VOS_TRACE_LEVEL_INFO,
1341 " %d) Channel Info"
1342 " width is %u "
1343 " CenterFreq %u "
1344 " CenterFreq0 %u "
1345 " CenterFreq1 %u "
1346 " onTime %u "
1347 " ccaBusyTime %u",
1348 i,
1349 pWifiChannelStats->channel.width,
1350 pWifiChannelStats->channel.centerFreq,
1351 pWifiChannelStats->channel.centerFreq0,
1352 pWifiChannelStats->channel.centerFreq1,
1353 pWifiChannelStats->onTime,
1354 pWifiChannelStats->ccaBusyTime);
1355
1356
1357 chInfo = nla_nest_start(vendor_event, i);
1358
1359 if (nla_put_u32(vendor_event,
1360 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1361 pWifiChannelStats->channel.width) ||
1362 nla_put_u32(vendor_event,
1363 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1364 pWifiChannelStats->channel.centerFreq) ||
1365 nla_put_u32(vendor_event,
1366 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1367 pWifiChannelStats->channel.centerFreq0) ||
1368 nla_put_u32(vendor_event,
1369 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1370 pWifiChannelStats->channel.centerFreq1) ||
1371 nla_put_u32(vendor_event,
1372 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1373 pWifiChannelStats->onTime) ||
1374 nla_put_u32(vendor_event,
1375 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1376 pWifiChannelStats->ccaBusyTime))
1377 {
1378 hddLog(VOS_TRACE_LEVEL_ERROR,
1379 FL("cfg80211_vendor_event_alloc failed") );
1380 kfree_skb(vendor_event);
1381 return ;
1382 }
1383 nla_nest_end(vendor_event, chInfo);
1384 }
1385 nla_nest_end(vendor_event, chList);
1386
1387 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
1388 return;
1389}
1390
1391/*
1392 * hdd_link_layer_stats_ind_callback () - This function is called after
1393 * receiving Link Layer indications from FW.This callback converts the firmware
1394 * data to the NL data and send the same to the kernel/upper layers.
1395 */
1396static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1397 int indType,
1398 void *pRsp )
1399{
1400 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pCtx;
1401 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1402 int status;
1403
1404 status = wlan_hdd_validate_context(pHddCtx);
1405
1406 if (0 != status)
1407 {
1408 hddLog(VOS_TRACE_LEVEL_ERROR,
1409 FL("HDD context is not valid"));
1410 return;
1411 }
1412
1413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1414 "%s: Link Layer Indication indType: %d", __func__, indType);
1415 switch (indType)
1416 {
1417 case SIR_HAL_LL_STATS_RESULTS_RSP:
1418 {
1419 tpSirLLStatsResults linkLayerStatsResults =
1420 (tpSirLLStatsResults)pRsp;
1421
1422
1423 hddLog(VOS_TRACE_LEVEL_INFO,
1424 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1425 hddLog(VOS_TRACE_LEVEL_INFO,
1426 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1427 linkLayerStatsResults->paramId);
1428 hddLog(VOS_TRACE_LEVEL_INFO,
1429 "LL_STATS RESULTS RESPONSE ifaceId = %u",
1430 linkLayerStatsResults->ifaceId);
1431 hddLog(VOS_TRACE_LEVEL_INFO,
1432 "LL_STATS RESULTS RESPONSE respId = %u",
1433 linkLayerStatsResults->respId);
1434 hddLog(VOS_TRACE_LEVEL_INFO,
1435 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1436 linkLayerStatsResults->moreResultToFollow);
1437 hddLog(VOS_TRACE_LEVEL_INFO,
1438 "LL_STATS RESULTS RESPONSE result = %p",
1439 linkLayerStatsResults->result);
1440 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1441 {
1442 hdd_link_layer_process_radio_stats(pAdapter,
1443 (v_VOID_t *)linkLayerStatsResults->result);
1444 }
1445 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1446 {
1447 hdd_link_layer_process_iface_stats(pAdapter,
1448 (v_VOID_t *)linkLayerStatsResults->result);
1449 }
1450 else if ( linkLayerStatsResults->paramId &
1451 WMI_LINK_STATS_ALL_PEER )
1452 {
1453 hdd_link_layer_process_peer_stats(pAdapter,
1454 (v_VOID_t *)linkLayerStatsResults->result);
1455 } /* WMI_LINK_STATS_ALL_PEER */
1456 else
1457 {
1458 hddLog(VOS_TRACE_LEVEL_ERROR,
1459 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1460 }
1461
1462 break;
1463 }
1464 default:
1465 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1466 break;
1467 }
1468 return;
1469}
1470
1471const struct
1472nla_policy
1473qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1474{
1475 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1476 { .type = NLA_U32 },
1477 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1478 { .type = NLA_U32 },
1479};
1480
1481static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1482 struct wireless_dev *wdev,
1483 void *data,
1484 int data_len)
1485{
1486 int status;
1487 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
1488 tpSirLLStatsSetReq pLinkLayerStatsSetReq;
1489 struct net_device *dev = wdev->netdev;
1490 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1491 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1492
1493 status = wlan_hdd_validate_context(pHddCtx);
1494 if (0 != status)
1495 {
1496 hddLog(VOS_TRACE_LEVEL_ERROR,
1497 FL("HDD context is not valid"));
1498 return -EINVAL;
1499 }
1500
1501 if (NULL == pAdapter)
1502 {
1503 hddLog(VOS_TRACE_LEVEL_ERROR,
1504 FL("HDD adapter is Null"));
1505 return -ENODEV;
1506 }
1507
1508 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1509 (struct nlattr *)data,
1510 data_len, qca_wlan_vendor_ll_set_policy))
1511 {
1512 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1513 return -EINVAL;
1514 }
1515 if (!tb_vendor
1516 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1517 {
1518 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1519 return -EINVAL;
1520 }
1521 if (!tb_vendor[
1522 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1523 {
1524 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1525 return -EINVAL;
1526 }
1527 pLinkLayerStatsSetReq = vos_mem_malloc(sizeof(tSirLLStatsSetReq));
1528 if (NULL == pLinkLayerStatsSetReq)
1529 {
1530 hddLog(VOS_TRACE_LEVEL_ERROR,
1531 FL(" Unable to allocate memory to pLinkLayerStatsSetReq") );
1532 return -ENOMEM;
1533 }
1534 // Shall take the request Id if the Upper layers pass. 1 For now.
1535 pLinkLayerStatsSetReq->reqId = 1;
1536
1537 pLinkLayerStatsSetReq->mpduSizeThreshold =
1538 nla_get_u32(
1539 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1540
1541 pLinkLayerStatsSetReq->aggressiveStatisticsGathering =
1542 nla_get_u32(
1543 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1544
1545 /* staId 0 in Firmware is reserved for Broadcast/Multicast data.
1546 * Hence the interface staId start from 1. Hence the staId matching the
1547 * interface in the firmware is sessionId + 1.
1548 */
1549 pLinkLayerStatsSetReq->staId = pAdapter->sessionId + 1;
1550
1551
1552 hddLog(VOS_TRACE_LEVEL_INFO,
1553 "LL_STATS_SET reqId = %d",
1554 pLinkLayerStatsSetReq->reqId);
1555 hddLog(VOS_TRACE_LEVEL_INFO,
1556 "LL_STATS_SET staId = %d", pLinkLayerStatsSetReq->staId);
1557 hddLog(VOS_TRACE_LEVEL_INFO,
1558 "LL_STATS_SET mpduSizeThreshold = %d",
1559 pLinkLayerStatsSetReq->mpduSizeThreshold);
1560 hddLog(VOS_TRACE_LEVEL_INFO,
1561 "LL_STATS_SET aggressive Statistics Gathering = %d",
1562 pLinkLayerStatsSetReq->aggressiveStatisticsGathering);
1563
1564 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1565 pHddCtx->hHal,
1566 pAdapter->sessionId,
1567 hdd_link_layer_stats_ind_callback,
1568 pAdapter))
1569 {
1570 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1571 "sme_SetLinkLayerStatsIndCB Failed", __func__);
1572 vos_mem_free(pLinkLayerStatsSetReq);
1573 return -EINVAL;
1574
1575 }
1576 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
1577 pLinkLayerStatsSetReq))
1578 {
1579 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1580 "sme_LLStatsSetReq Failed", __func__);
1581 vos_mem_free(pLinkLayerStatsSetReq);
1582 return -EINVAL;
1583 }
1584
1585 pAdapter->isLinkLayerStatsSet = 1;
1586
1587 return 0;
1588}
1589
1590const struct
1591nla_policy
1592qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1593{
1594 /* Unsigned 32bit value provided by the caller issuing the GET stats
1595 * command. When reporting
1596 * the stats results, the driver uses the same value to indicate
1597 * which GET request the results
1598 * correspond to.
1599 */
1600 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1601
1602 /* Unsigned 32bit value . bit mask to identify what statistics are
1603 requested for retrieval */
1604 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1605};
1606
1607static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1608 struct wireless_dev *wdev,
1609 void *data,
1610 int data_len)
1611{
1612 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1613 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
1614 tpSirLLStatsGetReq pLinkLayerStatsGetReq;
1615 struct net_device *dev = wdev->netdev;
1616 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1617 int status;
1618
1619 status = wlan_hdd_validate_context(pHddCtx);
1620 if (0 != status)
1621 {
1622 hddLog(VOS_TRACE_LEVEL_ERROR,
1623 FL("HDD context is not valid"));
1624 return -EINVAL ;
1625 }
1626
1627 if (NULL == pAdapter)
1628 {
1629 hddLog(VOS_TRACE_LEVEL_FATAL,
1630 "%s: HDD adapter is Null", __func__);
1631 return -ENODEV;
1632 }
1633
1634 if (!pAdapter->isLinkLayerStatsSet)
1635 {
1636 hddLog(VOS_TRACE_LEVEL_FATAL,
1637 "%s: isLinkLayerStatsSet : %d",
1638 __func__, pAdapter->isLinkLayerStatsSet);
1639 return -EINVAL;
1640 }
1641
1642 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
1643 (struct nlattr *)data,
1644 data_len, qca_wlan_vendor_ll_get_policy))
1645 {
1646 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1647 return -EINVAL;
1648 }
1649
1650 if (!tb_vendor
1651 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
1652 {
1653 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
1654 return -EINVAL;
1655 }
1656
1657 if (!tb_vendor
1658 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
1659 {
1660 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
1661 return -EINVAL;
1662 }
1663
1664 pLinkLayerStatsGetReq = vos_mem_malloc(sizeof(tSirLLStatsGetReq));
1665
1666 if (NULL == pLinkLayerStatsGetReq)
1667 {
1668 hddLog(VOS_TRACE_LEVEL_ERROR,
1669 FL("Unable to allocate memory to pLinkLayerStatsGetReq"));
1670 return -ENOMEM;
1671 }
1672
1673 pLinkLayerStatsGetReq->reqId =
1674 nla_get_u32( tb_vendor[
1675 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
1676 pLinkLayerStatsGetReq->paramIdMask =
1677 nla_get_u32( tb_vendor[
1678 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
1679
1680 /* staId 0 in Firmware is reserved for Broadcast/Multicast data.
1681 * Hence the interface staId start from 1. Hence the staId matching the
1682 * interface in the firmware is sessionId + 1.
1683 */
1684 pLinkLayerStatsGetReq->staId = pAdapter->sessionId + 1;
1685
1686 hddLog(VOS_TRACE_LEVEL_INFO,
1687 "LL_STATS_GET reqId = %d", pLinkLayerStatsGetReq->reqId);
1688 hddLog(VOS_TRACE_LEVEL_INFO,
1689 "LL_STATS_GET staId = %d", pLinkLayerStatsGetReq->staId);
1690 hddLog(VOS_TRACE_LEVEL_INFO,
1691 "LL_STATS_GET paramIdMask = %d",
1692 pLinkLayerStatsGetReq->paramIdMask);
1693
1694 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
1695 pLinkLayerStatsGetReq))
1696 {
1697 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1698 "sme_LLStatsGetReq Failed", __func__);
1699 vos_mem_free(pLinkLayerStatsGetReq);
1700 return -EINVAL;
1701 }
1702 return 0;
1703}
1704
1705const struct
1706nla_policy
1707qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
1708{
1709 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
1710 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
1711 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
1712 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
1713};
1714
1715static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
1716 struct wireless_dev *wdev,
1717 void *data,
1718 int data_len)
1719{
1720 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1721 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
1722 tpSirLLStatsClearReq pLinkLayerStatsClearReq;
1723 struct net_device *dev = wdev->netdev;
1724 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1725 u32 statsClearReqMask;
1726 u8 stopReq;
1727 int status;
1728
1729 status = wlan_hdd_validate_context(pHddCtx);
1730 if (0 != status)
1731 {
1732 hddLog(VOS_TRACE_LEVEL_ERROR,
1733 FL("HDD context is not valid"));
1734 return -EINVAL;
1735 }
1736
1737 if (NULL == pAdapter)
1738 {
1739 hddLog(VOS_TRACE_LEVEL_FATAL,
1740 "%s: HDD adapter is Null", __func__);
1741 return -ENODEV;
1742 }
1743
1744 if (!pAdapter->isLinkLayerStatsSet)
1745 {
1746 hddLog(VOS_TRACE_LEVEL_FATAL,
1747 "%s: isLinkLayerStatsSet : %d",
1748 __func__, pAdapter->isLinkLayerStatsSet);
1749 return -EINVAL;
1750 }
1751
1752 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
1753 (struct nlattr *)data,
1754 data_len, qca_wlan_vendor_ll_clr_policy))
1755 {
1756 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1757 return -EINVAL;
1758 }
1759
1760 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
1761
1762 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
1763 {
1764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
1765 return -EINVAL;
1766
1767 }
1768
1769 pLinkLayerStatsClearReq = vos_mem_malloc(sizeof(tSirLLStatsClearReq));
1770 if (NULL == pLinkLayerStatsClearReq)
1771 {
1772 hddLog(VOS_TRACE_LEVEL_ERROR,
1773 FL("Unable to allocate memory to pLinkLayerStatsClearReq"));
1774 return -ENOMEM;
1775 }
1776
1777 statsClearReqMask = pLinkLayerStatsClearReq->statsClearReqMask =
1778 nla_get_u32(
1779 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
1780
1781 stopReq = pLinkLayerStatsClearReq->stopReq =
1782 nla_get_u8(
1783 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
1784
1785 // Shall take the request Id if the Upper layers pass. 1 For now.
1786 pLinkLayerStatsClearReq->reqId = 1;
1787
1788 /* staId 0 in Firmware is reserved for Broadcast/Multicast data.
1789 * Hence the interface staId start from 1. Hence the staId matching the
1790 * interface in the firmware is sessionId + 1.
1791 */
1792 pLinkLayerStatsClearReq->staId = pAdapter->sessionId + 1;
1793
1794 hddLog(VOS_TRACE_LEVEL_INFO,
1795 "LL_STATS_CLEAR reqId = %d", pLinkLayerStatsClearReq->reqId);
1796 hddLog(VOS_TRACE_LEVEL_INFO,
1797 "LL_STATS_CLEAR staId = %d", pLinkLayerStatsClearReq->staId);
1798 hddLog(VOS_TRACE_LEVEL_INFO,
1799 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
1800 pLinkLayerStatsClearReq->statsClearReqMask);
1801 hddLog(VOS_TRACE_LEVEL_INFO,
1802 "LL_STATS_CLEAR stopReq = %d",
1803 pLinkLayerStatsClearReq->stopReq);
1804
1805 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
1806 pLinkLayerStatsClearReq))
1807 {
1808 struct sk_buff *temp_skbuff;
1809 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
1810 2 * sizeof(u32) +
1811 NLMSG_HDRLEN);
1812
1813 if (temp_skbuff != NULL)
1814 {
1815
1816 if (nla_put_u32(temp_skbuff,
1817 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
1818 statsClearReqMask) ||
1819 nla_put_u32(temp_skbuff,
1820 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
1821 stopReq))
1822 {
1823 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
1824 kfree_skb(temp_skbuff);
1825 return -EINVAL;
1826 }
1827 /* If the ask is to stop the stats collection as part of clear
1828 * (stopReq = 1) , ensure that no further requests of get
1829 * go to the firmware by having isLinkLayerStatsSet set to 0.
1830 * However it the stopReq as part of the clear request is 0 ,
1831 * the request to get the statistics are ehonoured as in this
1832 * case the firmware is just asked to clear the statistics.
1833 */
1834 if (pLinkLayerStatsClearReq->stopReq == 1)
1835 pAdapter->isLinkLayerStatsSet = 0;
1836 return cfg80211_vendor_cmd_reply(temp_skbuff);
1837 }
1838 return -ENOMEM;
1839 }
1840 vos_mem_free(pLinkLayerStatsClearReq);
1841 return -EINVAL;
1842}
1843#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1844
1845const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
1846{
1847#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1848 {
1849 .info.vendor_id = QCA_NL80211_VENDOR_ID,
1850 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
1851 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
1852 WIPHY_VENDOR_CMD_NEED_NETDEV |
1853 WIPHY_VENDOR_CMD_NEED_RUNNING,
1854 .doit = wlan_hdd_cfg80211_ll_stats_clear
1855 },
1856
1857 {
1858 .info.vendor_id = QCA_NL80211_VENDOR_ID,
1859 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
1860 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
1861 WIPHY_VENDOR_CMD_NEED_NETDEV |
1862 WIPHY_VENDOR_CMD_NEED_RUNNING,
1863 .doit = wlan_hdd_cfg80211_ll_stats_set
1864 },
1865
1866 {
1867 .info.vendor_id = QCA_NL80211_VENDOR_ID,
1868 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
1869 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
1870 WIPHY_VENDOR_CMD_NEED_NETDEV |
1871 WIPHY_VENDOR_CMD_NEED_RUNNING,
1872 .doit = wlan_hdd_cfg80211_ll_stats_get
1873 }
1874#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1875};
1876
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001877/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05301878static const
1879struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001880{
1881#ifdef FEATURE_WLAN_CH_AVOID
1882 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301883 .vendor_id = QCA_NL80211_VENDOR_ID,
1884 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001885 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05301886#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
1887#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1888 {
1889 /* Index = 1*/
1890 .vendor_id = QCA_NL80211_VENDOR_ID,
1891 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
1892 },
1893 {
1894 /* Index = 2*/
1895 .vendor_id = QCA_NL80211_VENDOR_ID,
1896 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
1897 },
1898 {
1899 /* Index = 3*/
1900 .vendor_id = QCA_NL80211_VENDOR_ID,
1901 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
1902 },
1903 {
1904 /* Index = 4*/
1905 .vendor_id = QCA_NL80211_VENDOR_ID,
1906 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
1907 },
1908 {
1909 /* Index = 5*/
1910 .vendor_id = QCA_NL80211_VENDOR_ID,
1911 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
1912 },
1913 {
1914 /* Index = 6*/
1915 .vendor_id = QCA_NL80211_VENDOR_ID,
1916 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
1917 },
1918#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1919
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08001920};
1921
Jeff Johnson295189b2012-06-20 16:38:30 -07001922/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05301923 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301924 * This function is called by hdd_wlan_startup()
1925 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05301926 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05301928struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07001929{
1930 struct wiphy *wiphy;
1931 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301932 /*
1933 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 */
1935 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
1936
1937 if (!wiphy)
1938 {
1939 /* Print error and jump into err label and free the memory */
1940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
1941 return NULL;
1942 }
1943
Sunil Duttc69bccb2014-05-26 21:30:20 +05301944
Jeff Johnson295189b2012-06-20 16:38:30 -07001945 return wiphy;
1946}
1947
1948/*
1949 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301950 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 * private ioctl to change the band value
1952 */
1953int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
1954{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05301955 int i, j;
1956 eNVChannelEnabledType channelEnabledState;
1957
Jeff Johnsone7245742012-09-05 17:12:55 -07001958 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05301959
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05301960 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05301962
1963 if (NULL == wiphy->bands[i])
1964 {
1965 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
1966 __func__, i);
1967 continue;
1968 }
1969
1970 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
1971 {
1972 struct ieee80211_supported_band *band = wiphy->bands[i];
1973
1974 channelEnabledState = vos_nv_getChannelEnabledState(
1975 band->channels[j].hw_value);
1976
1977 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
1978 {
1979 // Enable Social channels for P2P
1980 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
1981 NV_CHANNEL_ENABLE == channelEnabledState)
1982 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
1983 else
1984 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
1985 continue;
1986 }
1987 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
1988 {
1989 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
1990 continue;
1991 }
1992
1993 if (NV_CHANNEL_DISABLE == channelEnabledState ||
1994 NV_CHANNEL_INVALID == channelEnabledState)
1995 {
1996 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
1997 }
1998 else if (NV_CHANNEL_DFS == channelEnabledState)
1999 {
2000 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
2001 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
2002 }
2003 else
2004 {
2005 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
2006 |IEEE80211_CHAN_RADAR);
2007 }
2008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 }
2010 return 0;
2011}
2012/*
2013 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302014 * This function is called by hdd_wlan_startup()
2015 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 * This function is used to initialize and register wiphy structure.
2017 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05302018int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 struct wiphy *wiphy,
2020 hdd_config_t *pCfg
2021 )
2022{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05302023 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05302024 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2025
Jeff Johnsone7245742012-09-05 17:12:55 -07002026 ENTER();
2027
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 /* Now bind the underlying wlan device with wiphy */
2029 set_wiphy_dev(wiphy, dev);
2030
2031 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07002032
Kiet Lam6c583332013-10-14 05:37:09 +05302033#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07002034 /* the flag for the other case would be initialzed in
2035 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07002036 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05302037#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07002038
Amar Singhalfddc28c2013-09-05 13:03:40 -07002039 /* This will disable updating of NL channels from passive to
2040 * active if a beacon is received on passive channel. */
2041 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07002042
Amar Singhalfddc28c2013-09-05 13:03:40 -07002043
Amar Singhala49cbc52013-10-08 18:37:44 -07002044
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002045#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002046 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
2047 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
2048 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07002049 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05302050 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002051#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07002052
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002053#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07002054 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08002055#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07002056 || pCfg->isFastRoamIniFeatureEnabled
2057#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002058#ifdef FEATURE_WLAN_ESE
2059 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07002060#endif
2061 )
2062 {
2063 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
2064 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08002065#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002066#ifdef FEATURE_WLAN_TDLS
2067 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
2068 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
2069#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05302070#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05302071 if (pCfg->configPNOScanSupport)
2072 {
2073 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
2074 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
2075 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
2076 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
2077 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05302078#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002079
Amar Singhalfddc28c2013-09-05 13:03:40 -07002080#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07002081 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
2082 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07002083 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07002084 driver need to determine what to do with both
2085 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07002086
2087 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07002088#else
2089 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07002090#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002091
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302092 wiphy->max_scan_ssids = MAX_SCAN_SSID;
2093
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +05302094 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07002095
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302096 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
2097
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302099 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 | BIT(NL80211_IFTYPE_P2P_CLIENT)
2102 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 | BIT(NL80211_IFTYPE_AP);
2104
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05302105 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08002106 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05302107#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
2108 if( pCfg->enableMCC )
2109 {
2110 /* Currently, supports up to two channels */
2111 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08002112
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05302113 if( !pCfg->allowMCCGODiffBI )
2114 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08002115
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05302116 }
2117 wiphy->iface_combinations = &wlan_hdd_iface_combination;
2118 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08002119#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05302120 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08002121
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 /* Before registering we need to update the ht capabilitied based
2123 * on ini values*/
2124 if( !pCfg->ShortGI20MhzEnable )
2125 {
2126 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
2127 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
2128 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
2129 }
2130
2131 if( !pCfg->ShortGI40MhzEnable )
2132 {
2133 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
2134 }
2135
2136 if( !pCfg->nChannelBondingMode5GHz )
2137 {
2138 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
2139 }
2140
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05302141 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05302142 if (true == hdd_is_5g_supported(pHddCtx))
2143 {
2144 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
2145 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05302146
2147 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
2148 {
2149
2150 if (NULL == wiphy->bands[i])
2151 {
2152 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
2153 __func__, i);
2154 continue;
2155 }
2156
2157 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
2158 {
2159 struct ieee80211_supported_band *band = wiphy->bands[i];
2160
2161 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
2162 {
2163 // Enable social channels for P2P
2164 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
2165 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
2166 else
2167 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
2168 continue;
2169 }
2170 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
2171 {
2172 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
2173 continue;
2174 }
2175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 }
2177 /*Initialise the supported cipher suite details*/
2178 wiphy->cipher_suites = hdd_cipher_suites;
2179 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
2180
2181 /*signal strength in mBm (100*dBm) */
2182 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
2183
2184#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 wiphy->max_remain_on_channel_duration = 1000;
2186#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002187
Sunil Duttc69bccb2014-05-26 21:30:20 +05302188 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
2189 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08002190 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
2191 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
2192
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05302193 EXIT();
2194 return 0;
2195}
2196
2197/* In this function we are registering wiphy. */
2198int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
2199{
2200 ENTER();
2201 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 if (0 > wiphy_register(wiphy))
2203 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05302204 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
2206 return -EIO;
2207 }
2208
2209 EXIT();
2210 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302211}
Jeff Johnson295189b2012-06-20 16:38:30 -07002212
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05302213/* In this function we are updating channel list when,
2214 regulatory domain is FCC and country code is US.
2215 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
2216 As per FCC smart phone is not a indoor device.
2217 GO should not opeate on indoor channels */
2218void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
2219{
2220 int j;
2221 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2222 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
2223 //Default counrtycode from NV at the time of wiphy initialization.
2224 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
2225 &defaultCountryCode[0]))
2226 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002227 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05302228 }
2229 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
2230 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05302231 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
2232 {
2233 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
2234 return;
2235 }
2236 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
2237 {
2238 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
2239 // Mark UNII -1 band channel as passive
2240 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
2241 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
2242 }
2243 }
2244}
2245
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05302246/* This function registers for all frame which supplicant is interested in */
2247void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002248{
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2250 /* Register for all P2P action, public action etc frames */
2251 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
2252
Jeff Johnsone7245742012-09-05 17:12:55 -07002253 ENTER();
2254
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 /* Right now we are registering these frame when driver is getting
2256 initialized. Once we will move to 2.6.37 kernel, in which we have
2257 frame register ops, we will move this code as a part of that */
2258 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302259 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
2261
2262 /* GAS Initial Response */
2263 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
2264 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302265
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 /* GAS Comeback Request */
2267 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
2268 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
2269
2270 /* GAS Comeback Response */
2271 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
2272 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
2273
2274 /* P2P Public Action */
2275 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302276 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 P2P_PUBLIC_ACTION_FRAME_SIZE );
2278
2279 /* P2P Action */
2280 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
2281 (v_U8_t*)P2P_ACTION_FRAME,
2282 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07002283
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05302284 /* WNM BSS Transition Request frame */
2285 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
2286 (v_U8_t*)WNM_BSS_ACTION_FRAME,
2287 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07002288
2289 /* WNM-Notification */
2290 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
2291 (v_U8_t*)WNM_NOTIFICATION_FRAME,
2292 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002293}
2294
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05302295void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07002296{
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
2298 /* Register for all P2P action, public action etc frames */
2299 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
2300
Jeff Johnsone7245742012-09-05 17:12:55 -07002301 ENTER();
2302
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 /* Right now we are registering these frame when driver is getting
2304 initialized. Once we will move to 2.6.37 kernel, in which we have
2305 frame register ops, we will move this code as a part of that */
2306 /* GAS Initial Request */
2307
2308 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
2309 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
2310
2311 /* GAS Initial Response */
2312 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
2313 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302314
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 /* GAS Comeback Request */
2316 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
2317 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
2318
2319 /* GAS Comeback Response */
2320 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
2321 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
2322
2323 /* P2P Public Action */
2324 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302325 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 P2P_PUBLIC_ACTION_FRAME_SIZE );
2327
2328 /* P2P Action */
2329 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
2330 (v_U8_t*)P2P_ACTION_FRAME,
2331 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07002332 /* WNM-Notification */
2333 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
2334 (v_U8_t*)WNM_NOTIFICATION_FRAME,
2335 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002336}
2337
2338#ifdef FEATURE_WLAN_WAPI
2339void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
2340 const u8 *mac_addr, u8 *key , int key_Len)
2341{
2342 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2343 tCsrRoamSetKey setKey;
2344 v_BOOL_t isConnected = TRUE;
2345 int status = 0;
2346 v_U32_t roamId= 0xFF;
2347 tANI_U8 *pKeyPtr = NULL;
2348 int n = 0;
2349
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05302350 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
2351 __func__, hdd_device_modetoString(pAdapter->device_mode),
2352 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002353
Gopichand Nakkalae7480202013-02-11 15:24:22 +05302354 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 setKey.keyId = key_index; // Store Key ID
2356 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
2357 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
2358 setKey.paeRole = 0 ; // the PAE role
2359 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
2360 {
2361 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
2362 }
2363 else
2364 {
2365 isConnected = hdd_connIsConnected(pHddStaCtx);
2366 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
2367 }
2368 setKey.keyLength = key_Len;
2369 pKeyPtr = setKey.Key;
2370 memcpy( pKeyPtr, key, key_Len);
2371
Arif Hussain6d2a3322013-11-17 19:50:10 -08002372 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 __func__, key_Len);
2374 for (n = 0 ; n < key_Len; n++)
2375 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
2376 __func__,n,setKey.Key[n]);
2377
2378 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
2379 if ( isConnected )
2380 {
2381 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2382 pAdapter->sessionId, &setKey, &roamId );
2383 }
2384 if ( status != 0 )
2385 {
2386 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2387 "[%4d] sme_RoamSetKey returned ERROR status= %d",
2388 __LINE__, status );
2389 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2390 }
2391}
2392#endif /* FEATURE_WLAN_WAPI*/
2393
2394#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302395int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002396 beacon_data_t **ppBeacon,
2397 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002398#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302399int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002400 beacon_data_t **ppBeacon,
2401 struct cfg80211_beacon_data *params,
2402 int dtim_period)
2403#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302404{
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 int size;
2406 beacon_data_t *beacon = NULL;
2407 beacon_data_t *old = NULL;
2408 int head_len,tail_len;
2409
Jeff Johnsone7245742012-09-05 17:12:55 -07002410 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302412 {
2413 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2414 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002417
2418 old = pAdapter->sessionCtx.ap.beacon;
2419
2420 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302421 {
2422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2423 FL("session(%d) old and new heads points to NULL"),
2424 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302426 }
2427
2428 if (params->tail && !params->tail_len)
2429 {
2430 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2431 FL("tail_len is zero but tail is not NULL"));
2432 return -EINVAL;
2433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002434
Jeff Johnson295189b2012-06-20 16:38:30 -07002435#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
2436 /* Kernel 3.0 is not updating dtim_period for set beacon */
2437 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302438 {
2439 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2440 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002443#endif
2444
2445 if(params->head)
2446 head_len = params->head_len;
2447 else
2448 head_len = old->head_len;
2449
2450 if(params->tail || !old)
2451 tail_len = params->tail_len;
2452 else
2453 tail_len = old->tail_len;
2454
2455 size = sizeof(beacon_data_t) + head_len + tail_len;
2456
2457 beacon = kzalloc(size, GFP_KERNEL);
2458
2459 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302460 {
2461 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2462 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002465
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002466#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 if(params->dtim_period || !old )
2468 beacon->dtim_period = params->dtim_period;
2469 else
2470 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002471#else
2472 if(dtim_period || !old )
2473 beacon->dtim_period = dtim_period;
2474 else
2475 beacon->dtim_period = old->dtim_period;
2476#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302477
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
2479 beacon->tail = beacon->head + head_len;
2480 beacon->head_len = head_len;
2481 beacon->tail_len = tail_len;
2482
2483 if(params->head) {
2484 memcpy (beacon->head,params->head,beacon->head_len);
2485 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302486 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 if(old)
2488 memcpy (beacon->head,old->head,beacon->head_len);
2489 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302490
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 if(params->tail) {
2492 memcpy (beacon->tail,params->tail,beacon->tail_len);
2493 }
2494 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302495 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 memcpy (beacon->tail,old->tail,beacon->tail_len);
2497 }
2498
2499 *ppBeacon = beacon;
2500
2501 kfree(old);
2502
2503 return 0;
2504
2505}
Jeff Johnson295189b2012-06-20 16:38:30 -07002506
2507v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
2508{
2509 int left = length;
2510 v_U8_t *ptr = pIes;
2511 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302512
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302514 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002515 elem_id = ptr[0];
2516 elem_len = ptr[1];
2517 left -= 2;
2518 if(elem_len > left)
2519 {
2520 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002521 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 eid,elem_len,left);
2523 return NULL;
2524 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302525 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 {
2527 return ptr;
2528 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302529
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 left -= elem_len;
2531 ptr += (elem_len + 2);
2532 }
2533 return NULL;
2534}
2535
Jeff Johnson295189b2012-06-20 16:38:30 -07002536/* Check if rate is 11g rate or not */
2537static int wlan_hdd_rate_is_11g(u8 rate)
2538{
Sanjay Devnani28322e22013-06-21 16:13:40 -07002539 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 u8 i;
2541 for (i = 0; i < 8; i++)
2542 {
2543 if(rate == gRateArray[i])
2544 return TRUE;
2545 }
2546 return FALSE;
2547}
2548
2549/* Check for 11g rate and set proper 11g only mode */
2550static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
2551 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
2552{
2553 u8 i, num_rates = pIe[0];
2554
2555 pIe += 1;
2556 for ( i = 0; i < num_rates; i++)
2557 {
2558 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
2559 {
2560 /* If rate set have 11g rate than change the mode to 11G */
2561 *pSapHw_mode = eSAP_DOT11_MODE_11g;
2562 if (pIe[i] & BASIC_RATE_MASK)
2563 {
2564 /* If we have 11g rate as basic rate, it means mode
2565 is 11g only mode.
2566 */
2567 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
2568 *pCheckRatesfor11g = FALSE;
2569 }
2570 }
2571 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
2572 {
2573 *require_ht = TRUE;
2574 }
2575 }
2576 return;
2577}
2578
2579static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
2580{
2581 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
2582 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
2583 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
2584 u8 checkRatesfor11g = TRUE;
2585 u8 require_ht = FALSE;
2586 u8 *pIe=NULL;
2587
2588 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
2589
2590 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
2591 pBeacon->head_len, WLAN_EID_SUPP_RATES);
2592 if (pIe != NULL)
2593 {
2594 pIe += 1;
2595 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
2596 &pConfig->SapHw_mode);
2597 }
2598
2599 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
2600 WLAN_EID_EXT_SUPP_RATES);
2601 if (pIe != NULL)
2602 {
2603
2604 pIe += 1;
2605 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
2606 &pConfig->SapHw_mode);
2607 }
2608
2609 if( pConfig->channel > 14 )
2610 {
2611 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
2612 }
2613
2614 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
2615 WLAN_EID_HT_CAPABILITY);
2616
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302617 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 {
2619 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
2620 if(require_ht)
2621 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
2622 }
2623}
2624
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302625static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
2626 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
2627{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07002628 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302629 v_U8_t *pIe = NULL;
2630 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
2631
2632 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
2633 pBeacon->tail, pBeacon->tail_len);
2634
2635 if (pIe)
2636 {
2637 ielen = pIe[1] + 2;
2638 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
2639 {
2640 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
2641 }
2642 else
2643 {
2644 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
2645 return -EINVAL;
2646 }
2647 *total_ielen += ielen;
2648 }
2649 return 0;
2650}
2651
Arif Hussaine7f3ea52013-09-12 21:56:36 -07002652static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
2653 v_U8_t *genie, v_U8_t *total_ielen)
2654{
2655 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
2656 int left = pBeacon->tail_len;
2657 v_U8_t *ptr = pBeacon->tail;
2658 v_U8_t elem_id, elem_len;
2659 v_U16_t ielen = 0;
2660
2661 if ( NULL == ptr || 0 == left )
2662 return;
2663
2664 while (left >= 2)
2665 {
2666 elem_id = ptr[0];
2667 elem_len = ptr[1];
2668 left -= 2;
2669 if (elem_len > left)
2670 {
2671 hddLog( VOS_TRACE_LEVEL_ERROR,
2672 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
2673 elem_id, elem_len, left);
2674 return;
2675 }
2676 if (IE_EID_VENDOR == elem_id)
2677 {
2678 /* skipping the VSIE's which we don't want to include or
2679 * it will be included by existing code
2680 */
2681 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
2682#ifdef WLAN_FEATURE_WFD
2683 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
2684#endif
2685 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
2686 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
2687 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
2688 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
2689 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
2690 {
2691 ielen = ptr[1] + 2;
2692 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
2693 {
2694 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
2695 *total_ielen += ielen;
2696 }
2697 else
2698 {
2699 hddLog( VOS_TRACE_LEVEL_ERROR,
2700 "IE Length is too big "
2701 "IEs eid=%d elem_len=%d total_ie_lent=%d",
2702 elem_id, elem_len, *total_ielen);
2703 }
2704 }
2705 }
2706
2707 left -= elem_len;
2708 ptr += (elem_len + 2);
2709 }
2710 return;
2711}
2712
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002713#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002714static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
2715 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002716#else
2717static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
2718 struct cfg80211_beacon_data *params)
2719#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002720{
2721 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302722 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07002724 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002725
2726 genie = vos_mem_malloc(MAX_GENIE_LEN);
2727
2728 if(genie == NULL) {
2729
2730 return -ENOMEM;
2731 }
2732
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302733 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
2734 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302736 hddLog(LOGE,
2737 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302738 ret = -EINVAL;
2739 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 }
2741
2742#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302743 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
2744 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
2745 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302746 hddLog(LOGE,
2747 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302748 ret = -EINVAL;
2749 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 }
2751#endif
2752
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302753 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
2754 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05302756 hddLog(LOGE,
2757 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302758 ret = -EINVAL;
2759 goto done;
2760 }
2761
2762 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
2763 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07002764 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002766
2767 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2768 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
2769 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
2770 {
2771 hddLog(LOGE,
2772 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002773 ret = -EINVAL;
2774 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 }
2776
2777 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2778 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
2779 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
2780 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
2781 ==eHAL_STATUS_FAILURE)
2782 {
2783 hddLog(LOGE,
2784 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002785 ret = -EINVAL;
2786 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 }
2788
2789 // Added for ProResp IE
2790 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
2791 {
2792 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
2793 u8 probe_rsp_ie_len[3] = {0};
2794 u8 counter = 0;
2795 /* Check Probe Resp Length if it is greater then 255 then Store
2796 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
2797 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
2798 Store More then 255 bytes into One Variable.
2799 */
2800 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
2801 {
2802 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
2803 {
2804 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
2805 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
2806 }
2807 else
2808 {
2809 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
2810 rem_probe_resp_ie_len = 0;
2811 }
2812 }
2813
2814 rem_probe_resp_ie_len = 0;
2815
2816 if (probe_rsp_ie_len[0] > 0)
2817 {
2818 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2819 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
2820 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
2821 probe_rsp_ie_len[0], NULL,
2822 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
2823 {
2824 hddLog(LOGE,
2825 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002826 ret = -EINVAL;
2827 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002828 }
2829 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
2830 }
2831
2832 if (probe_rsp_ie_len[1] > 0)
2833 {
2834 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2835 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
2836 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
2837 probe_rsp_ie_len[1], NULL,
2838 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
2839 {
2840 hddLog(LOGE,
2841 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002842 ret = -EINVAL;
2843 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 }
2845 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
2846 }
2847
2848 if (probe_rsp_ie_len[2] > 0)
2849 {
2850 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2851 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
2852 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
2853 probe_rsp_ie_len[2], NULL,
2854 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
2855 {
2856 hddLog(LOGE,
2857 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002858 ret = -EINVAL;
2859 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 }
2861 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
2862 }
2863
2864 if (probe_rsp_ie_len[1] == 0 )
2865 {
2866 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2867 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
2868 eANI_BOOLEAN_FALSE) )
2869 {
2870 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002871 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 }
2873 }
2874
2875 if (probe_rsp_ie_len[2] == 0 )
2876 {
2877 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2878 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
2879 eANI_BOOLEAN_FALSE) )
2880 {
2881 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002882 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 }
2884 }
2885
2886 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2887 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
2888 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
2889 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
2890 == eHAL_STATUS_FAILURE)
2891 {
2892 hddLog(LOGE,
2893 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002894 ret = -EINVAL;
2895 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002896 }
2897 }
2898 else
2899 {
2900 // Reset WNI_CFG_PROBE_RSP Flags
2901 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
2902
2903 hddLog(VOS_TRACE_LEVEL_INFO,
2904 "%s: No Probe Response IE received in set beacon",
2905 __func__);
2906 }
2907
2908 // Added for AssocResp IE
2909 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
2910 {
2911 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2912 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
2913 params->assocresp_ies_len, NULL,
2914 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
2915 {
2916 hddLog(LOGE,
2917 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002918 ret = -EINVAL;
2919 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002920 }
2921
2922 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2923 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
2924 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
2925 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
2926 == eHAL_STATUS_FAILURE)
2927 {
2928 hddLog(LOGE,
2929 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07002930 ret = -EINVAL;
2931 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 }
2933 }
2934 else
2935 {
2936 hddLog(VOS_TRACE_LEVEL_INFO,
2937 "%s: No Assoc Response IE received in set beacon",
2938 __func__);
2939
2940 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
2941 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2942 eANI_BOOLEAN_FALSE) )
2943 {
2944 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002945 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07002946 }
2947 }
2948
Jeff Johnsone7245742012-09-05 17:12:55 -07002949done:
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05302951 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07002952}
Jeff Johnson295189b2012-06-20 16:38:30 -07002953
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302954/*
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 * FUNCTION: wlan_hdd_validate_operation_channel
2956 * called by wlan_hdd_cfg80211_start_bss() and
2957 * wlan_hdd_cfg80211_set_channel()
2958 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302959 * channel list.
2960 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07002961VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07002962{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302963
Jeff Johnson295189b2012-06-20 16:38:30 -07002964 v_U32_t num_ch = 0;
2965 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
2966 u32 indx = 0;
2967 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05302968 v_U8_t fValidChannel = FALSE, count = 0;
2969 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302970
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2972
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05302973 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05302975 /* Validate the channel */
2976 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05302978 if ( channel == rfChannels[count].channelNum )
2979 {
2980 fValidChannel = TRUE;
2981 break;
2982 }
2983 }
2984 if (fValidChannel != TRUE)
2985 {
2986 hddLog(VOS_TRACE_LEVEL_ERROR,
2987 "%s: Invalid Channel [%d]", __func__, channel);
2988 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 }
2990 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05302991 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05302993 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
2994 valid_ch, &num_ch))
2995 {
2996 hddLog(VOS_TRACE_LEVEL_ERROR,
2997 "%s: failed to get valid channel list", __func__);
2998 return VOS_STATUS_E_FAILURE;
2999 }
3000 for (indx = 0; indx < num_ch; indx++)
3001 {
3002 if (channel == valid_ch[indx])
3003 {
3004 break;
3005 }
3006 }
3007
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05303008 if (indx >= num_ch)
3009 {
3010 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
3011 {
3012 eCsrBand band;
3013 unsigned int freq;
3014
3015 sme_GetFreqBand(hHal, &band);
3016
3017 if (eCSR_BAND_5G == band)
3018 {
3019#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
3020 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
3021 {
3022 freq = ieee80211_channel_to_frequency(channel,
3023 IEEE80211_BAND_2GHZ);
3024 }
3025 else
3026 {
3027 freq = ieee80211_channel_to_frequency(channel,
3028 IEEE80211_BAND_5GHZ);
3029 }
3030#else
3031 freq = ieee80211_channel_to_frequency(channel);
3032#endif
3033 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
3034 return VOS_STATUS_SUCCESS;
3035 }
3036 }
3037
3038 hddLog(VOS_TRACE_LEVEL_ERROR,
3039 "%s: Invalid Channel [%d]", __func__, channel);
3040 return VOS_STATUS_E_FAILURE;
3041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05303043
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303045
Jeff Johnson295189b2012-06-20 16:38:30 -07003046}
3047
Viral Modi3a32cc52013-02-08 11:14:52 -08003048/**
3049 * FUNCTION: wlan_hdd_cfg80211_set_channel
3050 * This function is used to set the channel number
3051 */
3052static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
3053 struct ieee80211_channel *chan,
3054 enum nl80211_channel_type channel_type
3055 )
3056{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303057 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08003058 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07003059 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08003060 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303061 hdd_context_t *pHddCtx;
3062 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08003063
3064 ENTER();
3065
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303066
Viral Modi3a32cc52013-02-08 11:14:52 -08003067 if( NULL == dev )
3068 {
3069 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003070 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08003071 return -ENODEV;
3072 }
3073 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
3074
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303075 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3076 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
3077 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08003078 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303079 "%s: device_mode = %s (%d) freq = %d", __func__,
3080 hdd_device_modetoString(pAdapter->device_mode),
3081 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303082
3083 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3084 status = wlan_hdd_validate_context(pHddCtx);
3085
3086 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08003087 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303088 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3089 "%s: HDD context is not valid", __func__);
3090 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08003091 }
3092
3093 /*
3094 * Do freq to chan conversion
3095 * TODO: for 11a
3096 */
3097
3098 channel = ieee80211_frequency_to_channel(freq);
3099
3100 /* Check freq range */
3101 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
3102 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
3103 {
3104 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003105 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08003106 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
3107 WNI_CFG_CURRENT_CHANNEL_STAMAX);
3108 return -EINVAL;
3109 }
3110
3111 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3112
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05303113 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
3114 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08003115 {
3116 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
3117 {
3118 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003119 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08003120 return -EINVAL;
3121 }
3122 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3123 "%s: set channel to [%d] for device mode =%d",
3124 __func__, channel,pAdapter->device_mode);
3125 }
3126 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08003127 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08003128 )
3129 {
3130 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3131 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
3132 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3133
3134 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
3135 {
3136 /* Link is up then return cant set channel*/
3137 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003138 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08003139 return -EINVAL;
3140 }
3141
3142 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
3143 pHddStaCtx->conn_info.operationChannel = channel;
3144 pRoamProfile->ChannelInfo.ChannelList =
3145 &pHddStaCtx->conn_info.operationChannel;
3146 }
3147 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08003148 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08003149 )
3150 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05303151 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
3152 {
3153 if(VOS_STATUS_SUCCESS !=
3154 wlan_hdd_validate_operation_channel(pAdapter,channel))
3155 {
3156 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003157 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05303158 return -EINVAL;
3159 }
3160 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
3161 }
3162 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08003163 {
3164 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
3165
3166 /* If auto channel selection is configured as enable/ 1 then ignore
3167 channel set by supplicant
3168 */
3169 if ( cfg_param->apAutoChannelSelection )
3170 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05303171 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
3172 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08003173 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303174 "%s: set channel to auto channel (0) for device mode =%s (%d)",
3175 __func__, hdd_device_modetoString(pAdapter->device_mode),
3176 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08003177 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05303178 else
3179 {
3180 if(VOS_STATUS_SUCCESS !=
3181 wlan_hdd_validate_operation_channel(pAdapter,channel))
3182 {
3183 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003184 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05303185 return -EINVAL;
3186 }
3187 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
3188 }
Viral Modi3a32cc52013-02-08 11:14:52 -08003189 }
3190 }
3191 else
3192 {
3193 hddLog(VOS_TRACE_LEVEL_FATAL,
3194 "%s: Invalid device mode failed to set valid channel", __func__);
3195 return -EINVAL;
3196 }
3197 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303198 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08003199}
3200
Jeff Johnson295189b2012-06-20 16:38:30 -07003201#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
3202static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
3203 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003204#else
3205static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
3206 struct cfg80211_beacon_data *params,
3207 const u8 *ssid, size_t ssid_len,
3208 enum nl80211_hidden_ssid hidden_ssid)
3209#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003210{
3211 tsap_Config_t *pConfig;
3212 beacon_data_t *pBeacon = NULL;
3213 struct ieee80211_mgmt *pMgmt_frame;
3214 v_U8_t *pIe=NULL;
3215 v_U16_t capab_info;
3216 eCsrAuthType RSNAuthType;
3217 eCsrEncryptionType RSNEncryptType;
3218 eCsrEncryptionType mcRSNEncryptType;
3219 int status = VOS_STATUS_SUCCESS;
3220 tpWLAN_SAPEventCB pSapEventCallback;
3221 hdd_hostapd_state_t *pHostapdState;
3222 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
3223 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05303224 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003225 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05303226 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08003228 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Chet Lanctot40142442014-05-20 13:39:25 -07003229 v_BOOL_t MFPCapable = VOS_FALSE;
3230 v_BOOL_t MFPRequired = VOS_FALSE;
Abhishek Singhf0ac1752014-03-05 17:47:09 +05303231 eHddDot11Mode sapDot11Mode =
3232 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003233
3234 ENTER();
3235
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05303236 iniConfig = pHddCtx->cfg_ini;
3237
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
3239
3240 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
3241
3242 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
3243
3244 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
3245
3246 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
3247
3248 //channel is already set in the set_channel Call back
3249 //pConfig->channel = pCommitConfig->channel;
3250
3251 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303252 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
3254
3255 pConfig->dtim_period = pBeacon->dtim_period;
3256
Arif Hussain6d2a3322013-11-17 19:50:10 -08003257 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 pConfig->dtim_period);
3259
3260
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08003261 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07003262 {
3263 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05303265 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
3266 {
3267 tANI_BOOLEAN restartNeeded;
3268 pConfig->ieee80211d = 1;
3269 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
3270 sme_setRegInfo(hHal, pConfig->countryCode);
3271 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
3272 }
3273 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003275 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003276 pConfig->ieee80211d = 1;
3277 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
3278 sme_setRegInfo(hHal, pConfig->countryCode);
3279 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07003281 else
3282 {
3283 pConfig->ieee80211d = 0;
3284 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05303285 /*
3286 * If auto channel is configured i.e. channel is 0,
3287 * so skip channel validation.
3288 */
3289 if( AUTO_CHANNEL_SELECT != pConfig->channel )
3290 {
3291 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
3292 {
3293 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003294 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05303295 return -EINVAL;
3296 }
3297 }
3298 else
3299 {
3300 if(1 != pHddCtx->is_dynamic_channel_range_set)
3301 {
3302 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
3303 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
3304 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
3305 }
3306 pHddCtx->is_dynamic_channel_range_set = 0;
3307 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07003309 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 {
3311 pConfig->ieee80211d = 0;
3312 }
3313 pConfig->authType = eSAP_AUTO_SWITCH;
3314
3315 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303316
3317 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
3319
3320 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
3321
3322 /*Set wps station to configured*/
3323 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
3324
3325 if(pIe)
3326 {
3327 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
3328 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003329 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 return -EINVAL;
3331 }
3332 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
3333 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07003334 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 /* Check 15 bit of WPS IE as it contain information for wps state
3336 * WPS state
3337 */
3338 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
3339 {
3340 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
3341 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
3342 {
3343 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
3344 }
3345 }
3346 }
3347 else
3348 {
3349 pConfig->wps_state = SAP_WPS_DISABLED;
3350 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303351 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07003352
3353 pConfig->RSNWPAReqIELength = 0;
3354 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303355 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 WLAN_EID_RSN);
3357 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303358 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003359 pConfig->RSNWPAReqIELength = pIe[1] + 2;
3360 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
3361 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303362 /* The actual processing may eventually be more extensive than
3363 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 * by the app.
3365 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303366 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
3368 &RSNEncryptType,
3369 &mcRSNEncryptType,
3370 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08003371 &MFPCapable,
3372 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 pConfig->pRSNWPAReqIE[1]+2,
3374 pConfig->pRSNWPAReqIE );
3375
3376 if( VOS_STATUS_SUCCESS == status )
3377 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303378 /* Now copy over all the security attributes you have
3379 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 * */
3381 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
3382 pConfig->mcRSNEncryptType = mcRSNEncryptType;
3383 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
3384 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303385 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003386 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
3388 }
3389 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303390
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
3392 pBeacon->tail, pBeacon->tail_len);
3393
3394 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
3395 {
3396 if (pConfig->pRSNWPAReqIE)
3397 {
3398 /*Mixed mode WPA/WPA2*/
3399 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
3400 pConfig->RSNWPAReqIELength += pIe[1] + 2;
3401 }
3402 else
3403 {
3404 pConfig->RSNWPAReqIELength = pIe[1] + 2;
3405 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
3406 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303407 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
3409 &RSNEncryptType,
3410 &mcRSNEncryptType,
3411 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08003412 &MFPCapable,
3413 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 pConfig->pRSNWPAReqIE[1]+2,
3415 pConfig->pRSNWPAReqIE );
3416
3417 if( VOS_STATUS_SUCCESS == status )
3418 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303419 /* Now copy over all the security attributes you have
3420 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 * */
3422 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
3423 pConfig->mcRSNEncryptType = mcRSNEncryptType;
3424 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
3425 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05303426 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08003427 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
3429 }
3430 }
3431 }
3432
Jeff Johnson4416a782013-03-25 14:17:50 -07003433 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
3434 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
3435 return -EINVAL;
3436 }
3437
Jeff Johnson295189b2012-06-20 16:38:30 -07003438 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
3439
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003440#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 if (params->ssid != NULL)
3442 {
3443 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
3444 pConfig->SSIDinfo.ssid.length = params->ssid_len;
3445 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
3446 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
3447 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003448#else
3449 if (ssid != NULL)
3450 {
3451 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
3452 pConfig->SSIDinfo.ssid.length = ssid_len;
3453 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
3454 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
3455 }
3456#endif
3457
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303458 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303460
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 /* default value */
3462 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
3463 pConfig->num_accept_mac = 0;
3464 pConfig->num_deny_mac = 0;
3465
3466 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
3467 pBeacon->tail, pBeacon->tail_len);
3468
3469 /* pIe for black list is following form:
3470 type : 1 byte
3471 length : 1 byte
3472 OUI : 4 bytes
3473 acl type : 1 byte
3474 no of mac addr in black list: 1 byte
3475 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303476 */
3477 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 {
3479 pConfig->SapMacaddr_acl = pIe[6];
3480 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08003481 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05303483 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
3484 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
3486 for (i = 0; i < pConfig->num_deny_mac; i++)
3487 {
3488 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
3489 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 }
3492 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
3493 pBeacon->tail, pBeacon->tail_len);
3494
3495 /* pIe for white list is following form:
3496 type : 1 byte
3497 length : 1 byte
3498 OUI : 4 bytes
3499 acl type : 1 byte
3500 no of mac addr in white list: 1 byte
3501 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303502 */
3503 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 {
3505 pConfig->SapMacaddr_acl = pIe[6];
3506 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08003507 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05303509 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
3510 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
3512 for (i = 0; i < pConfig->num_accept_mac; i++)
3513 {
3514 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
3515 acl_entry++;
3516 }
3517 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05303518
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 wlan_hdd_set_sapHwmode(pHostapdAdapter);
3520
Jeff Johnsone7245742012-09-05 17:12:55 -07003521#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08003522 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05303523 * This is valid only if mode is set to 11n in hostapd, either AUTO or
3524 * 11ac in .ini and 11ac is supported by both host and firmware.
3525 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
3526 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08003527 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
3528 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Abhishek Singhf0ac1752014-03-05 17:47:09 +05303529 (( sapDot11Mode == eHDD_DOT11_MODE_AUTO ) ||
3530 ( sapDot11Mode == eHDD_DOT11_MODE_11ac ) ||
3531 ( sapDot11Mode == eHDD_DOT11_MODE_11ac_ONLY ) ) &&
3532 (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
3533 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07003534 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05303535 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07003536 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05303537 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07003538
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05303539 /* If ACS disable and selected channel <= 14
3540 * OR
3541 * ACS enabled and ACS operating band is choosen as 2.4
3542 * AND
3543 * VHT in 2.4G Disabled
3544 * THEN
3545 * Fallback to 11N mode
3546 */
3547 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
3548 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Siddharth Bhalf42f8592014-05-15 13:39:07 +05303549 operatingBand == RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05303550 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07003551 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05303552 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
3553 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07003554 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
3555 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003556 }
3557#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303558
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003559 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
3560 {
3561 sme_SelectCBMode(hHal,
3562 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
3563 pConfig->channel);
3564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003565 // ht_capab is not what the name conveys,this is used for protection bitmap
3566 pConfig->ht_capab =
3567 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
3568
3569 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
3570 {
3571 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
3572 return -EINVAL;
3573 }
3574
3575 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303576 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07003577 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
3578 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303579 pConfig->obssProtEnabled =
3580 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003581
Chet Lanctot8cecea22014-02-11 19:09:36 -08003582#ifdef WLAN_FEATURE_11W
3583 pConfig->mfpCapable = MFPCapable;
3584 pConfig->mfpRequired = MFPRequired;
3585 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
3586 pConfig->mfpCapable, pConfig->mfpRequired);
3587#endif
3588
Arif Hussain6d2a3322013-11-17 19:50:10 -08003589 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08003591 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
3592 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
3593 (int)pConfig->channel);
3594 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
3595 pConfig->SapHw_mode, pConfig->privacy,
3596 pConfig->authType);
3597 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
3598 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
3599 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
3600 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07003601
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303602 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 {
3604 //Bss already started. just return.
3605 //TODO Probably it should update some beacon params.
3606 hddLog( LOGE, "Bss Already started...Ignore the request");
3607 EXIT();
3608 return 0;
3609 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303610
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 pConfig->persona = pHostapdAdapter->device_mode;
3612
3613 pSapEventCallback = hdd_hostapd_SAPEventCB;
3614 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
3615 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
3616 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003617 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 return -EINVAL;
3619 }
3620
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303621 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
3623
3624 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303625
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303627 {
3628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003629 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07003630 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 VOS_ASSERT(0);
3632 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303633
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
3635
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07003636#ifdef WLAN_FEATURE_P2P_DEBUG
3637 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
3638 {
3639 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
3640 {
3641 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
3642 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08003643 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07003644 }
3645 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
3646 {
3647 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
3648 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08003649 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07003650 }
3651 }
3652#endif
3653
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 pHostapdState->bCommit = TRUE;
3655 EXIT();
3656
3657 return 0;
3658}
3659
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003660#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303661static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
3662 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 struct beacon_parameters *params)
3664{
3665 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303666 hdd_context_t *pHddCtx;
3667 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003668
3669 ENTER();
3670
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303671 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3672 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
3673 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303674 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
3675 hdd_device_modetoString(pAdapter->device_mode),
3676 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003677
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303678 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3679 status = wlan_hdd_validate_context(pHddCtx);
3680
3681 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003682 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303683 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3684 "%s: HDD context is not valid", __func__);
3685 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003686 }
3687
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303688 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07003690 )
3691 {
3692 beacon_data_t *old,*new;
3693
3694 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303695
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303697 {
3698 hddLog(VOS_TRACE_LEVEL_WARN,
3699 FL("already beacon info added to session(%d)"),
3700 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003703
3704 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
3705
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303706 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 {
3708 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003709 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 return -EINVAL;
3711 }
3712
3713 pAdapter->sessionCtx.ap.beacon = new;
3714
3715 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
3716 }
3717
3718 EXIT();
3719 return status;
3720}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303721
3722static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 struct net_device *dev,
3724 struct beacon_parameters *params)
3725{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303726 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303727 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303728 hdd_context_t *pHddCtx;
3729 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003730
3731 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303732 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3733 TRACE_CODE_HDD_CFG80211_SET_BEACON,
3734 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303735 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
3736 __func__, hdd_device_modetoString(pAdapter->device_mode),
3737 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003738
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303739 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3740 status = wlan_hdd_validate_context(pHddCtx);
3741
3742 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003743 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303744 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3745 "%s: HDD context is not valid", __func__);
3746 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003747 }
3748
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303749 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303751 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 {
3753 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303754
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303756
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303758 {
3759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3760 FL("session(%d) old and new heads points to NULL"),
3761 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003764
3765 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
3766
3767 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303768 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003769 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 return -EINVAL;
3771 }
3772
3773 pAdapter->sessionCtx.ap.beacon = new;
3774
3775 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
3776 }
3777
3778 EXIT();
3779 return status;
3780}
3781
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003782#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
3783
3784#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07003785static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
3786 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003787#else
3788static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
3789 struct net_device *dev)
3790#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003791{
3792 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07003793 hdd_context_t *pHddCtx = NULL;
3794 hdd_scaninfo_t *pScanInfo = NULL;
3795 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303796 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303797 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07003798
3799 ENTER();
3800
3801 if (NULL == pAdapter)
3802 {
3803 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003804 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 return -ENODEV;
3806 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003807
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303808 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3809 TRACE_CODE_HDD_CFG80211_STOP_AP,
3810 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303811 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3812 status = wlan_hdd_validate_context(pHddCtx);
3813
3814 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003815 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303816 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3817 "%s: HDD context is not valid", __func__);
3818 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07003819 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003820
3821 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
3822 if (NULL == staAdapter)
3823 {
3824 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
3825 if (NULL == staAdapter)
3826 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07003827 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3828 "%s: HDD adapter context for STA/P2P-CLI is Null",
3829 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07003830 }
3831 }
3832
3833 pScanInfo = &pHddCtx->scan_info;
3834
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303835 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
3836 __func__, hdd_device_modetoString(pAdapter->device_mode),
3837 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003838
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303839 ret = wlan_hdd_scan_abort(pAdapter);
3840
3841 if (ret <= 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07003842 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3844 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303845
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303846 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07003847 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3849 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08003850
Jeff Johnsone7245742012-09-05 17:12:55 -07003851 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303852 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07003853 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05303854 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07003855 }
3856
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05303857 hdd_hostapd_stop(dev);
3858
Jeff Johnson295189b2012-06-20 16:38:30 -07003859 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 )
3862 {
3863 beacon_data_t *old;
3864
3865 old = pAdapter->sessionCtx.ap.beacon;
3866
3867 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303868 {
3869 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3870 FL("session(%d) beacon data points to NULL"),
3871 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303873 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003874
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003876
3877 mutex_lock(&pHddCtx->sap_lock);
3878 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
3879 {
Jeff Johnson4416a782013-03-25 14:17:50 -07003880 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 {
3882 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3883
3884 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
3885
3886 if (!VOS_IS_STATUS_SUCCESS(status))
3887 {
3888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003889 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003890 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303891 }
3892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
3894 }
3895 mutex_unlock(&pHddCtx->sap_lock);
3896
3897 if(status != VOS_STATUS_SUCCESS)
3898 {
3899 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003900 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 return -EINVAL;
3902 }
3903
Jeff Johnson4416a782013-03-25 14:17:50 -07003904 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
3906 ==eHAL_STATUS_FAILURE)
3907 {
3908 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003909 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 }
3911
Jeff Johnson4416a782013-03-25 14:17:50 -07003912 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
3914 eANI_BOOLEAN_FALSE) )
3915 {
3916 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003917 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 }
3919
3920 // Reset WNI_CFG_PROBE_RSP Flags
3921 wlan_hdd_reset_prob_rspies(pAdapter);
3922
3923 pAdapter->sessionCtx.ap.beacon = NULL;
3924 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07003925#ifdef WLAN_FEATURE_P2P_DEBUG
3926 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
3927 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
3928 {
3929 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
3930 "GO got removed");
3931 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
3932 }
3933#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 }
3935 EXIT();
3936 return status;
3937}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003938
3939#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
3940
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303941static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
3942 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003943 struct cfg80211_ap_settings *params)
3944{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303945 hdd_adapter_t *pAdapter;
3946 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303947 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003948
3949 ENTER();
3950
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303951 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07003952 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303953 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303954 "%s: Device is Null", __func__);
3955 return -ENODEV;
3956 }
3957
3958 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3959 if (NULL == pAdapter)
3960 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303961 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303962 "%s: HDD adapter is Null", __func__);
3963 return -ENODEV;
3964 }
3965
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05303966 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
3967 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
3968 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303969 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
3970 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303971 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303972 "%s: HDD adapter magic is invalid", __func__);
3973 return -ENODEV;
3974 }
3975
3976 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303977 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303978
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303979 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303980 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303981 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3982 "%s: HDD context is not valid", __func__);
3983 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303984 }
3985
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05303986 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
3987 __func__, hdd_device_modetoString(pAdapter->device_mode),
3988 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303989
3990 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003991 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003992 )
3993 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303994 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003995
3996 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05303997
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003998 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05303999 {
4000 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4001 FL("already beacon info added to session(%d)"),
4002 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004003 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304004 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004005
4006 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
4007
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05304008 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004009 {
4010 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05304011 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004012 return -EINVAL;
4013 }
4014 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08004015#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07004016 wlan_hdd_cfg80211_set_channel(wiphy, dev,
4017#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
4018 params->channel, params->channel_type);
4019#else
4020 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
4021#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08004022#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004023 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
4024 params->ssid_len, params->hidden_ssid);
4025 }
4026
4027 EXIT();
4028 return status;
4029}
4030
4031
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304032static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004033 struct net_device *dev,
4034 struct cfg80211_beacon_data *params)
4035{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304036 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304037 hdd_context_t *pHddCtx;
4038 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004039
4040 ENTER();
4041
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304042 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4043 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
4044 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08004045 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004046 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304047
4048 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4049 status = wlan_hdd_validate_context(pHddCtx);
4050
4051 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07004052 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304053 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4054 "%s: HDD context is not valid", __func__);
4055 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07004056 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004057
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304058 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004059 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304060 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004061 {
4062 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304063
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004064 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304065
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004066 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304067 {
4068 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4069 FL("session(%d) beacon data points to NULL"),
4070 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004071 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304072 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004073
4074 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
4075
4076 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304077 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004078 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004079 return -EINVAL;
4080 }
4081
4082 pAdapter->sessionCtx.ap.beacon = new;
4083
4084 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
4085 }
4086
4087 EXIT();
4088 return status;
4089}
4090
4091#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
4092
Jeff Johnson295189b2012-06-20 16:38:30 -07004093
4094static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
4095 struct net_device *dev,
4096 struct bss_parameters *params)
4097{
4098 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4099
4100 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304101
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304102 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4103 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
4104 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05304105 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
4106 __func__, hdd_device_modetoString(pAdapter->device_mode),
4107 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004108
4109 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304111 )
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 {
4113 /* ap_isolate == -1 means that in change bss, upper layer doesn't
4114 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304115 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 {
4117 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 }
4120
4121 EXIT();
4122 return 0;
4123}
4124
Kiet Lam10841362013-11-01 11:36:50 +05304125/* FUNCTION: wlan_hdd_change_country_code_cd
4126* to wait for contry code completion
4127*/
4128void* wlan_hdd_change_country_code_cb(void *pAdapter)
4129{
4130 hdd_adapter_t *call_back_pAdapter = pAdapter;
4131 complete(&call_back_pAdapter->change_country_code);
4132 return NULL;
4133}
4134
Jeff Johnson295189b2012-06-20 16:38:30 -07004135/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05304136 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
4138 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05304139int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 struct net_device *ndev,
4141 enum nl80211_iftype type,
4142 u32 *flags,
4143 struct vif_params *params
4144 )
4145{
4146 struct wireless_dev *wdev;
4147 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08004148 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07004149 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 tCsrRoamProfile *pRoamProfile = NULL;
4151 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304152 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 eMib_dot11DesiredBssType connectedBssType;
4154 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304155 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07004156
4157 ENTER();
4158
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304159 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08004160 {
4161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4162 "%s: Adapter context is null", __func__);
4163 return VOS_STATUS_E_FAILURE;
4164 }
4165
4166 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4167 if (!pHddCtx)
4168 {
4169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4170 "%s: HDD context is null", __func__);
4171 return VOS_STATUS_E_FAILURE;
4172 }
4173
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304174 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4175 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
4176 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304177 status = wlan_hdd_validate_context(pHddCtx);
4178
4179 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304181 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4182 "%s: HDD context is not valid", __func__);
4183 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004184 }
4185
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05304186 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
4187 __func__, hdd_device_modetoString(pAdapter->device_mode),
4188 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004189
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304190 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 wdev = ndev->ieee80211_ptr;
4192
4193#ifdef WLAN_BTAMP_FEATURE
4194 if((NL80211_IFTYPE_P2P_CLIENT == type)||
4195 (NL80211_IFTYPE_ADHOC == type)||
4196 (NL80211_IFTYPE_AP == type)||
4197 (NL80211_IFTYPE_P2P_GO == type))
4198 {
4199 pHddCtx->isAmpAllowed = VOS_FALSE;
4200 // stop AMP traffic
4201 status = WLANBAP_StopAmp();
4202 if(VOS_STATUS_SUCCESS != status )
4203 {
4204 pHddCtx->isAmpAllowed = VOS_TRUE;
4205 hddLog(VOS_TRACE_LEVEL_FATAL,
4206 "%s: Failed to stop AMP", __func__);
4207 return -EINVAL;
4208 }
4209 }
4210#endif //WLAN_BTAMP_FEATURE
4211 /* Reset the current device mode bit mask*/
4212 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
4213
4214 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07004216 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 )
4218 {
4219 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08004220 if (!pWextState)
4221 {
4222 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4223 "%s: pWextState is null", __func__);
4224 return VOS_STATUS_E_FAILURE;
4225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 pRoamProfile = &pWextState->roamProfile;
4227 LastBSSType = pRoamProfile->BSSType;
4228
4229 switch (type)
4230 {
4231 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 hddLog(VOS_TRACE_LEVEL_INFO,
4234 "%s: setting interface Type to INFRASTRUCTURE", __func__);
4235 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004236#ifdef WLAN_FEATURE_11AC
4237 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
4238 {
4239 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
4240 }
4241#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304242 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07004243 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004244 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08004245 //Check for sub-string p2p to confirm its a p2p interface
4246 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304247 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08004248 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
4249 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
4250 }
4251 else
4252 {
4253 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08004255 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05304256#ifdef FEATURE_WLAN_TDLS
4257 /* The open adapter for the p2p shall skip initializations in
4258 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
4259 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
4260 * tdls_init when the change_iface sets the device mode to
4261 * WLAN_HDD_P2P_CLIENT.
4262 */
4263
4264 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
4265 {
4266 if (0 != wlan_hdd_tdls_init (pAdapter))
4267 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304268 hddLog(VOS_TRACE_LEVEL_ERROR,
4269 "%s: tdls initialization failed", __func__);
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05304270 return -EINVAL;
4271 }
4272 }
4273#endif
4274
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 break;
4276 case NL80211_IFTYPE_ADHOC:
4277 hddLog(VOS_TRACE_LEVEL_INFO,
4278 "%s: setting interface Type to ADHOC", __func__);
4279 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
4280 pRoamProfile->phyMode =
4281 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004282 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 wdev->iftype = type;
4284 break;
4285
4286 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 {
4289 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4290 "%s: setting interface Type to %s", __func__,
4291 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
4292
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08004293 //Cancel any remain on channel for GO mode
4294 if (NL80211_IFTYPE_P2P_GO == type)
4295 {
4296 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
4297 }
Mohit Khanna0f232092012-09-11 14:46:08 -07004298 if (NL80211_IFTYPE_AP == type)
4299 {
4300 /* As Loading WLAN Driver one interface being created for p2p device
4301 * address. This will take one HW STA and the max number of clients
4302 * that can connect to softAP will be reduced by one. so while changing
4303 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
4304 * interface as it is not required in SoftAP mode.
4305 */
4306
4307 // Get P2P Adapter
4308 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
4309
4310 if (pP2pAdapter)
4311 {
4312 hdd_stop_adapter(pHddCtx, pP2pAdapter);
4313 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
4314 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
4315 }
4316 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05304317 //Disable IMPS & BMPS for SAP/GO
4318 if(VOS_STATUS_E_FAILURE ==
4319 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
4320 {
4321 //Fail to Exit BMPS
4322 VOS_ASSERT(0);
4323 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304324#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07004325
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304326 /* A Mutex Lock is introduced while changing the mode to
4327 * protect the concurrent access for the Adapters by TDLS
4328 * module.
4329 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05304330 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304331#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 //De-init the adapter.
4333 hdd_stop_adapter( pHddCtx, pAdapter );
4334 hdd_deinit_adapter( pHddCtx, pAdapter );
4335 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
4337 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304338#ifdef FEATURE_WLAN_TDLS
4339 mutex_unlock(&pHddCtx->tdls_lock);
4340#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07004341 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
4342 (pConfig->apRandomBssidEnabled))
4343 {
4344 /* To meet Android requirements create a randomized
4345 MAC address of the form 02:1A:11:Fx:xx:xx */
4346 get_random_bytes(&ndev->dev_addr[3], 3);
4347 ndev->dev_addr[0] = 0x02;
4348 ndev->dev_addr[1] = 0x1A;
4349 ndev->dev_addr[2] = 0x11;
4350 ndev->dev_addr[3] |= 0xF0;
4351 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
4352 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08004353 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
4354 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07004355 }
4356
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 hdd_set_ap_ops( pAdapter->dev );
4358
Kiet Lam10841362013-11-01 11:36:50 +05304359 /* This is for only SAP mode where users can
4360 * control country through ini.
4361 * P2P GO follows station country code
4362 * acquired during the STA scanning. */
4363 if((NL80211_IFTYPE_AP == type) &&
4364 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
4365 {
4366 int status = 0;
4367 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
4368 "%s: setting country code from INI ", __func__);
4369 init_completion(&pAdapter->change_country_code);
4370 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
4371 (void *)(tSmeChangeCountryCallback)
4372 wlan_hdd_change_country_code_cb,
4373 pConfig->apCntryCode, pAdapter,
4374 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05304375 eSIR_FALSE,
4376 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05304377 if (eHAL_STATUS_SUCCESS == status)
4378 {
4379 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304380 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05304381 &pAdapter->change_country_code,
4382 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304383 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05304384 {
4385 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304386 FL("SME Timed out while setting country code %ld"),
4387 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08004388
4389 if (pHddCtx->isLogpInProgress)
4390 {
4391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4392 "%s: LOGP in Progress. Ignore!!!", __func__);
4393 return -EAGAIN;
4394 }
Kiet Lam10841362013-11-01 11:36:50 +05304395 }
4396 }
4397 else
4398 {
4399 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08004400 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05304401 return -EINVAL;
4402 }
4403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 status = hdd_init_ap_mode(pAdapter);
4405 if(status != VOS_STATUS_SUCCESS)
4406 {
4407 hddLog(VOS_TRACE_LEVEL_FATAL,
4408 "%s: Error initializing the ap mode", __func__);
4409 return -EINVAL;
4410 }
4411 hdd_set_conparam(1);
4412
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 /*interface type changed update in wiphy structure*/
4414 if(wdev)
4415 {
4416 wdev->iftype = type;
4417 pHddCtx->change_iface = type;
4418 }
4419 else
4420 {
4421 hddLog(VOS_TRACE_LEVEL_ERROR,
4422 "%s: ERROR !!!! Wireless dev is NULL", __func__);
4423 return -EINVAL;
4424 }
4425 goto done;
4426 }
4427
4428 default:
4429 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
4430 __func__);
4431 return -EOPNOTSUPP;
4432 }
4433 }
4434 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 )
4437 {
4438 switch(type)
4439 {
4440 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07004442 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304443#ifdef FEATURE_WLAN_TDLS
4444
4445 /* A Mutex Lock is introduced while changing the mode to
4446 * protect the concurrent access for the Adapters by TDLS
4447 * module.
4448 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05304449 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304450#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004451 hdd_stop_adapter( pHddCtx, pAdapter );
4452 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07004453 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08004454 //Check for sub-string p2p to confirm its a p2p interface
4455 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08004456 {
4457 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
4458 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
4459 }
4460 else
4461 {
4462 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08004464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 hdd_set_conparam(0);
4466 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
4468 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304469#ifdef FEATURE_WLAN_TDLS
4470 mutex_unlock(&pHddCtx->tdls_lock);
4471#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05304472 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 if( VOS_STATUS_SUCCESS != status )
4474 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07004475 /* In case of JB, for P2P-GO, only change interface will be called,
4476 * This is the right place to enable back bmps_imps()
4477 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05304478 if (pHddCtx->hdd_wlan_suspended)
4479 {
4480 hdd_set_pwrparams(pHddCtx);
4481 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004482 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 goto done;
4484 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
4488 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07004489 goto done;
4490 default:
4491 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
4492 __func__);
4493 return -EOPNOTSUPP;
4494
4495 }
4496
4497 }
4498 else
4499 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05304500 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
4501 __func__, hdd_device_modetoString(pAdapter->device_mode),
4502 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 return -EOPNOTSUPP;
4504 }
4505
4506
4507 if(pRoamProfile)
4508 {
4509 if ( LastBSSType != pRoamProfile->BSSType )
4510 {
4511 /*interface type changed update in wiphy structure*/
4512 wdev->iftype = type;
4513
4514 /*the BSS mode changed, We need to issue disconnect
4515 if connected or in IBSS disconnect state*/
4516 if ( hdd_connGetConnectedBssType(
4517 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
4518 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
4519 {
4520 /*need to issue a disconnect to CSR.*/
4521 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4522 if( eHAL_STATUS_SUCCESS ==
4523 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
4524 pAdapter->sessionId,
4525 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
4526 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304527 ret = wait_for_completion_interruptible_timeout(
4528 &pAdapter->disconnect_comp_var,
4529 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4530 if (ret <= 0)
4531 {
4532 hddLog(VOS_TRACE_LEVEL_ERROR,
4533 FL("wait on disconnect_comp_var failed %ld"), ret);
4534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 }
4536 }
4537 }
4538 }
4539
4540done:
4541 /*set bitmask based on updated value*/
4542 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07004543
4544 /* Only STA mode support TM now
4545 * all other mode, TM feature should be disabled */
4546 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
4547 (~VOS_STA & pHddCtx->concurrency_mode) )
4548 {
4549 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
4550 }
4551
Jeff Johnson295189b2012-06-20 16:38:30 -07004552#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304553 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
4555 {
4556 //we are ok to do AMP
4557 pHddCtx->isAmpAllowed = VOS_TRUE;
4558 }
4559#endif //WLAN_BTAMP_FEATURE
4560 EXIT();
4561 return 0;
4562}
4563
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05304564/*
4565 * FUNCTION: wlan_hdd_cfg80211_change_iface
4566 * wrapper function to protect the actual implementation from SSR.
4567 */
4568int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
4569 struct net_device *ndev,
4570 enum nl80211_iftype type,
4571 u32 *flags,
4572 struct vif_params *params
4573 )
4574{
4575 int ret;
4576
4577 vos_ssr_protect(__func__);
4578 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
4579 vos_ssr_unprotect(__func__);
4580
4581 return ret;
4582}
4583
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004584#ifdef FEATURE_WLAN_TDLS
4585static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
4586 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
4587{
4588 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4589 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4590 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004591 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304592 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05304593 tANI_U16 numCurrTdlsPeers;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004594
4595 ENTER();
4596
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05304597 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004598 {
4599 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4600 "Invalid arguments");
4601 return -EINVAL;
4602 }
Hoonki Lee27511902013-03-14 18:19:06 -07004603
4604 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
4605 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
4606 {
4607 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4608 "%s: TDLS mode is disabled OR not enabled in FW."
4609 MAC_ADDRESS_STR " Request declined.",
4610 __func__, MAC_ADDR_ARRAY(mac));
4611 return -ENOTSUPP;
4612 }
4613
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004614 if (pHddCtx->isLogpInProgress)
4615 {
4616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4617 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07004618 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004619 return -EBUSY;
4620 }
4621
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05304622 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004623
4624 if ( NULL == pTdlsPeer ) {
4625 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4626 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
4627 __func__, MAC_ADDR_ARRAY(mac), update);
4628 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07004629 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004630
4631 /* in add station, we accept existing valid staId if there is */
4632 if ((0 == update) &&
4633 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
4634 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004635 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004636 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004637 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004638 " link_status %d. staId %d. add station ignored.",
4639 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
4640 return 0;
4641 }
4642 /* in change station, we accept only when staId is valid */
4643 if ((1 == update) &&
4644 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
4645 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
4646 {
4647 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4648 "%s: " MAC_ADDRESS_STR
4649 " link status %d. staId %d. change station %s.",
4650 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
4651 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
4652 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004653 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07004654
4655 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304656 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004657 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07004658 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4659 "%s: " MAC_ADDRESS_STR
4660 " TDLS setup is ongoing. Request declined.",
4661 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07004662 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004663 }
4664
4665 /* first to check if we reached to maximum supported TDLS peer.
4666 TODO: for now, return -EPERM looks working fine,
4667 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05304668 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
4669 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004670 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07004671 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4672 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05304673 " TDLS Max peer already connected. Request declined."
4674 " Num of peers (%d), Max allowed (%d).",
4675 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
4676 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07004677 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004678 }
4679 else
4680 {
4681 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05304682 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004683 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004684 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07004685 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4686 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
4687 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004688 return -EPERM;
4689 }
4690 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004691 if (0 == update)
4692 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004693
Jeff Johnsond75fe012013-04-06 10:53:06 -07004694 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05304695 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004696 {
4697 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4698 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07004699 if(StaParams->htcap_present)
4700 {
4701 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4702 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
4703 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4704 "ht_capa->extended_capabilities: %0x",
4705 StaParams->HTCap.extendedHtCapInfo);
4706 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004707 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4708 "params->capability: %0x",StaParams->capability);
4709 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004710 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07004711 if(StaParams->vhtcap_present)
4712 {
4713 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4714 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
4715 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
4716 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
4717 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004718 {
4719 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004720 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004721 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
4722 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
4723 "[%d]: %x ", i, StaParams->supported_rates[i]);
4724 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07004725 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05304726 else if ((1 == update) && (NULL == StaParams))
4727 {
4728 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4729 "%s : update is true, but staParams is NULL. Error!", __func__);
4730 return -EPERM;
4731 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004732
4733 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
4734
4735 if (!update)
4736 {
4737 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
4738 pAdapter->sessionId, mac);
4739 }
4740 else
4741 {
4742 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
4743 pAdapter->sessionId, mac, StaParams);
4744 }
4745
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304746 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004747 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
4748
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304749 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004750 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07004751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304752 "%s: timeout waiting for tdls add station indication %ld",
4753 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07004754 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004755 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05304756
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004757 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
4758 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07004759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004760 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07004761 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004762 }
4763
4764 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07004765
4766error:
4767 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
4768 return -EPERM;
4769
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004770}
4771#endif
4772
Jeff Johnson295189b2012-06-20 16:38:30 -07004773static int wlan_hdd_change_station(struct wiphy *wiphy,
4774 struct net_device *dev,
4775 u8 *mac,
4776 struct station_parameters *params)
4777{
4778 VOS_STATUS status = VOS_STATUS_SUCCESS;
4779 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05304780 hdd_context_t *pHddCtx;
4781 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07004783#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004784 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004785 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05304786 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07004787#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07004788 ENTER();
4789
Gopichand Nakkala29149562013-05-10 21:43:41 +05304790 if ((NULL == pAdapter))
4791 {
4792 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4793 "invalid adapter ");
4794 return -EINVAL;
4795 }
4796
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304797 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4798 TRACE_CODE_HDD_CHANGE_STATION,
4799 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05304800 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4801 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4802
4803 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
4804 {
4805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4806 "invalid HDD state or HDD station context");
4807 return -EINVAL;
4808 }
4809
4810 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004811 {
4812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4813 "%s:LOGP in Progress. Ignore!!!", __func__);
4814 return -EAGAIN;
4815 }
4816
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
4818
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004819 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
4820 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004822 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07004823 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304824 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 WLANTL_STA_AUTHENTICATED);
4826
Gopichand Nakkala29149562013-05-10 21:43:41 +05304827 if (status != VOS_STATUS_SUCCESS)
4828 {
4829 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4830 "%s: Not able to change TL state to AUTHENTICATED", __func__);
4831 return -EINVAL;
4832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004833 }
4834 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07004835 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
4836 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05304837#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004838 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
4839 StaParams.capability = params->capability;
4840 StaParams.uapsd_queues = params->uapsd_queues;
4841 StaParams.max_sp = params->max_sp;
4842
Naresh Jayaram3180aa42014-02-12 21:47:26 +05304843 /* Convert (first channel , number of channels) tuple to
4844 * the total list of channels. This goes with the assumption
4845 * that if the first channel is < 14, then the next channels
4846 * are an incremental of 1 else an incremental of 4 till the number
4847 * of channels.
4848 */
4849 if (0 != params->supported_channels_len) {
4850 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
4851 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
4852 {
4853 int wifi_chan_index;
4854 StaParams.supported_channels[j] = params->supported_channels[i];
4855 wifi_chan_index =
4856 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
4857 no_of_channels = params->supported_channels[i+1];
4858 for(k=1; k <= no_of_channels; k++)
4859 {
4860 StaParams.supported_channels[j+1] =
4861 StaParams.supported_channels[j] + wifi_chan_index;
4862 j+=1;
4863 }
4864 }
4865 StaParams.supported_channels_len = j;
4866 }
4867 vos_mem_copy(StaParams.supported_oper_classes,
4868 params->supported_oper_classes,
4869 params->supported_oper_classes_len);
4870 StaParams.supported_oper_classes_len =
4871 params->supported_oper_classes_len;
4872
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004873 if (0 != params->ext_capab_len)
4874 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
4875 sizeof(StaParams.extn_capability));
4876
4877 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07004878 {
4879 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004880 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07004881 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004882
4883 StaParams.supported_rates_len = params->supported_rates_len;
4884
4885 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
4886 * The supported_rates array , for all the structures propogating till Add Sta
4887 * to the firmware has to be modified , if the supplicant (ieee80211) is
4888 * modified to send more rates.
4889 */
4890
4891 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
4892 */
4893 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
4894 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
4895
4896 if (0 != StaParams.supported_rates_len) {
4897 int i = 0;
4898 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
4899 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004900 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004901 "Supported Rates with Length %d", StaParams.supported_rates_len);
4902 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07004903 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004904 "[%d]: %0x", i, StaParams.supported_rates[i]);
4905 }
4906
4907 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07004908 {
4909 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004910 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07004911 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07004912
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004913 if (0 != params->ext_capab_len ) {
4914 /*Define A Macro : TODO Sunil*/
4915 if ((1<<4) & StaParams.extn_capability[3]) {
4916 isBufSta = 1;
4917 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05304918 /* TDLS Channel Switching Support */
4919 if ((1<<6) & StaParams.extn_capability[3]) {
4920 isOffChannelSupported = 1;
4921 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004922 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05304923 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
4924 &StaParams, isBufSta,
4925 isOffChannelSupported);
4926
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05304927 if (VOS_STATUS_SUCCESS != status) {
4928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4929 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
4930 return -EINVAL;
4931 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004932 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
4933
4934 if (VOS_STATUS_SUCCESS != status) {
4935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4936 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
4937 return -EINVAL;
4938 }
4939 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07004940#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05304941 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004942 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 return status;
4944}
4945
4946/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 * FUNCTION: wlan_hdd_cfg80211_add_key
4948 * This function is used to initialize the key information
4949 */
4950#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07004951static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 struct net_device *ndev,
4953 u8 key_index, bool pairwise,
4954 const u8 *mac_addr,
4955 struct key_params *params
4956 )
4957#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07004958static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004959 struct net_device *ndev,
4960 u8 key_index, const u8 *mac_addr,
4961 struct key_params *params
4962 )
4963#endif
4964{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07004965 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 tCsrRoamSetKey setKey;
4967 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304968 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07004969 v_U32_t roamId= 0xFF;
4970 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 hdd_hostapd_state_t *pHostapdState;
4972 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07004973 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304974 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004975
4976 ENTER();
4977
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05304978 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
4979 TRACE_CODE_HDD_CFG80211_ADD_KEY,
4980 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304981 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4982 status = wlan_hdd_validate_context(pHddCtx);
4983
4984 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004985 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304986 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4987 "%s: HDD context is not valid", __func__);
4988 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004989 }
4990
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05304991 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
4992 __func__, hdd_device_modetoString(pAdapter->device_mode),
4993 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004994
4995 if (CSR_MAX_NUM_KEY <= key_index)
4996 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07004997 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 key_index);
4999
5000 return -EINVAL;
5001 }
5002
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005003 if (CSR_MAX_KEY_LEN < params->key_len)
5004 {
5005 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
5006 params->key_len);
5007
5008 return -EINVAL;
5009 }
5010
5011 hddLog(VOS_TRACE_LEVEL_INFO,
5012 "%s: called with key index = %d & key length %d",
5013 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07005014
5015 /*extract key idx, key len and key*/
5016 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5017 setKey.keyId = key_index;
5018 setKey.keyLength = params->key_len;
5019 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
5020
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005021 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 {
5023 case WLAN_CIPHER_SUITE_WEP40:
5024 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5025 break;
5026
5027 case WLAN_CIPHER_SUITE_WEP104:
5028 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5029 break;
5030
5031 case WLAN_CIPHER_SUITE_TKIP:
5032 {
5033 u8 *pKey = &setKey.Key[0];
5034 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
5035
5036 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
5037
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005038 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07005039
5040 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005041 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 |--------------|----------|----------|
5043 <---16bytes---><--8bytes--><--8bytes-->
5044
5045 */
5046 /*Sme expects the 32 bytes key to be in the below order
5047
5048 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005049 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 |--------------|----------|----------|
5051 <---16bytes---><--8bytes--><--8bytes-->
5052 */
5053 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005054 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07005055
5056 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005057 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07005058
5059 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005060 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07005061
5062
5063 break;
5064 }
5065
5066 case WLAN_CIPHER_SUITE_CCMP:
5067 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
5068 break;
5069
5070#ifdef FEATURE_WLAN_WAPI
5071 case WLAN_CIPHER_SUITE_SMS4:
5072 {
5073 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5074 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
5075 params->key, params->key_len);
5076 return 0;
5077 }
5078#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005079
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005080#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005081 case WLAN_CIPHER_SUITE_KRK:
5082 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
5083 break;
5084#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005085
5086#ifdef WLAN_FEATURE_11W
5087 case WLAN_CIPHER_SUITE_AES_CMAC:
5088 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07005089 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07005090#endif
5091
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005093 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07005094 __func__, params->cipher);
5095 return -EOPNOTSUPP;
5096 }
5097
5098 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
5099 __func__, setKey.encType);
5100
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005101 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07005102#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5103 (!pairwise)
5104#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005105 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07005106#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005107 )
5108 {
5109 /* set group key*/
5110 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5111 "%s- %d: setting Broadcast key",
5112 __func__, __LINE__);
5113 setKey.keyDirection = eSIR_RX_ONLY;
5114 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5115 }
5116 else
5117 {
5118 /* set pairwise key*/
5119 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5120 "%s- %d: setting pairwise key",
5121 __func__, __LINE__);
5122 setKey.keyDirection = eSIR_TX_RX;
5123 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
5124 }
5125 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
5126 {
5127 setKey.keyDirection = eSIR_TX_RX;
5128 /*Set the group key*/
5129 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
5130 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005131
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005132 if ( 0 != status )
5133 {
5134 hddLog(VOS_TRACE_LEVEL_ERROR,
5135 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
5136 return -EINVAL;
5137 }
5138 /*Save the keys here and call sme_RoamSetKey for setting
5139 the PTK after peer joins the IBSS network*/
5140 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
5141 &setKey, sizeof(tCsrRoamSetKey));
5142 return status;
5143 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05305144 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
5145 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
5146 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005148 if( pHostapdState->bssState == BSS_START )
5149 {
c_hpothu7c55da62014-01-23 18:34:02 +05305150 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5151 vos_status = wlan_hdd_check_ula_done(pAdapter);
5152
5153 if ( vos_status != VOS_STATUS_SUCCESS )
5154 {
5155 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5156 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5157 __LINE__, vos_status );
5158
5159 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5160
5161 return -EINVAL;
5162 }
5163
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 status = WLANSAP_SetKeySta( pVosContext, &setKey);
5165
5166 if ( status != eHAL_STATUS_SUCCESS )
5167 {
5168 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5169 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
5170 __LINE__, status );
5171 }
5172 }
5173
5174 /* Saving WEP keys */
5175 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
5176 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
5177 {
5178 //Save the wep key in ap context. Issue setkey after the BSS is started.
5179 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5180 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
5181 }
5182 else
5183 {
5184 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005185 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005186 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
5187 }
5188 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005189 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
5190 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 {
5192 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5193 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5194
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305195#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5196 if (!pairwise)
5197#else
5198 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
5199#endif
5200 {
5201 /* set group key*/
5202 if (pHddStaCtx->roam_info.deferKeyComplete)
5203 {
5204 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5205 "%s- %d: Perform Set key Complete",
5206 __func__, __LINE__);
5207 hdd_PerformRoamSetKeyComplete(pAdapter);
5208 }
5209 }
5210
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
5212
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08005213 pWextState->roamProfile.Keys.defaultIndex = key_index;
5214
5215
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07005216 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 params->key, params->key_len);
5218
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305219
Jeff Johnson295189b2012-06-20 16:38:30 -07005220 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5221
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305222 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07005223 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305224 __func__, setKey.peerMac[0], setKey.peerMac[1],
5225 setKey.peerMac[2], setKey.peerMac[3],
5226 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 setKey.keyDirection);
5228
5229 vos_status = wlan_hdd_check_ula_done(pAdapter);
5230
5231 if ( vos_status != VOS_STATUS_SUCCESS )
5232 {
5233 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5234 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
5235 __LINE__, vos_status );
5236
5237 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5238
5239 return -EINVAL;
5240
5241 }
5242
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005243#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305244 /* The supplicant may attempt to set the PTK once pre-authentication
5245 is done. Save the key in the UMAC and include it in the ADD BSS
5246 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005247 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305248 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005249 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05305250 hddLog(VOS_TRACE_LEVEL_INFO_MED,
5251 "%s: Update PreAuth Key success", __func__);
5252 return 0;
5253 }
5254 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
5255 {
5256 hddLog(VOS_TRACE_LEVEL_ERROR,
5257 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05305258 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005259 }
5260#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07005261
5262 /* issue set key request to SME*/
5263 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
5264 pAdapter->sessionId, &setKey, &roamId );
5265
5266 if ( 0 != status )
5267 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305268 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
5270 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5271 return -EINVAL;
5272 }
5273
5274
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305275 /* in case of IBSS as there was no information available about WEP keys during
5276 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305278 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
5279 !( ( IW_AUTH_KEY_MGMT_802_1X
5280 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
5282 )
5283 &&
5284 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
5285 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
5286 )
5287 )
5288 {
5289 setKey.keyDirection = eSIR_RX_ONLY;
5290 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
5291
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305292 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07005293 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305294 __func__, setKey.peerMac[0], setKey.peerMac[1],
5295 setKey.peerMac[2], setKey.peerMac[3],
5296 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07005297 setKey.keyDirection);
5298
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305299 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005300 pAdapter->sessionId, &setKey, &roamId );
5301
5302 if ( 0 != status )
5303 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305304 hddLog(VOS_TRACE_LEVEL_ERROR,
5305 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005306 __func__, status);
5307 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5308 return -EINVAL;
5309 }
5310 }
5311 }
5312
5313 return 0;
5314}
5315
5316/*
5317 * FUNCTION: wlan_hdd_cfg80211_get_key
5318 * This function is used to get the key information
5319 */
5320#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305321static int wlan_hdd_cfg80211_get_key(
5322 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005323 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305324 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 const u8 *mac_addr, void *cookie,
5326 void (*callback)(void *cookie, struct key_params*)
5327 )
5328#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305329static int wlan_hdd_cfg80211_get_key(
5330 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 struct net_device *ndev,
5332 u8 key_index, const u8 *mac_addr, void *cookie,
5333 void (*callback)(void *cookie, struct key_params*)
5334 )
5335#endif
5336{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305337 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5339 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5340 struct key_params params;
5341
5342 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305343
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05305344 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
5345 __func__, hdd_device_modetoString(pAdapter->device_mode),
5346 pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305347
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 memset(&params, 0, sizeof(params));
5349
5350 if (CSR_MAX_NUM_KEY <= key_index)
5351 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05305352 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305354 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005355
5356 switch(pRoamProfile->EncryptionType.encryptionType[0])
5357 {
5358 case eCSR_ENCRYPT_TYPE_NONE:
5359 params.cipher = IW_AUTH_CIPHER_NONE;
5360 break;
5361
5362 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5363 case eCSR_ENCRYPT_TYPE_WEP40:
5364 params.cipher = WLAN_CIPHER_SUITE_WEP40;
5365 break;
5366
5367 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5368 case eCSR_ENCRYPT_TYPE_WEP104:
5369 params.cipher = WLAN_CIPHER_SUITE_WEP104;
5370 break;
5371
5372 case eCSR_ENCRYPT_TYPE_TKIP:
5373 params.cipher = WLAN_CIPHER_SUITE_TKIP;
5374 break;
5375
5376 case eCSR_ENCRYPT_TYPE_AES:
5377 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
5378 break;
5379
5380 default:
5381 params.cipher = IW_AUTH_CIPHER_NONE;
5382 break;
5383 }
5384
c_hpothuaaf19692014-05-17 17:01:48 +05305385 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5386 TRACE_CODE_HDD_CFG80211_GET_KEY,
5387 pAdapter->sessionId, params.cipher));
5388
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
5390 params.seq_len = 0;
5391 params.seq = NULL;
5392 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
5393 callback(cookie, &params);
5394 return 0;
5395}
5396
5397/*
5398 * FUNCTION: wlan_hdd_cfg80211_del_key
5399 * This function is used to delete the key information
5400 */
5401#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305402static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305404 u8 key_index,
5405 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 const u8 *mac_addr
5407 )
5408#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305409static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 struct net_device *ndev,
5411 u8 key_index,
5412 const u8 *mac_addr
5413 )
5414#endif
5415{
5416 int status = 0;
5417
5418 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305419 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 //it is observed that this is invalidating peer
5421 //key index whenever re-key is done. This is affecting data link.
5422 //It should be ok to ignore del_key.
5423#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305424 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
5425 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5427 tCsrRoamSetKey setKey;
5428 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305429
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 ENTER();
5431
5432 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
5433 __func__,pAdapter->device_mode);
5434
5435 if (CSR_MAX_NUM_KEY <= key_index)
5436 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305437 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 key_index);
5439
5440 return -EINVAL;
5441 }
5442
5443 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5444 setKey.keyId = key_index;
5445
5446 if (mac_addr)
5447 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
5448 else
5449 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
5450
5451 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
5452
5453 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305455 )
5456 {
5457
5458 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
5460 if( pHostapdState->bssState == BSS_START)
5461 {
5462 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305463
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 if ( status != eHAL_STATUS_SUCCESS )
5465 {
5466 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5467 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
5468 __LINE__, status );
5469 }
5470 }
5471 }
5472 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305473 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07005474 )
5475 {
5476 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5477
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305478 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
5479
5480 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305482 __func__, setKey.peerMac[0], setKey.peerMac[1],
5483 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305485 if(pAdapter->sessionCtx.station.conn_info.connState ==
5486 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305488 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305490
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 if ( 0 != status )
5492 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305493 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 "%s: sme_RoamSetKey failure, returned %d",
5495 __func__, status);
5496 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
5497 return -EINVAL;
5498 }
5499 }
5500 }
5501#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07005502 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 return status;
5504}
5505
5506/*
5507 * FUNCTION: wlan_hdd_cfg80211_set_default_key
5508 * This function is used to set the default tx key index
5509 */
5510#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5511static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
5512 struct net_device *ndev,
5513 u8 key_index,
5514 bool unicast, bool multicast)
5515#else
5516static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
5517 struct net_device *ndev,
5518 u8 key_index)
5519#endif
5520{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305521 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305522 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05305523 hdd_wext_state_t *pWextState;
5524 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305525 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005526
5527 ENTER();
5528
Gopichand Nakkala29149562013-05-10 21:43:41 +05305529 if ((NULL == pAdapter))
5530 {
5531 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5532 "invalid adapter");
5533 return -EINVAL;
5534 }
5535
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305536 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5537 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
5538 pAdapter->sessionId, key_index));
5539
Gopichand Nakkala29149562013-05-10 21:43:41 +05305540 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5541 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5542
5543 if ((NULL == pWextState) || (NULL == pHddStaCtx))
5544 {
5545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5546 "invalid Wext state or HDD context");
5547 return -EINVAL;
5548 }
5549
Arif Hussain6d2a3322013-11-17 19:50:10 -08005550 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305552
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 if (CSR_MAX_NUM_KEY <= key_index)
5554 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305555 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 key_index);
5557
5558 return -EINVAL;
5559 }
5560
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305561 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5562 status = wlan_hdd_validate_context(pHddCtx);
5563
5564 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005565 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5567 "%s: HDD context is not valid", __func__);
5568 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005569 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305570
Jeff Johnson295189b2012-06-20 16:38:30 -07005571 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305573 )
Jeff Johnson295189b2012-06-20 16:38:30 -07005574 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05305575 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08005576 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305577 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08005578 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305580 {
5581 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07005582 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305583
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 tCsrRoamSetKey setKey;
5585 v_U32_t roamId= 0xFF;
5586 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305587
5588 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305590
Jeff Johnson295189b2012-06-20 16:38:30 -07005591 Keys->defaultIndex = (u8)key_index;
5592 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
5593 setKey.keyId = key_index;
5594 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305595
5596 vos_mem_copy(&setKey.Key[0],
5597 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305599
Gopichand Nakkala29149562013-05-10 21:43:41 +05305600 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305601
5602 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 &pHddStaCtx->conn_info.bssId[0],
5604 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305605
Gopichand Nakkala29149562013-05-10 21:43:41 +05305606 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
5607 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
5608 eCSR_ENCRYPT_TYPE_WEP104)
5609 {
5610 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
5611 even though ap is configured for WEP-40 encryption. In this canse the key length
5612 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
5613 type(104) and switching encryption type to 40*/
5614 pWextState->roamProfile.EncryptionType.encryptionType[0] =
5615 eCSR_ENCRYPT_TYPE_WEP40;
5616 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5617 eCSR_ENCRYPT_TYPE_WEP40;
5618 }
5619
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305620 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07005621 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305622
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305624 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005625 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305626
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 if ( 0 != status )
5628 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305629 hddLog(VOS_TRACE_LEVEL_ERROR,
5630 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 status);
5632 return -EINVAL;
5633 }
5634 }
5635 }
5636
5637 /* In SoftAp mode setting key direction for default mode */
5638 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
5639 {
5640 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
5641 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
5642 (eCSR_ENCRYPT_TYPE_AES !=
5643 pWextState->roamProfile.EncryptionType.encryptionType[0])
5644 )
5645 {
5646 /* Saving key direction for default key index to TX default */
5647 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
5648 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
5649 }
5650 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305651
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 return status;
5653}
5654
Jeff Johnson295189b2012-06-20 16:38:30 -07005655/*
5656 * FUNCTION: wlan_hdd_cfg80211_inform_bss
5657 * This function is used to inform the BSS details to nl80211 interface.
5658 */
5659static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
5660 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
5661{
5662 struct net_device *dev = pAdapter->dev;
5663 struct wireless_dev *wdev = dev->ieee80211_ptr;
5664 struct wiphy *wiphy = wdev->wiphy;
5665 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
5666 int chan_no;
5667 int ie_length;
5668 const char *ie;
5669 unsigned int freq;
5670 struct ieee80211_channel *chan;
5671 int rssi = 0;
5672 struct cfg80211_bss *bss = NULL;
5673
5674 ENTER();
5675
5676 if( NULL == pBssDesc )
5677 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005678 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 return bss;
5680 }
5681
5682 chan_no = pBssDesc->channelId;
5683 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
5684 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
5685
5686 if( NULL == ie )
5687 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005688 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 return bss;
5690 }
5691
5692#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
5693 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
5694 {
5695 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
5696 }
5697 else
5698 {
5699 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
5700 }
5701#else
5702 freq = ieee80211_channel_to_frequency(chan_no);
5703#endif
5704
5705 chan = __ieee80211_get_channel(wiphy, freq);
5706
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05305707 if (!chan) {
5708 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
5709 return NULL;
5710 }
5711
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
5713 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
5714 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
5715 if (bss == NULL)
5716 {
5717 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
5718
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305719 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
5720 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07005721 pBssDesc->capabilityInfo,
5722 pBssDesc->beaconInterval, ie, ie_length,
5723 rssi, GFP_KERNEL ));
5724}
5725 else
5726 {
5727 return bss;
5728 }
5729}
5730
5731
5732
5733/*
5734 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
5735 * This function is used to inform the BSS details to nl80211 interface.
5736 */
5737struct cfg80211_bss*
5738wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
5739 tSirBssDescription *bss_desc
5740 )
5741{
5742 /*
5743 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
5744 already exists in bss data base of cfg80211 for that particular BSS ID.
5745 Using cfg80211_inform_bss_frame to update the bss entry instead of
5746 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
5747 now there is no possibility to get the mgmt(probe response) frame from PE,
5748 converting bss_desc to ieee80211_mgmt(probe response) and passing to
5749 cfg80211_inform_bss_frame.
5750 */
5751 struct net_device *dev = pAdapter->dev;
5752 struct wireless_dev *wdev = dev->ieee80211_ptr;
5753 struct wiphy *wiphy = wdev->wiphy;
5754 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08005755#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
5756 qcom_ie_age *qie_age = NULL;
5757 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
5758#else
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08005760#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 const char *ie =
5762 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
5763 unsigned int freq;
5764 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05305765 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 struct cfg80211_bss *bss_status = NULL;
5767 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
5768 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07005769 hdd_context_t *pHddCtx;
5770 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07005771#ifdef WLAN_OPEN_SOURCE
5772 struct timespec ts;
5773#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005774
Wilson Yangf80a0542013-10-07 13:02:37 -07005775 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5776 status = wlan_hdd_validate_context(pHddCtx);
5777
5778 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05305779 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07005780 {
5781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5782 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
5783 return NULL;
5784 }
5785
5786
5787 if (0 != status)
5788 {
5789 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5790 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07005791 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07005792 }
5793
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05305794 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07005795 if (!mgmt)
5796 {
5797 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5798 "%s: memory allocation failed ", __func__);
5799 return NULL;
5800 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07005801
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07005803
5804#ifdef WLAN_OPEN_SOURCE
5805 /* Android does not want the timestamp from the frame.
5806 Instead it wants a monotonic increasing value */
5807 get_monotonic_boottime(&ts);
5808 mgmt->u.probe_resp.timestamp =
5809 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
5810#else
5811 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
5813 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07005814
5815#endif
5816
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
5818 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08005819
5820#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
5821 /* GPS Requirement: need age ie per entry. Using vendor specific. */
5822 /* Assuming this is the last IE, copy at the end */
5823 ie_length -=sizeof(qcom_ie_age);
5824 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
5825 qie_age->element_id = QCOM_VENDOR_IE_ID;
5826 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
5827 qie_age->oui_1 = QCOM_OUI1;
5828 qie_age->oui_2 = QCOM_OUI2;
5829 qie_age->oui_3 = QCOM_OUI3;
5830 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
5831 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
5832#endif
5833
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05305835 if (bss_desc->fProbeRsp)
5836 {
5837 mgmt->frame_control |=
5838 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
5839 }
5840 else
5841 {
5842 mgmt->frame_control |=
5843 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
5844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005845
5846#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305847 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
5849 {
5850 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
5851 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305852 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
5854
5855 {
5856 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
5857 }
5858 else
5859 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305860 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
5861 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 kfree(mgmt);
5863 return NULL;
5864 }
5865#else
5866 freq = ieee80211_channel_to_frequency(chan_no);
5867#endif
5868 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08005869 /*when the band is changed on the fly using the GUI, three things are done
5870 * 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)
5871 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
5872 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
5873 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
5874 * and discards the channels correponding to previous band and calls back with zero bss results.
5875 * 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
5876 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
5877 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
5878 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
5879 * So drop the bss and continue to next bss.
5880 */
5881 if(chan == NULL)
5882 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305883 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07005884 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08005885 return NULL;
5886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005887 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305888 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 * */
5890 if (( eConnectionState_Associated ==
5891 pAdapter->sessionCtx.station.conn_info.connState ) &&
5892 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
5893 pAdapter->sessionCtx.station.conn_info.bssId,
5894 WNI_CFG_BSSID_LEN)))
5895 {
5896 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
5897 rssi = (pAdapter->rssi * 100);
5898 }
5899 else
5900 {
5901 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
5902 }
5903
Nirav Shah20ac06f2013-12-12 18:14:06 +05305904 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
5905 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
5906 chan->center_freq, (int)(rssi/100));
5907
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
5909 frame_len, rssi, GFP_KERNEL);
5910 kfree(mgmt);
5911 return bss_status;
5912}
5913
5914/*
5915 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
5916 * This function is used to update the BSS data base of CFG8011
5917 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305918struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 tCsrRoamInfo *pRoamInfo
5920 )
5921{
5922 tCsrRoamConnectedProfile roamProfile;
5923 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5924 struct cfg80211_bss *bss = NULL;
5925
5926 ENTER();
5927
5928 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
5929 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
5930
5931 if (NULL != roamProfile.pBssDesc)
5932 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305933 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 &roamProfile);
5935
5936 if (NULL == bss)
5937 {
5938 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
5939 __func__);
5940 }
5941
5942 sme_RoamFreeConnectProfile(hHal, &roamProfile);
5943 }
5944 else
5945 {
5946 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
5947 __func__);
5948 }
5949 return bss;
5950}
5951
5952/*
5953 * FUNCTION: wlan_hdd_cfg80211_update_bss
5954 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305955static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
5956 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305958{
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5960 tCsrScanResultInfo *pScanResult;
5961 eHalStatus status = 0;
5962 tScanResultHandle pResult;
5963 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07005964 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005965
5966 ENTER();
5967
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305968 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
5969 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
5970 NO_SESSION, pAdapter->sessionId));
5971
Wilson Yangf80a0542013-10-07 13:02:37 -07005972 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5973
5974 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 {
Wilson Yangf80a0542013-10-07 13:02:37 -07005976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
5977 "%s:LOGP in Progress. Ignore!!!",__func__);
5978 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 }
5980
Wilson Yangf80a0542013-10-07 13:02:37 -07005981
5982 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05305983 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07005984 {
5985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5986 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
5987 return VOS_STATUS_E_PERM;
5988 }
5989
5990
Jeff Johnson295189b2012-06-20 16:38:30 -07005991 /*
5992 * start getting scan results and populate cgf80211 BSS database
5993 */
5994 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
5995
5996 /* no scan results */
5997 if (NULL == pResult)
5998 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05305999 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
6000 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006001 return status;
6002 }
6003
6004 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
6005
6006 while (pScanResult)
6007 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306008 /*
6009 * cfg80211_inform_bss() is not updating ie field of bss entry, if
6010 * entry already exists in bss data base of cfg80211 for that
6011 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
6012 * bss entry instead of cfg80211_inform_bss, But this call expects
6013 * mgmt packet as input. As of now there is no possibility to get
6014 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 * ieee80211_mgmt(probe response) and passing to c
6016 * fg80211_inform_bss_frame.
6017 * */
6018
6019 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
6020 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306021
Jeff Johnson295189b2012-06-20 16:38:30 -07006022
6023 if (NULL == bss_status)
6024 {
6025 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006026 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 }
6028 else
6029 {
Yue Maf49ba872013-08-19 12:04:25 -07006030 cfg80211_put_bss(
6031#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
6032 wiphy,
6033#endif
6034 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 }
6036
6037 pScanResult = sme_ScanResultGetNext(hHal, pResult);
6038 }
6039
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306040 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07006041
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306042 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006043}
6044
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006045void
6046hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
6047{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306048 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08006049 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006050} /****** end hddPrintMacAddr() ******/
6051
6052void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006053hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006054{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306055 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006056 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006057 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
6058 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
6059 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006060} /****** end hddPrintPmkId() ******/
6061
6062//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
6063//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
6064
6065//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
6066//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
6067
6068#define dump_bssid(bssid) \
6069 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07006070 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
6071 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006072 }
6073
6074#define dump_pmkid(pMac, pmkid) \
6075 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07006076 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
6077 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006078 }
6079
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07006080#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006081/*
6082 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
6083 * This function is used to notify the supplicant of a new PMKSA candidate.
6084 */
6085int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306086 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006087 int index, bool preauth )
6088{
Jeff Johnsone7245742012-09-05 17:12:55 -07006089#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006090 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07006091 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006092
6093 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07006094 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006095
6096 if( NULL == pRoamInfo )
6097 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006098 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006099 return -EINVAL;
6100 }
6101
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07006102 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
6103 {
6104 dump_bssid(pRoamInfo->bssid);
6105 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006106 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07006107 }
Jeff Johnsone7245742012-09-05 17:12:55 -07006108#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306109 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006110}
6111#endif //FEATURE_WLAN_LFR
6112
Yue Maef608272013-04-08 23:09:17 -07006113#ifdef FEATURE_WLAN_LFR_METRICS
6114/*
6115 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
6116 * 802.11r/LFR metrics reporting function to report preauth initiation
6117 *
6118 */
6119#define MAX_LFR_METRICS_EVENT_LENGTH 100
6120VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
6121 tCsrRoamInfo *pRoamInfo)
6122{
6123 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
6124 union iwreq_data wrqu;
6125
6126 ENTER();
6127
6128 if (NULL == pAdapter)
6129 {
6130 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
6131 return VOS_STATUS_E_FAILURE;
6132 }
6133
6134 /* create the event */
6135 memset(&wrqu, 0, sizeof(wrqu));
6136 memset(metrics_notification, 0, sizeof(metrics_notification));
6137
6138 wrqu.data.pointer = metrics_notification;
6139 wrqu.data.length = scnprintf(metrics_notification,
6140 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
6141 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
6142
6143 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
6144
6145 EXIT();
6146
6147 return VOS_STATUS_SUCCESS;
6148}
6149
6150/*
6151 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
6152 * 802.11r/LFR metrics reporting function to report preauth completion
6153 * or failure
6154 */
6155VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
6156 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
6157{
6158 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
6159 union iwreq_data wrqu;
6160
6161 ENTER();
6162
6163 if (NULL == pAdapter)
6164 {
6165 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
6166 return VOS_STATUS_E_FAILURE;
6167 }
6168
6169 /* create the event */
6170 memset(&wrqu, 0, sizeof(wrqu));
6171 memset(metrics_notification, 0, sizeof(metrics_notification));
6172
6173 scnprintf(metrics_notification, sizeof(metrics_notification),
6174 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
6175 MAC_ADDR_ARRAY(pRoamInfo->bssid));
6176
6177 if (1 == preauth_status)
6178 strncat(metrics_notification, " TRUE", 5);
6179 else
6180 strncat(metrics_notification, " FALSE", 6);
6181
6182 wrqu.data.pointer = metrics_notification;
6183 wrqu.data.length = strlen(metrics_notification);
6184
6185 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
6186
6187 EXIT();
6188
6189 return VOS_STATUS_SUCCESS;
6190}
6191
6192/*
6193 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
6194 * 802.11r/LFR metrics reporting function to report handover initiation
6195 *
6196 */
6197VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
6198 tCsrRoamInfo *pRoamInfo)
6199{
6200 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
6201 union iwreq_data wrqu;
6202
6203 ENTER();
6204
6205 if (NULL == pAdapter)
6206 {
6207 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
6208 return VOS_STATUS_E_FAILURE;
6209 }
6210
6211 /* create the event */
6212 memset(&wrqu, 0, sizeof(wrqu));
6213 memset(metrics_notification, 0, sizeof(metrics_notification));
6214
6215 wrqu.data.pointer = metrics_notification;
6216 wrqu.data.length = scnprintf(metrics_notification,
6217 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
6218 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
6219
6220 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
6221
6222 EXIT();
6223
6224 return VOS_STATUS_SUCCESS;
6225}
6226#endif
6227
Jeff Johnson295189b2012-06-20 16:38:30 -07006228/*
6229 * FUNCTION: hdd_cfg80211_scan_done_callback
6230 * scanning callback function, called after finishing scan
6231 *
6232 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306233static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07006234 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
6235{
6236 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306237 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006239 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6240 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07006241 struct cfg80211_scan_request *req = NULL;
6242 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306243 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306244 long waitRet = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006245
6246 ENTER();
6247
6248 hddLog(VOS_TRACE_LEVEL_INFO,
6249 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -08006250 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006251 __func__, halHandle, pContext, (int) scanId, (int) status);
6252
Kiet Lamac06e2c2013-10-23 16:25:07 +05306253 pScanInfo->mScanPendingCounter = 0;
6254
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306256 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 &pScanInfo->scan_req_completion_event,
6258 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306259 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306261 hddLog(VOS_TRACE_LEVEL_ERROR,
6262 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07006264 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07006265 }
6266
Yue Maef608272013-04-08 23:09:17 -07006267 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 {
6269 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07006270 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 }
6272
6273 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306274 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 {
6276 hddLog(VOS_TRACE_LEVEL_INFO,
6277 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -08006278 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 (int) scanId);
6280 }
6281
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306282 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006283 pAdapter);
6284
6285 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306286 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006287
6288
6289 /* If any client wait scan result through WEXT
6290 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006291 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 {
6293 /* The other scan request waiting for current scan finish
6294 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006295 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07006296 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006297 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07006298 }
6299 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006300 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 {
6302 struct net_device *dev = pAdapter->dev;
6303 union iwreq_data wrqu;
6304 int we_event;
6305 char *msg;
6306
6307 memset(&wrqu, '\0', sizeof(wrqu));
6308 we_event = SIOCGIWSCAN;
6309 msg = NULL;
6310 wireless_send_event(dev, we_event, &wrqu, msg);
6311 }
6312 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07006313 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006314
6315 /* Get the Scan Req */
6316 req = pAdapter->request;
6317
6318 if (!req)
6319 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08006320 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07006321 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07006322 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 }
6324
6325 /*
6326 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306327 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006328 req->n_ssids = 0;
6329 req->n_channels = 0;
6330 req->ie = 0;
6331
Jeff Johnson295189b2012-06-20 16:38:30 -07006332 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07006333 /* Scan is no longer pending */
6334 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006335
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07006336 /*
6337 * cfg80211_scan_done informing NL80211 about completion
6338 * of scanning
6339 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05306340 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
6341 {
6342 aborted = true;
6343 }
6344 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08006345 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07006346
Jeff Johnsone7245742012-09-05 17:12:55 -07006347allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07006348 /* release the wake lock at the end of the scan*/
6349 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07006350
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07006351 /* Acquire wakelock to handle the case where APP's tries to suspend
6352 * immediatly after the driver gets connect request(i.e after scan)
6353 * from supplicant, this result in app's is suspending and not able
6354 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +05306355 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07006356
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07006357#ifdef FEATURE_WLAN_TDLS
c_hpothu3c8f8e82014-06-02 18:01:50 +05306358 if (!(eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode))
6359 {
6360 wlan_hdd_tdls_scan_done_callback(pAdapter);
6361 }
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07006362#endif
6363
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 EXIT();
6365 return 0;
6366}
6367
6368/*
Rashmi Ramannab1429032014-04-26 14:59:09 +05306369 * FUNCTION: hdd_isConnectionInProgress
6370 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006371 *
6372 */
Rashmi Ramannab1429032014-04-26 14:59:09 +05306373v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx )
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006374{
6375 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
6376 hdd_station_ctx_t *pHddStaCtx = NULL;
6377 hdd_adapter_t *pAdapter = NULL;
6378 VOS_STATUS status = 0;
6379 v_U8_t staId = 0;
6380 v_U8_t *staMac = NULL;
6381
c_hpothu9b781ba2013-12-30 20:57:45 +05306382 if (TRUE == pHddCtx->btCoexModeSet)
6383 {
6384 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +05306385 FL("BTCoex Mode operation in progress"));
6386 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +05306387 }
6388
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006389 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
6390
6391 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
6392 {
6393 pAdapter = pAdapterNode->pAdapter;
6394
6395 if( pAdapter )
6396 {
6397 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306398 "%s: Adapter with device mode %s (%d) exists",
6399 __func__, hdd_device_modetoString(pAdapter->device_mode),
6400 pAdapter->device_mode);
Rashmi Ramannab1429032014-04-26 14:59:09 +05306401 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
6402 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
6403 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
6404 (eConnectionState_Connecting ==
6405 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6406 {
6407 hddLog(VOS_TRACE_LEVEL_ERROR,
6408 "%s: %p(%d) Connection is in progress", __func__,
6409 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
6410 return VOS_TRUE;
6411 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006412 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306413 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
6414 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006415 {
6416 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6417 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306418 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006419 {
6420 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
6421 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08006422 "%s: client " MAC_ADDRESS_STR
6423 " is in the middle of WPS/EAPOL exchange.", __func__,
6424 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05306425 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006426 }
6427 }
6428 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
6429 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
6430 {
6431 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
6432 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306433 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006434 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
6435 {
6436 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
6437
6438 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08006439 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
6440 "middle of WPS/EAPOL exchange.", __func__,
6441 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +05306442 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006443 }
6444 }
6445 }
6446 }
6447 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
6448 pAdapterNode = pNext;
6449 }
Rashmi Ramannab1429032014-04-26 14:59:09 +05306450 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306451}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006452
6453/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05306454 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -07006455 * this scan respond to scan trigger and update cfg80211 scan database
6456 * later, scan dump command can be used to recieve scan results
6457 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05306458int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08006459#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
6460 struct net_device *dev,
6461#endif
6462 struct cfg80211_scan_request *request)
6463{
Siddharth Bhal0c162d02014-05-06 19:50:42 +05306464 hdd_adapter_t *pAdapter = NULL;
6465 hdd_context_t *pHddCtx = NULL;
6466 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306467 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006468 tCsrScanRequest scanRequest;
6469 tANI_U8 *channelList = NULL, i;
6470 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306471 int status;
6472 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006473 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006474
Siddharth Bhal0c162d02014-05-06 19:50:42 +05306475#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
6476 struct net_device *dev = NULL;
6477 if (NULL == request)
6478 {
6479 hddLog(VOS_TRACE_LEVEL_ERROR,
6480 "%s: scan req param null", __func__);
6481 return -EINVAL;
6482 }
6483 dev = request->wdev->netdev;
6484#endif
6485
6486 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6487 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
6488 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6489
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 ENTER();
6491
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306492
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306493 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
6494 __func__, hdd_device_modetoString(pAdapter->device_mode),
6495 pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08006496
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306497 status = wlan_hdd_validate_context(pHddCtx);
6498
6499 if (0 != status)
6500 {
6501 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6502 "%s: HDD context is not valid", __func__);
6503 return status;
6504 }
6505
Siddharth Bhal0c162d02014-05-06 19:50:42 +05306506 if (NULL == pwextBuf)
6507 {
6508 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
6509 __func__);
6510 return -EIO;
6511 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306512 cfg_param = pHddCtx->cfg_ini;
6513 pScanInfo = &pHddCtx->scan_info;
6514
Jeff Johnson295189b2012-06-20 16:38:30 -07006515#ifdef WLAN_BTAMP_FEATURE
6516 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006517 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08006519 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 "%s: No scanning when AMP is on", __func__);
6521 return -EOPNOTSUPP;
6522 }
6523#endif
6524 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006525 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006527 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306528 "%s: Not scanning on device_mode = %s (%d)",
6529 __func__, hdd_device_modetoString(pAdapter->device_mode),
6530 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006531 return -EOPNOTSUPP;
6532 }
6533
6534 if (TRUE == pScanInfo->mScanPending)
6535 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05306536 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
6537 {
6538 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
6539 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006540 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07006541 }
6542
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306543 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07006544 //Channel and action frame is pending
6545 //Otherwise Cancel Remain On Channel and allow Scan
6546 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006547 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07006548 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05306549 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07006550 return -EBUSY;
6551 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006552#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07006553 /* if tdls disagree scan right now, return immediately.
6554 tdls will schedule the scan when scan is allowed. (return SUCCESS)
6555 or will reject the scan if any TDLS is in progress. (return -EBUSY)
6556 */
6557 status = wlan_hdd_tdls_scan_callback (pAdapter,
6558 wiphy,
6559#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
6560 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07006561#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07006562 request);
6563 if(status <= 0)
6564 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05306565 if(!status)
6566 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
6567 "scan rejected %d", __func__, status);
6568 else
6569 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
6570 __func__, status);
6571
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07006572 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006573 }
6574#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07006575
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
6577 {
6578 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08006579 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006582 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
6583 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05306584 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006585 "%s: MAX TM Level Scan not allowed", __func__);
6586 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306587 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 }
6589 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
6590
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006591 /* Check if scan is allowed at this point of time.
6592 */
Rashmi Ramannab1429032014-04-26 14:59:09 +05306593 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08006594 {
6595 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
6596 return -EBUSY;
6597 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306598
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 vos_mem_zero( &scanRequest, sizeof(scanRequest));
6600
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306601 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
6602 (int)request->n_ssids);
6603
6604 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
6605 * Becasue of this, driver is assuming that this is not wildcard scan and so
6606 * is not aging out the scan results.
6607 */
6608 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306610 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306612
6613 if ((request->ssids) && (0 < request->n_ssids))
6614 {
6615 tCsrSSIDInfo *SsidInfo;
6616 int j;
6617 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
6618 /* Allocate num_ssid tCsrSSIDInfo structure */
6619 SsidInfo = scanRequest.SSIDs.SSIDList =
6620 ( tCsrSSIDInfo *)vos_mem_malloc(
6621 request->n_ssids*sizeof(tCsrSSIDInfo));
6622
6623 if(NULL == scanRequest.SSIDs.SSIDList)
6624 {
6625 hddLog(VOS_TRACE_LEVEL_ERROR,
6626 "%s: memory alloc failed SSIDInfo buffer", __func__);
6627 return -ENOMEM;
6628 }
6629
6630 /* copy all the ssid's and their length */
6631 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
6632 {
6633 /* get the ssid length */
6634 SsidInfo->SSID.length = request->ssids[j].ssid_len;
6635 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
6636 SsidInfo->SSID.length);
6637 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
6638 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
6639 j, SsidInfo->SSID.ssId);
6640 }
6641 /* set the scan type to active */
6642 scanRequest.scanType = eSIR_ACTIVE_SCAN;
6643 }
6644 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +05306646 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6647 TRACE_CODE_HDD_CFG80211_SCAN,
6648 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -07006649 /* set the scan type to active */
6650 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306652 else
6653 {
6654 /*Set the scan type to default type, in this case it is ACTIVE*/
6655 scanRequest.scanType = pScanInfo->scan_mode;
6656 }
6657 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
6658 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07006659
6660 /* set BSSType to default type */
6661 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
6662
6663 /*TODO: scan the requested channels only*/
6664
6665 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306666 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306668 hddLog(VOS_TRACE_LEVEL_WARN,
6669 "No of Scan Channels exceeded limit: %d", request->n_channels);
6670 request->n_channels = MAX_CHANNEL;
6671 }
6672
6673 hddLog(VOS_TRACE_LEVEL_INFO,
6674 "No of Scan Channels: %d", request->n_channels);
6675
6676
6677 if( request->n_channels )
6678 {
6679 char chList [(request->n_channels*5)+1];
6680 int len;
6681 channelList = vos_mem_malloc( request->n_channels );
6682 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +05306683 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306684 hddLog(VOS_TRACE_LEVEL_ERROR,
6685 "%s: memory alloc failed channelList", __func__);
6686 status = -ENOMEM;
6687 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +05306688 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306689
6690 for( i = 0, len = 0; i < request->n_channels ; i++ )
6691 {
6692 channelList[i] = request->channels[i]->hw_value;
6693 len += snprintf(chList+len, 5, "%d ", channelList[i]);
6694 }
6695
Nirav Shah20ac06f2013-12-12 18:14:06 +05306696 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306697 "Channel-List: %s ", chList);
6698 }
c_hpothu53512302014-04-15 18:49:53 +05306699
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306700 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
6701 scanRequest.ChannelInfo.ChannelList = channelList;
6702
6703 /* set requestType to full scan */
6704 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
6705
6706 /* Flush the scan results(only p2p beacons) for STA scan and P2P
6707 * search (Flush on both full scan and social scan but not on single
6708 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
6709 */
6710
6711 /* Supplicant does single channel scan after 8-way handshake
6712 * and in that case driver shoudnt flush scan results. If
6713 * driver flushes the scan results here and unfortunately if
6714 * the AP doesnt respond to our probe req then association
6715 * fails which is not desired
6716 */
6717
6718 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
6719 {
6720 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
6721 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
6722 pAdapter->sessionId );
6723 }
6724
6725 if( request->ie_len )
6726 {
6727 /* save this for future association (join requires this) */
6728 /*TODO: Array needs to be converted to dynamic allocation,
6729 * as multiple ie.s can be sent in cfg80211_scan_request structure
6730 * CR 597966
6731 */
6732 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
6733 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
6734 pScanInfo->scanAddIE.length = request->ie_len;
6735
6736 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
6737 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
6738 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306740 if ( request->ie_len <= SIR_MAC_MAX_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306742 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
6743 memcpy( pwextBuf->roamProfile.addIEScan,
6744 request->ie, request->ie_len);
6745 }
6746 else
6747 {
6748 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
6749 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07006750 }
6751
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306752 }
6753 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
6754 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
6755
6756 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
6757 request->ie_len);
6758 if (pP2pIe != NULL)
6759 {
6760#ifdef WLAN_FEATURE_P2P_DEBUG
6761 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
6762 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
6763 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +05306764 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306765 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
6766 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
6767 "Go nego completed to Connection is started");
6768 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
6769 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +05306770 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306771 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
6772 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07006773 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306774 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
6775 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
6776 "Disconnected state to Connection is started");
6777 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
6778 "for 4way Handshake");
6779 }
6780#endif
6781
6782 /* no_cck will be set during p2p find to disable 11b rates */
6783 if(TRUE == request->no_cck)
6784 {
6785 hddLog(VOS_TRACE_LEVEL_INFO,
6786 "%s: This is a P2P Search", __func__);
6787 scanRequest.p2pSearch = 1;
6788
6789 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +05306790 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306791 /* set requestType to P2P Discovery */
6792 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
6793 }
6794
6795 /*
6796 Skip Dfs Channel in case of P2P Search
6797 if it is set in ini file
6798 */
6799 if(cfg_param->skipDfsChnlInP2pSearch)
6800 {
6801 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +05306802 }
6803 else
6804 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +05306805 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +05306806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006807
Agarwal Ashish4f616132013-12-30 23:32:50 +05306808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 }
6810 }
6811
6812 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
6813
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07006814 /* acquire the wakelock to avoid the apps suspend during the scan. To
6815 * address the following issues.
6816 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
6817 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
6818 * for long time, this result in apps running at full power for long time.
6819 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
6820 * be stuck in full power because of resume BMPS
6821 */
6822 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07006823
Nirav Shah20ac06f2013-12-12 18:14:06 +05306824 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6825 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306826 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
6827 scanRequest.requestType, scanRequest.scanType,
6828 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +05306829 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
6830
Jeff Johnsone7245742012-09-05 17:12:55 -07006831 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07006832 pAdapter->sessionId, &scanRequest, &scanId,
6833 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07006834
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 if (eHAL_STATUS_SUCCESS != status)
6836 {
6837 hddLog(VOS_TRACE_LEVEL_ERROR,
6838 "%s: sme_ScanRequest returned error %d", __func__, status);
6839 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07006840 if(eHAL_STATUS_RESOURCES == status)
6841 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05306842 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
6843 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07006844 status = -EBUSY;
6845 } else {
6846 status = -EIO;
6847 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07006848 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 goto free_mem;
6850 }
6851
6852 pScanInfo->mScanPending = TRUE;
6853 pAdapter->request = request;
6854 pScanInfo->scanId = scanId;
6855
6856 complete(&pScanInfo->scan_req_completion_event);
6857
6858free_mem:
6859 if( scanRequest.SSIDs.SSIDList )
6860 {
6861 vos_mem_free(scanRequest.SSIDs.SSIDList);
6862 }
6863
6864 if( channelList )
6865 vos_mem_free( channelList );
6866
6867 EXIT();
6868
6869 return status;
6870}
6871
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05306872int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
6873#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
6874 struct net_device *dev,
6875#endif
6876 struct cfg80211_scan_request *request)
6877{
6878 int ret;
6879
6880 vos_ssr_protect(__func__);
6881 ret = __wlan_hdd_cfg80211_scan(wiphy,
6882#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
6883 dev,
6884#endif
6885 request);
6886 vos_ssr_unprotect(__func__);
6887
6888 return ret;
6889}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006890
6891void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
6892{
6893 v_U8_t iniDot11Mode =
6894 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
6895 eHddDot11Mode hddDot11Mode = iniDot11Mode;
6896
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05306897 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
6898 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006899 switch ( iniDot11Mode )
6900 {
6901 case eHDD_DOT11_MODE_AUTO:
6902 case eHDD_DOT11_MODE_11ac:
6903 case eHDD_DOT11_MODE_11ac_ONLY:
6904#ifdef WLAN_FEATURE_11AC
6905 hddDot11Mode = eHDD_DOT11_MODE_11ac;
6906#else
6907 hddDot11Mode = eHDD_DOT11_MODE_11n;
6908#endif
6909 break;
6910 case eHDD_DOT11_MODE_11n:
6911 case eHDD_DOT11_MODE_11n_ONLY:
6912 hddDot11Mode = eHDD_DOT11_MODE_11n;
6913 break;
6914 default:
6915 hddDot11Mode = iniDot11Mode;
6916 break;
6917 }
6918 /* This call decides required channel bonding mode */
6919 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
6920 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
6921 operationChannel);
6922}
6923
Jeff Johnson295189b2012-06-20 16:38:30 -07006924/*
6925 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306926 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07006927 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306928int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07006929 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006930{
6931 int status = 0;
6932 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -08006933 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 v_U32_t roamId;
6935 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 eCsrAuthType RSNAuthType;
6937
6938 ENTER();
6939
6940 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -08006941 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6942
6943 status = wlan_hdd_validate_context(pHddCtx);
6944 if (status)
6945 {
6946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6947 "%s: HDD context is not valid!", __func__);
6948 return status;
6949 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306950
Jeff Johnson295189b2012-06-20 16:38:30 -07006951 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
6952 {
6953 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
6954 return -EINVAL;
6955 }
6956
6957 pRoamProfile = &pWextState->roamProfile;
6958
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306959 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07006960 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006961 hdd_station_ctx_t *pHddStaCtx;
6962 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006963
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306964 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07006965 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
6966 {
6967 /*QoS not enabled in cfg file*/
6968 pRoamProfile->uapsd_mask = 0;
6969 }
6970 else
6971 {
6972 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306973 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
6975 }
6976
6977 pRoamProfile->SSIDs.numOfSSIDs = 1;
6978 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
6979 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306980 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
6982 ssid, ssid_len);
6983
6984 if (bssid)
6985 {
6986 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
6987 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
6988 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306989 /* Save BSSID in seperate variable as well, as RoamProfile
6990 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07006991 case of join failure we should send valid BSSID to supplicant
6992 */
6993 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
6994 WNI_CFG_BSSID_LEN);
6995 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07006996 else
6997 {
6998 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
6999 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007000
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05307001 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
7002 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
7004 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307005 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007006 /*set gen ie*/
7007 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
7008 /*set auth*/
7009 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
7010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007011#ifdef FEATURE_WLAN_WAPI
7012 if (pAdapter->wapi_info.nWapiMode)
7013 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007014 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 switch (pAdapter->wapi_info.wapiAuthMode)
7016 {
7017 case WAPI_AUTH_MODE_PSK:
7018 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007019 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 pAdapter->wapi_info.wapiAuthMode);
7021 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
7022 break;
7023 }
7024 case WAPI_AUTH_MODE_CERT:
7025 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007026 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 pAdapter->wapi_info.wapiAuthMode);
7028 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
7029 break;
7030 }
7031 } // End of switch
7032 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
7033 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
7034 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007035 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007036 pRoamProfile->AuthType.numEntries = 1;
7037 pRoamProfile->EncryptionType.numEntries = 1;
7038 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
7039 pRoamProfile->mcEncryptionType.numEntries = 1;
7040 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
7041 }
7042 }
7043#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307044#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307045 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307046 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
7047 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
7048 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307049 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
7050 sizeof (tSirGtkOffloadParams));
7051 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307052 }
7053#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 pRoamProfile->csrPersona = pAdapter->device_mode;
7055
Jeff Johnson32d95a32012-09-10 13:15:23 -07007056 if( operatingChannel )
7057 {
7058 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
7059 pRoamProfile->ChannelInfo.numOfChannels = 1;
7060 }
Chet Lanctot186b5732013-03-18 10:26:30 -07007061 else
7062 {
7063 pRoamProfile->ChannelInfo.ChannelList = NULL;
7064 pRoamProfile->ChannelInfo.numOfChannels = 0;
7065 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07007066 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
7067 {
7068 hdd_select_cbmode(pAdapter,operatingChannel);
7069 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05307070
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08007071 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
7072 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307073 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08007074 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08007075 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
7076 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307077 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
7078 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +05307079 {
7080 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7081 "%s: Set HDD connState to eConnectionState_Connecting",
7082 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08007083 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
7084 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +05307085 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307086 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 pAdapter->sessionId, pRoamProfile, &roamId);
7088
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05307089 if ((eHAL_STATUS_SUCCESS != status) &&
7090 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
7091 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05307092
7093 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08007094 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
7095 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
7096 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05307097 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08007098 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05307099 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08007100
7101 pRoamProfile->ChannelInfo.ChannelList = NULL;
7102 pRoamProfile->ChannelInfo.numOfChannels = 0;
7103
Jeff Johnson295189b2012-06-20 16:38:30 -07007104 }
7105 else
7106 {
7107 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
7108 return -EINVAL;
7109 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08007110 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007111 return status;
7112}
7113
7114/*
7115 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
7116 * This function is used to set the authentication type (OPEN/SHARED).
7117 *
7118 */
7119static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
7120 enum nl80211_auth_type auth_type)
7121{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307122 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007123 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7124
7125 ENTER();
7126
7127 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307128 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07007129 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007130 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05307131 hddLog(VOS_TRACE_LEVEL_INFO,
7132 "%s: set authentication type to AUTOSWITCH", __func__);
7133 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
7134 break;
7135
7136 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007137#ifdef WLAN_FEATURE_VOWIFI_11R
7138 case NL80211_AUTHTYPE_FT:
7139#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307140 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 "%s: set authentication type to OPEN", __func__);
7142 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
7143 break;
7144
7145 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307146 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 "%s: set authentication type to SHARED", __func__);
7148 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
7149 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007150#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307152 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 "%s: set authentication type to CCKM WPA", __func__);
7154 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
7155 break;
7156#endif
7157
7158
7159 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307160 hddLog(VOS_TRACE_LEVEL_ERROR,
7161 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 auth_type);
7163 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
7164 return -EINVAL;
7165 }
7166
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307167 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07007168 pHddStaCtx->conn_info.authType;
7169 return 0;
7170}
7171
7172/*
7173 * FUNCTION: wlan_hdd_set_akm_suite
7174 * This function is used to set the key mgmt type(PSK/8021x).
7175 *
7176 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307177static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07007178 u32 key_mgmt
7179 )
7180{
7181 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7182 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307183
Jeff Johnson295189b2012-06-20 16:38:30 -07007184 /*set key mgmt type*/
7185 switch(key_mgmt)
7186 {
7187 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307188#ifdef WLAN_FEATURE_VOWIFI_11R
7189 case WLAN_AKM_SUITE_FT_PSK:
7190#endif
7191 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 __func__);
7193 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
7194 break;
7195
7196 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307197#ifdef WLAN_FEATURE_VOWIFI_11R
7198 case WLAN_AKM_SUITE_FT_8021X:
7199#endif
7200 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 __func__);
7202 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
7203 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007204#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007205#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
7206#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
7207 case WLAN_AKM_SUITE_CCKM:
7208 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
7209 __func__);
7210 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
7211 break;
7212#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07007213#ifndef WLAN_AKM_SUITE_OSEN
7214#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
7215 case WLAN_AKM_SUITE_OSEN:
7216 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
7217 __func__);
7218 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
7219 break;
7220#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007221
7222 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307223 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007224 __func__, key_mgmt);
7225 return -EINVAL;
7226
7227 }
7228 return 0;
7229}
7230
7231/*
7232 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307233 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07007234 * (NONE/WEP40/WEP104/TKIP/CCMP).
7235 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307236static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
7237 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 bool ucast
7239 )
7240{
7241 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307242 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7244
7245 ENTER();
7246
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307247 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07007248 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307249 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07007250 __func__, cipher);
7251 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
7252 }
7253 else
7254 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307255
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307257 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07007258 {
7259 case IW_AUTH_CIPHER_NONE:
7260 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
7261 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307262
Jeff Johnson295189b2012-06-20 16:38:30 -07007263 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05307264 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07007265 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307266
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05307268 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07007269 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307270
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 case WLAN_CIPHER_SUITE_TKIP:
7272 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
7273 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307274
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 case WLAN_CIPHER_SUITE_CCMP:
7276 encryptionType = eCSR_ENCRYPT_TYPE_AES;
7277 break;
7278#ifdef FEATURE_WLAN_WAPI
7279 case WLAN_CIPHER_SUITE_SMS4:
7280 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
7281 break;
7282#endif
7283
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007284#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007285 case WLAN_CIPHER_SUITE_KRK:
7286 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
7287 break;
7288#endif
7289 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307290 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 __func__, cipher);
7292 return -EOPNOTSUPP;
7293 }
7294 }
7295
7296 if (ucast)
7297 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307298 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007299 __func__, encryptionType);
7300 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
7301 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307302 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07007303 encryptionType;
7304 }
7305 else
7306 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307307 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007308 __func__, encryptionType);
7309 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
7310 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
7311 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
7312 }
7313
7314 return 0;
7315}
7316
7317
7318/*
7319 * FUNCTION: wlan_hdd_cfg80211_set_ie
7320 * This function is used to parse WPA/RSN IE's.
7321 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307322int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
7323 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07007324 size_t ie_len
7325 )
7326{
7327 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
7328 u8 *genie = ie;
7329 v_U16_t remLen = ie_len;
7330#ifdef FEATURE_WLAN_WAPI
7331 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
7332 u16 *tmp;
7333 v_U16_t akmsuiteCount;
7334 int *akmlist;
7335#endif
7336 ENTER();
7337
7338 /* clear previous assocAddIE */
7339 pWextState->assocAddIE.length = 0;
7340 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007341 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007342
7343 while (remLen >= 2)
7344 {
7345 v_U16_t eLen = 0;
7346 v_U8_t elementId;
7347 elementId = *genie++;
7348 eLen = *genie++;
7349 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307350
Arif Hussain6d2a3322013-11-17 19:50:10 -08007351 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -07007352 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307353
7354 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07007355 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307356 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007357 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 -07007358 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307359 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007360 "%s: Invalid WPA IE", __func__);
7361 return -EINVAL;
7362 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307363 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 {
7365 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307366 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07007367 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307368
Jeff Johnson295189b2012-06-20 16:38:30 -07007369 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
7370 {
Jeff Johnson902c9832012-12-10 14:28:09 -08007371 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
7372 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07007373 VOS_ASSERT(0);
7374 return -ENOMEM;
7375 }
7376 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
7377 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
7378 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307379
Jeff Johnson295189b2012-06-20 16:38:30 -07007380 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
7381 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
7382 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
7383 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307384 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
7385 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
7387 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
7388 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
7389 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
7390 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
7391 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307392 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +05307393 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 {
7395 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307396 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07007397 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307398
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
7400 {
Jeff Johnson902c9832012-12-10 14:28:09 -08007401 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
7402 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 VOS_ASSERT(0);
7404 return -ENOMEM;
7405 }
7406 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
7407 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
7408 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307409
Jeff Johnson295189b2012-06-20 16:38:30 -07007410 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
7411 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
7412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007413#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307414 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
7415 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07007416 /*Consider WFD IE, only for P2P Client */
7417 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
7418 {
7419 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307420 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307422
Jeff Johnson295189b2012-06-20 16:38:30 -07007423 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
7424 {
Jeff Johnson902c9832012-12-10 14:28:09 -08007425 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
7426 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07007427 VOS_ASSERT(0);
7428 return -ENOMEM;
7429 }
7430 // WFD IE is saved to Additional IE ; it should be accumulated to handle
7431 // WPS IE + P2P IE + WFD IE
7432 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
7433 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307434
Jeff Johnson295189b2012-06-20 16:38:30 -07007435 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
7436 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
7437 }
7438#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007439 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307440 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007441 HS20_OUI_TYPE_SIZE)) )
7442 {
7443 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307444 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007445 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007446
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007447 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
7448 {
Jeff Johnson902c9832012-12-10 14:28:09 -08007449 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
7450 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007451 VOS_ASSERT(0);
7452 return -ENOMEM;
7453 }
7454 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
7455 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007456
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007457 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
7458 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
7459 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007460 /* Appending OSEN Information Element in Assiciation Request */
7461 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
7462 OSEN_OUI_TYPE_SIZE)) )
7463 {
7464 v_U16_t curAddIELen = pWextState->assocAddIE.length;
7465 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
7466 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007467
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007468 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
7469 {
7470 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
7471 "Need bigger buffer space");
7472 VOS_ASSERT(0);
7473 return -ENOMEM;
7474 }
7475 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
7476 pWextState->assocAddIE.length += eLen + 2;
7477
7478 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
7479 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
7480 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
7481 }
7482
7483 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07007484 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
7485
7486 /* populating as ADDIE in beacon frames */
7487 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
7488 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
7489 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
7490 {
7491 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
7492 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
7493 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
7494 {
7495 hddLog(LOGE,
7496 "Coldn't pass "
7497 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
7498 }
7499 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
7500 else
7501 hddLog(LOGE,
7502 "Could not pass on "
7503 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
7504
7505 /* IBSS mode doesn't contain params->proberesp_ies still
7506 beaconIE's need to be populated in probe response frames */
7507 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
7508 {
7509 u16 rem_probe_resp_ie_len = eLen + 2;
7510 u8 probe_rsp_ie_len[3] = {0};
7511 u8 counter = 0;
7512
7513 /* Check Probe Resp Length if it is greater then 255 then
7514 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
7515 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
7516 not able Store More then 255 bytes into One Variable */
7517
7518 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
7519 {
7520 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
7521 {
7522 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
7523 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
7524 }
7525 else
7526 {
7527 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
7528 rem_probe_resp_ie_len = 0;
7529 }
7530 }
7531
7532 rem_probe_resp_ie_len = 0;
7533
7534 if (probe_rsp_ie_len[0] > 0)
7535 {
7536 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
7537 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
7538 (tANI_U8*)(genie - 2),
7539 probe_rsp_ie_len[0], NULL,
7540 eANI_BOOLEAN_FALSE)
7541 == eHAL_STATUS_FAILURE)
7542 {
7543 hddLog(LOGE,
7544 "Could not pass"
7545 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
7546 }
7547 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
7548 }
7549
7550 if (probe_rsp_ie_len[1] > 0)
7551 {
7552 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
7553 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
7554 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
7555 probe_rsp_ie_len[1], NULL,
7556 eANI_BOOLEAN_FALSE)
7557 == eHAL_STATUS_FAILURE)
7558 {
7559 hddLog(LOGE,
7560 "Could not pass"
7561 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
7562 }
7563 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
7564 }
7565
7566 if (probe_rsp_ie_len[2] > 0)
7567 {
7568 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
7569 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
7570 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
7571 probe_rsp_ie_len[2], NULL,
7572 eANI_BOOLEAN_FALSE)
7573 == eHAL_STATUS_FAILURE)
7574 {
7575 hddLog(LOGE,
7576 "Could not pass"
7577 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
7578 }
7579 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
7580 }
7581
7582 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
7583 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
7584 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
7585 {
7586 hddLog(LOGE,
7587 "Could not pass"
7588 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
7589 }
7590 }
7591 else
7592 {
7593 // Reset WNI_CFG_PROBE_RSP Flags
7594 wlan_hdd_reset_prob_rspies(pAdapter);
7595
7596 hddLog(VOS_TRACE_LEVEL_INFO,
7597 "%s: No Probe Response IE received in set beacon",
7598 __func__);
7599 }
7600 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07007601 break;
7602 case DOT11F_EID_RSN:
7603 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
7604 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
7605 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
7606 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
7607 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
7608 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007609 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
7610 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307611 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007612 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307613 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007614 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307615
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007616 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
7617 {
Jeff Johnson902c9832012-12-10 14:28:09 -08007618 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
7619 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007620 VOS_ASSERT(0);
7621 return -ENOMEM;
7622 }
7623 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
7624 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307625
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007626 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
7627 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
7628 break;
7629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007630#ifdef FEATURE_WLAN_WAPI
7631 case WLAN_EID_WAPI:
7632 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007633 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 pAdapter->wapi_info.nWapiMode);
7635 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307636 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 akmsuiteCount = WPA_GET_LE16(tmp);
7638 tmp = tmp + 1;
7639 akmlist = (int *)(tmp);
7640 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
7641 {
7642 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
7643 }
7644 else
7645 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007646 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 VOS_ASSERT(0);
7648 return -EINVAL;
7649 }
7650
7651 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
7652 {
7653 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007654 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007657 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307658 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007659 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007660 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007661 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
7662 }
7663 break;
7664#endif
7665 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307666 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007667 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07007668 /* when Unknown IE is received we should break and continue
7669 * to the next IE in the buffer instead we were returning
7670 * so changing this to break */
7671 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 }
7673 genie += eLen;
7674 remLen -= eLen;
7675 }
7676 EXIT();
7677 return 0;
7678}
7679
7680/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05307681 * FUNCTION: hdd_isWPAIEPresent
7682 * Parse the received IE to find the WPA IE
7683 *
7684 */
7685static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
7686{
7687 v_U8_t eLen = 0;
7688 v_U16_t remLen = ie_len;
7689 v_U8_t elementId = 0;
7690
7691 while (remLen >= 2)
7692 {
7693 elementId = *ie++;
7694 eLen = *ie++;
7695 remLen -= 2;
7696 if (eLen > remLen)
7697 {
7698 hddLog(VOS_TRACE_LEVEL_ERROR,
7699 "%s: IE length is wrong %d", __func__, eLen);
7700 return FALSE;
7701 }
7702 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
7703 {
7704 /* OUI - 0x00 0X50 0XF2
7705 WPA Information Element - 0x01
7706 WPA version - 0x01*/
7707 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
7708 return TRUE;
7709 }
7710 ie += eLen;
7711 remLen -= eLen;
7712 }
7713 return FALSE;
7714}
7715
7716/*
Jeff Johnson295189b2012-06-20 16:38:30 -07007717 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307718 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07007719 * parameters during connect operation.
7720 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307721int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 struct cfg80211_connect_params *req
7723 )
7724{
7725 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307726 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007727 ENTER();
7728
7729 /*set wpa version*/
7730 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
7731
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307732 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07007733 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05307734 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07007735 {
7736 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
7737 }
7738 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
7739 {
7740 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
7741 }
7742 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307743
7744 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 pWextState->wpaVersion);
7746
7747 /*set authentication type*/
7748 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
7749
7750 if (0 > status)
7751 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307752 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007753 "%s: failed to set authentication type ", __func__);
7754 return status;
7755 }
7756
7757 /*set key mgmt type*/
7758 if (req->crypto.n_akm_suites)
7759 {
7760 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
7761 if (0 > status)
7762 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307763 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07007764 __func__);
7765 return status;
7766 }
7767 }
7768
7769 /*set pairwise cipher type*/
7770 if (req->crypto.n_ciphers_pairwise)
7771 {
7772 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
7773 req->crypto.ciphers_pairwise[0], true);
7774 if (0 > status)
7775 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307776 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007777 "%s: failed to set unicast cipher type", __func__);
7778 return status;
7779 }
7780 }
7781 else
7782 {
7783 /*Reset previous cipher suite to none*/
7784 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
7785 if (0 > status)
7786 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307787 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007788 "%s: failed to set unicast cipher type", __func__);
7789 return status;
7790 }
7791 }
7792
7793 /*set group cipher type*/
7794 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
7795 false);
7796
7797 if (0 > status)
7798 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307799 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07007800 __func__);
7801 return status;
7802 }
7803
Chet Lanctot186b5732013-03-18 10:26:30 -07007804#ifdef WLAN_FEATURE_11W
7805 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
7806#endif
7807
Jeff Johnson295189b2012-06-20 16:38:30 -07007808 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
7809 if (req->ie_len)
7810 {
7811 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
7812 if ( 0 > status)
7813 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307814 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07007815 __func__);
7816 return status;
7817 }
7818 }
7819
7820 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307821 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07007822 {
7823 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
7824 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
7825 )
7826 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307827 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07007828 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
7829 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307830 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07007831 __func__);
7832 return -EOPNOTSUPP;
7833 }
7834 else
7835 {
7836 u8 key_len = req->key_len;
7837 u8 key_idx = req->key_idx;
7838
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307839 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 && (CSR_MAX_NUM_KEY > key_idx)
7841 )
7842 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307843 hddLog(VOS_TRACE_LEVEL_INFO,
7844 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 __func__, key_idx, key_len);
7846 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307847 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07007848 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307849 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07007850 (u8)key_len;
7851 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
7852 }
7853 }
7854 }
7855 }
7856
7857 return status;
7858}
7859
7860/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05307861 * FUNCTION: wlan_hdd_try_disconnect
7862 * This function is used to disconnect from previous
7863 * connection
7864 */
7865static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
7866{
7867 long ret = 0;
7868 hdd_station_ctx_t *pHddStaCtx;
7869 eMib_dot11DesiredBssType connectedBssType;
7870
7871 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7872
7873 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
7874
7875 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
7876 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
7877 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
7878 {
7879 /* Issue disconnect to CSR */
7880 INIT_COMPLETION(pAdapter->disconnect_comp_var);
7881 if( eHAL_STATUS_SUCCESS ==
7882 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
7883 pAdapter->sessionId,
7884 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
7885 {
7886 ret = wait_for_completion_interruptible_timeout(
7887 &pAdapter->disconnect_comp_var,
7888 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7889 if (0 >= ret)
7890 {
7891 hddLog(LOGE, FL("Failed to receive disconnect event"));
7892 return -EALREADY;
7893 }
7894 }
7895 }
7896 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
7897 {
7898 ret = wait_for_completion_interruptible_timeout(
7899 &pAdapter->disconnect_comp_var,
7900 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
7901 if (0 >= ret)
7902 {
7903 hddLog(LOGE, FL("Failed to receive disconnect event"));
7904 return -EALREADY;
7905 }
7906 }
7907
7908 return 0;
7909}
7910
7911/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05307912 * FUNCTION: __wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307913 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 * parameters during connect operation.
7915 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05307916static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007917 struct net_device *ndev,
7918 struct cfg80211_connect_params *req
7919 )
7920{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307921 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307922 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07007923 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007924 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007925
7926 ENTER();
7927
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307928 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7929 TRACE_CODE_HDD_CFG80211_CONNECT,
7930 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307931 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307932 "%s: device_mode = %s (%d)", __func__,
7933 hdd_device_modetoString(pAdapter->device_mode),
7934 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007935
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307936 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007937 if (!pHddCtx)
7938 {
7939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7940 "%s: HDD context is null", __func__);
7941 return VOS_STATUS_E_FAILURE;
7942 }
7943
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307944 status = wlan_hdd_validate_context(pHddCtx);
7945
7946 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007947 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307948 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7949 "%s: HDD context is not valid", __func__);
7950 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 }
7952
7953#ifdef WLAN_BTAMP_FEATURE
7954 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307955 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307957 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007958 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08007959 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07007960 }
7961#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05307962
7963 //If Device Mode is Station Concurrent Sessions Exit BMps
7964 //P2P Mode will be taken care in Open/close adapter
7965 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
7966 (vos_concurrent_sessions_running()))
7967 {
7968 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
7969 }
7970
7971 /*Try disconnecting if already in connected state*/
7972 status = wlan_hdd_try_disconnect(pAdapter);
7973 if ( 0 > status)
7974 {
7975 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
7976 " connection"));
7977 return -EALREADY;
7978 }
7979
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307981 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07007982
7983 if ( 0 > status)
7984 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307985 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07007986 __func__);
7987 return status;
7988 }
7989
Mohit Khanna765234a2012-09-11 15:08:35 -07007990 if ( req->channel )
7991 {
7992 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
7993 req->ssid_len, req->bssid,
7994 req->channel->hw_value);
7995 }
7996 else
7997 {
7998 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307999 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07008000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008001
8002 if (0 > status)
8003 {
8004 //ReEnable BMPS if disabled
8005 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
8006 (NULL != pHddCtx))
8007 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308008 if (pHddCtx->hdd_wlan_suspended)
8009 {
8010 hdd_set_pwrparams(pHddCtx);
8011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008012 //ReEnable Bmps and Imps back
8013 hdd_enable_bmps_imps(pHddCtx);
8014 }
8015
8016 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
8017 return status;
8018 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308019 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008020 EXIT();
8021 return status;
8022}
8023
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05308024static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
8025 struct net_device *ndev,
8026 struct cfg80211_connect_params *req)
8027{
8028 int ret;
8029 vos_ssr_protect(__func__);
8030 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
8031 vos_ssr_unprotect(__func__);
8032
8033 return ret;
8034}
Jeff Johnson295189b2012-06-20 16:38:30 -07008035
8036/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308037 * FUNCTION: wlan_hdd_disconnect
8038 * This function is used to issue a disconnect request to SME
8039 */
8040int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
8041{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308042 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308043 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308044 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8045
8046 status = wlan_hdd_validate_context(pHddCtx);
8047
8048 if (0 != status)
8049 {
8050 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8051 "%s: HDD context is not valid", __func__);
8052 return status;
8053 }
8054
8055 pHddCtx->isAmpAllowed = VOS_TRUE;
Abhishek Singhf4669da2014-05-26 15:07:49 +05308056 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8057 "%s: Set HDD connState to eConnectionState_Disconnecting",
8058 __func__);
Vinay Krishna Erannab09d3e72014-03-26 21:23:55 +05308059 pHddStaCtx->conn_info.connState = eConnectionState_Disconnecting;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308060 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308061
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308062 /*issue disconnect*/
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05308063
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308064 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8065 pAdapter->sessionId, reason);
8066
8067 if ( 0 != status )
8068 {
8069 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008070 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308071 __func__, (int)status );
8072 return -EINVAL;
8073 }
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05308074 status = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308075 &pAdapter->disconnect_comp_var,
8076 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05308077 if (!status)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308078 {
8079 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05308080 "%s: Failed to disconnect, timed out", __func__);
8081 return -ETIMEDOUT;
8082 }
8083 else if (status == -ERESTARTSYS)
8084 {
8085 hddLog(VOS_TRACE_LEVEL_ERROR,
8086 "%s: Failed to disconnect, wait interrupted", __func__);
8087 return status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308088 }
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308089 /*stop tx queues*/
8090 netif_tx_disable(pAdapter->dev);
8091 netif_carrier_off(pAdapter->dev);
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +05308092 return 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308093}
8094
8095
8096/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05308097 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -07008098 * This function is used to issue a disconnect request to SME
8099 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05308100static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008101 struct net_device *dev,
8102 u16 reason
8103 )
8104{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308105 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
8106 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07008107 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308108 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008109 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008110 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05308111#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08008112 tANI_U8 staIdx;
8113#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308114
Jeff Johnson295189b2012-06-20 16:38:30 -07008115 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308116
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308117 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8118 TRACE_CODE_HDD_CFG80211_DISCONNECT,
8119 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308120 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
8121 __func__, hdd_device_modetoString(pAdapter->device_mode),
8122 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008123
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308124 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
8125 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07008126
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308127 status = wlan_hdd_validate_context(pHddCtx);
8128
8129 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008130 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308131 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8132 "%s: HDD context is not valid", __func__);
8133 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308135
Jeff Johnson295189b2012-06-20 16:38:30 -07008136 if (NULL != pRoamProfile)
8137 {
8138 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +05308139 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
8140 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -07008141 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308142 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07008143 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05308144 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008145 switch(reason)
8146 {
8147 case WLAN_REASON_MIC_FAILURE:
8148 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
8149 break;
8150
8151 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
8152 case WLAN_REASON_DISASSOC_AP_BUSY:
8153 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
8154 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
8155 break;
8156
8157 case WLAN_REASON_PREV_AUTH_NOT_VALID:
8158 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +05308159 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
8161 break;
8162
Jeff Johnson295189b2012-06-20 16:38:30 -07008163 default:
8164 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
8165 break;
8166 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05308167 pScanInfo = &pHddCtx->scan_info;
8168 if (pScanInfo->mScanPending)
8169 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05308170 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05308171 "Aborting Scan");
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05308172 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId,
8173 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05308174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008175
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08008176#ifdef FEATURE_WLAN_TDLS
8177 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008178 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08008179 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008180 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
8181 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08008182 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008183 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008184 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008185 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008186 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008187 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008188 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08008189 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008190 pAdapter->sessionId,
8191 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08008192 }
8193 }
8194#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +05308195 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308196 status = wlan_hdd_disconnect(pAdapter, reasonCode);
8197 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07008198 {
8199 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008200 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 __func__, (int)status );
8202 return -EINVAL;
8203 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008204 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +05308205 else
8206 {
8207 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
8208 "called while in %d state", __func__,
8209 pHddStaCtx->conn_info.connState);
8210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008211 }
8212 else
8213 {
8214 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
8215 }
8216
8217 return status;
8218}
8219
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +05308220static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
8221 struct net_device *dev,
8222 u16 reason
8223 )
8224{
8225 int ret;
8226 vos_ssr_protect(__func__);
8227 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
8228 vos_ssr_unprotect(__func__);
8229
8230 return ret;
8231}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05308232
Jeff Johnson295189b2012-06-20 16:38:30 -07008233/*
8234 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308235 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 * settings in IBSS mode.
8237 */
8238static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308239 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 struct cfg80211_ibss_params *params
8241 )
8242{
8243 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308244 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
8246 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308247
Jeff Johnson295189b2012-06-20 16:38:30 -07008248 ENTER();
8249
8250 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -07008251 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07008252
8253 if (params->ie_len && ( NULL != params->ie) )
8254 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07008255 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
8256 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 {
8258 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
8259 encryptionType = eCSR_ENCRYPT_TYPE_AES;
8260 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07008261 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07008262 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008263 tDot11fIEWPA dot11WPAIE;
8264 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07008265 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008266
Wilson Yang00256342013-10-10 23:13:38 -07008267 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07008268 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
8269 params->ie_len, DOT11F_EID_WPA);
8270 if ( NULL != ie )
8271 {
8272 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
8273 // Unpack the WPA IE
8274 //Skip past the EID byte and length byte - and four byte WiFi OUI
8275 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
8276 &ie[2+4],
8277 ie[1] - 4,
8278 &dot11WPAIE);
8279 /*Extract the multicast cipher, the encType for unicast
8280 cipher for wpa-none is none*/
8281 encryptionType =
8282 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
8283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008284 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07008285
Jeff Johnson295189b2012-06-20 16:38:30 -07008286 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
8287
8288 if (0 > status)
8289 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308290 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07008291 __func__);
8292 return status;
8293 }
8294 }
8295
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308296 pWextState->roamProfile.AuthType.authType[0] =
8297 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 eCSR_AUTH_TYPE_OPEN_SYSTEM;
8299
8300 if (params->privacy)
8301 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308302 /* Security enabled IBSS, At this time there is no information available
8303 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07008304 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308305 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308307 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 *enable privacy bit in beacons */
8309
8310 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8311 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008312 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
8313 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07008314 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
8315 pWextState->roamProfile.EncryptionType.numEntries = 1;
8316 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07008317 return status;
8318}
8319
8320/*
8321 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308322 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07008323 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308324static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 struct net_device *dev,
8326 struct cfg80211_ibss_params *params
8327 )
8328{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308329 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8331 tCsrRoamProfile *pRoamProfile;
8332 int status;
krunal sonie9002db2013-11-25 14:24:17 -08008333 bool alloc_bssid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308335 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07008336
8337 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308338
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308339 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8340 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
8341 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308342 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308343 "%s: device_mode = %s (%d)", __func__,
8344 hdd_device_modetoString(pAdapter->device_mode),
8345 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008346
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308347 status = wlan_hdd_validate_context(pHddCtx);
8348
8349 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308351 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8352 "%s: HDD context is not valid", __func__);
8353 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008354 }
8355
8356 if (NULL == pWextState)
8357 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008358 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -07008359 __func__);
8360 return -EIO;
8361 }
8362
Vinay Krishna Eranna21042322014-01-08 19:21:39 +05308363 /*Try disconnecting if already in connected state*/
8364 status = wlan_hdd_try_disconnect(pAdapter);
8365 if ( 0 > status)
8366 {
8367 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
8368 " IBSS connection"));
8369 return -EALREADY;
8370 }
8371
Jeff Johnson295189b2012-06-20 16:38:30 -07008372 pRoamProfile = &pWextState->roamProfile;
8373
8374 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
8375 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308376 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008377 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07008378 return -EINVAL;
8379 }
8380
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07008381 /* BSSID is provided by upper layers hence no need to AUTO generate */
8382 if (NULL != params->bssid) {
8383 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
8384 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
8385 hddLog (VOS_TRACE_LEVEL_ERROR,
8386 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
8387 return -EIO;
8388 }
8389 }
krunal sonie9002db2013-11-25 14:24:17 -08008390 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
8391 {
8392 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
8393 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
8394 {
8395 hddLog (VOS_TRACE_LEVEL_ERROR,
8396 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
8397 return -EIO;
8398 }
8399 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
8400 if (!params->bssid)
8401 {
8402 hddLog (VOS_TRACE_LEVEL_ERROR,
8403 "%s:Failed memory allocation", __func__);
8404 return -EIO;
8405 }
8406 vos_mem_copy((v_U8_t *)params->bssid,
8407 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
8408 VOS_MAC_ADDR_SIZE);
8409 alloc_bssid = VOS_TRUE;
8410 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07008411
Jeff Johnson295189b2012-06-20 16:38:30 -07008412 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07008413 if (NULL !=
8414#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
8415 params->chandef.chan)
8416#else
8417 params->channel)
8418#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 {
8420 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008421 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
8422 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
8423 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8424 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008425
8426 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308427 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07008428 ieee80211_frequency_to_channel(
8429#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
8430 params->chandef.chan->center_freq);
8431#else
8432 params->channel->center_freq);
8433#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008434
8435 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
8436 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008438 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
8439 __func__);
8440 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07008441 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008442
8443 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008445 if (channelNum == validChan[indx])
8446 {
8447 break;
8448 }
8449 }
8450 if (indx >= numChans)
8451 {
8452 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008453 __func__, channelNum);
8454 return -EINVAL;
8455 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008456 /* Set the Operational Channel */
8457 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
8458 channelNum);
8459 pRoamProfile->ChannelInfo.numOfChannels = 1;
8460 pHddStaCtx->conn_info.operationChannel = channelNum;
8461 pRoamProfile->ChannelInfo.ChannelList =
8462 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07008463 }
8464
8465 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308466 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07008467 if (status < 0)
8468 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308469 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 __func__);
8471 return status;
8472 }
8473
8474 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308475 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07008476 params->ssid_len, params->bssid,
8477 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07008478
8479 if (0 > status)
8480 {
8481 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
8482 return status;
8483 }
8484
krunal sonie9002db2013-11-25 14:24:17 -08008485 if (NULL != params->bssid &&
8486 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
8487 alloc_bssid == VOS_TRUE)
8488 {
8489 vos_mem_free(params->bssid);
8490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008491 return 0;
8492}
8493
8494/*
8495 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308496 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07008497 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308498static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008499 struct net_device *dev
8500 )
8501{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308502 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008503 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
8504 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308505 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8506 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008507
8508 ENTER();
8509
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308510 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8511 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
8512 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308513 status = wlan_hdd_validate_context(pHddCtx);
8514
8515 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008516 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308517 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8518 "%s: HDD context is not valid", __func__);
8519 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008520 }
8521
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308522 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
8523 hdd_device_modetoString(pAdapter->device_mode),
8524 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008525 if (NULL == pWextState)
8526 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08008527 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 __func__);
8529 return -EIO;
8530 }
8531
8532 pRoamProfile = &pWextState->roamProfile;
8533
8534 /* Issue disconnect only if interface type is set to IBSS */
8535 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
8536 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308537 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07008538 __func__);
8539 return -EINVAL;
8540 }
8541
8542 /* Issue Disconnect request */
8543 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8544 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
8545 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
8546
8547 return 0;
8548}
8549
8550/*
8551 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
8552 * This function is used to set the phy parameters
8553 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
8554 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308555static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008556 u32 changed)
8557{
8558 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8559 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308560 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008561
8562 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308563 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8564 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
8565 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308566 status = wlan_hdd_validate_context(pHddCtx);
8567
8568 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008569 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308570 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8571 "%s: HDD context is not valid", __func__);
8572 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008573 }
8574
Jeff Johnson295189b2012-06-20 16:38:30 -07008575 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
8576 {
8577 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
8578 WNI_CFG_RTS_THRESHOLD_STAMAX :
8579 wiphy->rts_threshold;
8580
8581 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308582 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07008583 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308584 hddLog(VOS_TRACE_LEVEL_ERROR,
8585 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008586 __func__, rts_threshold);
8587 return -EINVAL;
8588 }
8589
8590 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
8591 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308592 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008593 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308594 hddLog(VOS_TRACE_LEVEL_ERROR,
8595 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008596 __func__, rts_threshold);
8597 return -EIO;
8598 }
8599
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308600 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008601 rts_threshold);
8602 }
8603
8604 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
8605 {
8606 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
8607 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
8608 wiphy->frag_threshold;
8609
8610 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308611 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008612 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308613 hddLog(VOS_TRACE_LEVEL_ERROR,
8614 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008615 frag_threshold);
8616 return -EINVAL;
8617 }
8618
8619 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
8620 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308621 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008622 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308623 hddLog(VOS_TRACE_LEVEL_ERROR,
8624 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008625 __func__, frag_threshold);
8626 return -EIO;
8627 }
8628
8629 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
8630 frag_threshold);
8631 }
8632
8633 if ((changed & WIPHY_PARAM_RETRY_SHORT)
8634 || (changed & WIPHY_PARAM_RETRY_LONG))
8635 {
8636 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
8637 wiphy->retry_short :
8638 wiphy->retry_long;
8639
8640 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
8641 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
8642 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308643 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008644 __func__, retry_value);
8645 return -EINVAL;
8646 }
8647
8648 if (changed & WIPHY_PARAM_RETRY_SHORT)
8649 {
8650 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
8651 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308652 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308654 hddLog(VOS_TRACE_LEVEL_ERROR,
8655 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008656 __func__, retry_value);
8657 return -EIO;
8658 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308659 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 __func__, retry_value);
8661 }
8662 else if (changed & WIPHY_PARAM_RETRY_SHORT)
8663 {
8664 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
8665 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308666 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008667 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308668 hddLog(VOS_TRACE_LEVEL_ERROR,
8669 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 __func__, retry_value);
8671 return -EIO;
8672 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308673 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07008674 __func__, retry_value);
8675 }
8676 }
8677
8678 return 0;
8679}
8680
8681/*
8682 * FUNCTION: wlan_hdd_cfg80211_set_txpower
8683 * This function is used to set the txpower
8684 */
8685static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07008686#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
8687 struct wireless_dev *wdev,
8688#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008689#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308690 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07008691#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308692 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07008693#endif
8694 int dbm)
8695{
8696 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308697 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008698 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
8699 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308700 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008701
8702 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308703 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8704 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
8705 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308706 status = wlan_hdd_validate_context(pHddCtx);
8707
8708 if (0 != status)
8709 {
8710 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8711 "%s: HDD context is not valid", __func__);
8712 return status;
8713 }
8714
8715 hHal = pHddCtx->hHal;
8716
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308717 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
8718 dbm, ccmCfgSetCallback,
8719 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07008720 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308721 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07008722 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
8723 return -EIO;
8724 }
8725
8726 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
8727 dbm);
8728
8729 switch(type)
8730 {
8731 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
8732 /* Fall through */
8733 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
8734 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
8735 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308736 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
8737 __func__);
8738 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008739 }
8740 break;
8741 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308742 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07008743 __func__);
8744 return -EOPNOTSUPP;
8745 break;
8746 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308747 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
8748 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07008749 return -EIO;
8750 }
8751
8752 return 0;
8753}
8754
8755/*
8756 * FUNCTION: wlan_hdd_cfg80211_get_txpower
8757 * This function is used to read the txpower
8758 */
Yue Maf49ba872013-08-19 12:04:25 -07008759static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
8760#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
8761 struct wireless_dev *wdev,
8762#endif
8763 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07008764{
8765
8766 hdd_adapter_t *pAdapter;
8767 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308768 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008769
Jeff Johnsone7245742012-09-05 17:12:55 -07008770 ENTER();
8771
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308772 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008773
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308774 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008775 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308776 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8777 "%s: HDD context is not valid", __func__);
8778 *dbm = 0;
8779 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008780 }
8781
Jeff Johnson295189b2012-06-20 16:38:30 -07008782 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
8783 if (NULL == pAdapter)
8784 {
8785 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
8786 return -ENOENT;
8787 }
8788
8789 wlan_hdd_get_classAstats(pAdapter);
8790 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
8791
Jeff Johnsone7245742012-09-05 17:12:55 -07008792 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008793 return 0;
8794}
8795
8796static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
8797 u8* mac, struct station_info *sinfo)
8798{
8799 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
8800 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8801 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +05308802 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07008803
8804 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
8805 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008806
8807 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
8808 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
8809 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
8810 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
8811 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
8812 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
8813 tANI_U16 maxRate = 0;
8814 tANI_U16 myRate;
8815 tANI_U16 currentRate = 0;
8816 tANI_U8 maxSpeedMCS = 0;
8817 tANI_U8 maxMCSIdx = 0;
8818 tANI_U8 rateFlag = 1;
8819 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07008820 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308821 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07008822
Leo Chang6f8870f2013-03-26 18:11:36 -07008823#ifdef WLAN_FEATURE_11AC
8824 tANI_U32 vht_mcs_map;
8825 eDataRate11ACMaxMcs vhtMaxMcs;
8826#endif /* WLAN_FEATURE_11AC */
8827
Jeff Johnsone7245742012-09-05 17:12:55 -07008828 ENTER();
8829
Jeff Johnson295189b2012-06-20 16:38:30 -07008830 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
8831 (0 == ssidlen))
8832 {
8833 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
8834 " Invalid ssidlen, %d", __func__, ssidlen);
8835 /*To keep GUI happy*/
8836 return 0;
8837 }
8838
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308839 status = wlan_hdd_validate_context(pHddCtx);
8840
8841 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008842 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8844 "%s: HDD context is not valid", __func__);
8845 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008846 }
8847
Jeff Johnson295189b2012-06-20 16:38:30 -07008848
Kiet Lam3b17fc82013-09-27 05:24:08 +05308849 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
8850 sinfo->filled |= STATION_INFO_SIGNAL;
8851
c_hpothu09f19542014-05-30 21:53:31 +05308852 wlan_hdd_get_station_stats(pAdapter);
8853 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
8854
8855 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +05308856 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
8857 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
8858 sinfo->signal >= pCfg->linkSpeedRssiHigh))
8859 {
8860 rate_flags = pAdapter->maxRateFlags;
8861 }
c_hpothu44ff4e02014-05-08 00:13:57 +05308862
Jeff Johnson295189b2012-06-20 16:38:30 -07008863 //convert to the UI units of 100kbps
8864 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
8865
8866#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07008867 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 -07008868 sinfo->signal,
8869 pCfg->reportMaxLinkSpeed,
8870 myRate,
8871 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07008872 (int) pCfg->linkSpeedRssiMid,
8873 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07008874 (int) rate_flags,
8875 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07008876#endif //LINKSPEED_DEBUG_ENABLED
8877
8878 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
8879 {
8880 // we do not want to necessarily report the current speed
8881 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
8882 {
8883 // report the max possible speed
8884 rssidx = 0;
8885 }
8886 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
8887 {
8888 // report the max possible speed with RSSI scaling
8889 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
8890 {
8891 // report the max possible speed
8892 rssidx = 0;
8893 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07008894 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07008895 {
8896 // report middle speed
8897 rssidx = 1;
8898 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07008899 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
8900 {
8901 // report middle speed
8902 rssidx = 2;
8903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008904 else
8905 {
8906 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07008907 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07008908 }
8909 }
8910 else
8911 {
8912 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
8913 hddLog(VOS_TRACE_LEVEL_ERROR,
8914 "%s: Invalid value for reportMaxLinkSpeed: %u",
8915 __func__, pCfg->reportMaxLinkSpeed);
8916 rssidx = 0;
8917 }
8918
8919 maxRate = 0;
8920
8921 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05308922 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
8923 OperationalRates, &ORLeng))
8924 {
8925 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
8926 /*To keep GUI happy*/
8927 return 0;
8928 }
8929
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 for (i = 0; i < ORLeng; i++)
8931 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008932 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008933 {
8934 /* Validate Rate Set */
8935 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
8936 {
8937 currentRate = supported_data_rate[j].supported_rate[rssidx];
8938 break;
8939 }
8940 }
8941 /* Update MAX rate */
8942 maxRate = (currentRate > maxRate)?currentRate:maxRate;
8943 }
8944
8945 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05308946 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
8947 ExtendedRates, &ERLeng))
8948 {
8949 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
8950 /*To keep GUI happy*/
8951 return 0;
8952 }
8953
Jeff Johnson295189b2012-06-20 16:38:30 -07008954 for (i = 0; i < ERLeng; i++)
8955 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008956 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07008957 {
8958 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
8959 {
8960 currentRate = supported_data_rate[j].supported_rate[rssidx];
8961 break;
8962 }
8963 }
8964 /* Update MAX rate */
8965 maxRate = (currentRate > maxRate)?currentRate:maxRate;
8966 }
Kiet Lamb69f8dc2013-11-15 15:34:27 +05308967 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +05308968 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +05308969 if we have good rssi */
Kaushik, Sushantdc304d82014-01-22 10:58:37 +05308970 if ((0 == rssidx) ||
Kiet Lamb69f8dc2013-11-15 15:34:27 +05308971 (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed))
Jeff Johnson295189b2012-06-20 16:38:30 -07008972 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05308973 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
8974 MCSRates, &MCSLeng))
8975 {
8976 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
8977 /*To keep GUI happy*/
8978 return 0;
8979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008980 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07008981#ifdef WLAN_FEATURE_11AC
8982 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05308983 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07008984 {
Leo Chang6f8870f2013-03-26 18:11:36 -07008985 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05308986 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07008987 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07008988 {
Leo Chang6f8870f2013-03-26 18:11:36 -07008989 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008990 }
Leo Chang6f8870f2013-03-26 18:11:36 -07008991 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07008992 {
Leo Chang6f8870f2013-03-26 18:11:36 -07008993 maxMCSIdx = 7;
8994 }
8995 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
8996 {
8997 maxMCSIdx = 8;
8998 }
8999 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
9000 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309001 //VHT20 is supporting 0~8
9002 if (rate_flags & eHAL_TX_RATE_VHT20)
9003 maxMCSIdx = 8;
9004 else
9005 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07009006 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309007
9008 if (rate_flags & eHAL_TX_RATE_VHT80)
9009 {
9010 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
9011 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
9012 }
9013 else if (rate_flags & eHAL_TX_RATE_VHT40)
9014 {
9015 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
9016 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
9017 }
9018 else if (rate_flags & eHAL_TX_RATE_VHT20)
9019 {
9020 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
9021 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
9022 }
9023
Leo Chang6f8870f2013-03-26 18:11:36 -07009024 maxSpeedMCS = 1;
9025 if (currentRate > maxRate)
9026 {
9027 maxRate = currentRate;
9028 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309029
Leo Chang6f8870f2013-03-26 18:11:36 -07009030 }
9031 else
9032#endif /* WLAN_FEATURE_11AC */
9033 {
9034 if (rate_flags & eHAL_TX_RATE_HT40)
9035 {
9036 rateFlag |= 1;
9037 }
9038 if (rate_flags & eHAL_TX_RATE_SGI)
9039 {
9040 rateFlag |= 2;
9041 }
9042
9043 for (i = 0; i < MCSLeng; i++)
9044 {
9045 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
9046 for (j = 0; j < temp; j++)
9047 {
9048 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
9049 {
9050 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
9051 break;
9052 }
9053 }
9054 if ((j < temp) && (currentRate > maxRate))
9055 {
9056 maxRate = currentRate;
9057 maxSpeedMCS = 1;
9058 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
9059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009060 }
9061 }
9062 }
9063
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309064 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
9065 {
9066 maxRate = myRate;
9067 maxSpeedMCS = 1;
9068 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
9069 }
9070
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07009072 if (((maxRate < myRate) && (0 == rssidx)) ||
9073 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07009074 {
9075 maxRate = myRate;
9076 if (rate_flags & eHAL_TX_RATE_LEGACY)
9077 {
9078 maxSpeedMCS = 0;
9079 }
9080 else
9081 {
9082 maxSpeedMCS = 1;
9083 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
9084 }
9085 }
9086
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309087 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07009088 {
9089 sinfo->txrate.legacy = maxRate;
9090#ifdef LINKSPEED_DEBUG_ENABLED
9091 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
9092#endif //LINKSPEED_DEBUG_ENABLED
9093 }
9094 else
9095 {
9096 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07009097#ifdef WLAN_FEATURE_11AC
9098 sinfo->txrate.nss = 1;
9099 if (rate_flags & eHAL_TX_RATE_VHT80)
9100 {
9101 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309102 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07009103 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309104 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07009105 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309106 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
9107 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
9108 }
9109 else if (rate_flags & eHAL_TX_RATE_VHT20)
9110 {
9111 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
9112 }
9113#endif /* WLAN_FEATURE_11AC */
9114 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
9115 {
9116 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
9117 if (rate_flags & eHAL_TX_RATE_HT40)
9118 {
9119 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
9120 }
Leo Chang6f8870f2013-03-26 18:11:36 -07009121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009122 if (rate_flags & eHAL_TX_RATE_SGI)
9123 {
9124 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
9125 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05309126
Jeff Johnson295189b2012-06-20 16:38:30 -07009127#ifdef LINKSPEED_DEBUG_ENABLED
9128 pr_info("Reporting MCS rate %d flags %x\n",
9129 sinfo->txrate.mcs,
9130 sinfo->txrate.flags );
9131#endif //LINKSPEED_DEBUG_ENABLED
9132 }
9133 }
9134 else
9135 {
9136 // report current rate instead of max rate
9137
9138 if (rate_flags & eHAL_TX_RATE_LEGACY)
9139 {
9140 //provide to the UI in units of 100kbps
9141 sinfo->txrate.legacy = myRate;
9142#ifdef LINKSPEED_DEBUG_ENABLED
9143 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
9144#endif //LINKSPEED_DEBUG_ENABLED
9145 }
9146 else
9147 {
9148 //must be MCS
9149 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07009150#ifdef WLAN_FEATURE_11AC
9151 sinfo->txrate.nss = 1;
9152 if (rate_flags & eHAL_TX_RATE_VHT80)
9153 {
9154 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
9155 }
9156 else
9157#endif /* WLAN_FEATURE_11AC */
9158 {
9159 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
9160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 if (rate_flags & eHAL_TX_RATE_SGI)
9162 {
9163 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
9164 }
9165 if (rate_flags & eHAL_TX_RATE_HT40)
9166 {
9167 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
9168 }
Leo Chang6f8870f2013-03-26 18:11:36 -07009169#ifdef WLAN_FEATURE_11AC
9170 else if (rate_flags & eHAL_TX_RATE_VHT80)
9171 {
9172 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
9173 }
9174#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07009175#ifdef LINKSPEED_DEBUG_ENABLED
9176 pr_info("Reporting actual MCS rate %d flags %x\n",
9177 sinfo->txrate.mcs,
9178 sinfo->txrate.flags );
9179#endif //LINKSPEED_DEBUG_ENABLED
9180 }
9181 }
9182 sinfo->filled |= STATION_INFO_TX_BITRATE;
9183
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07009184 sinfo->tx_packets =
9185 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
9186 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
9187 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
9188 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
9189
9190 sinfo->tx_retries =
9191 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
9192 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
9193 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
9194 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
9195
9196 sinfo->tx_failed =
9197 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
9198 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
9199 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
9200 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
9201
9202 sinfo->filled |=
9203 STATION_INFO_TX_PACKETS |
9204 STATION_INFO_TX_RETRIES |
9205 STATION_INFO_TX_FAILED;
9206
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309207 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9208 TRACE_CODE_HDD_CFG80211_GET_STA,
9209 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07009210 EXIT();
9211 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009212}
9213
9214static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07009215 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07009216{
9217 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05309218 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009219 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309220 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009221
Jeff Johnsone7245742012-09-05 17:12:55 -07009222 ENTER();
9223
Jeff Johnson295189b2012-06-20 16:38:30 -07009224 if (NULL == pAdapter)
9225 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009226 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 return -ENODEV;
9228 }
9229
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309230 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9231 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
9232 pAdapter->sessionId, timeout));
9233
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05309234 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309235 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05309236
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309237 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309238 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309239 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9240 "%s: HDD context is not valid", __func__);
9241 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309242 }
9243
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05309244 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
9245 (TRUE == pHddCtx->hdd_wlan_suspended) &&
9246 (pHddCtx->cfg_ini->fhostArpOffload) &&
9247 (eConnectionState_Associated ==
9248 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
9249 {
Amar Singhald53568e2013-09-26 11:03:45 -07009250
9251 hddLog(VOS_TRACE_LEVEL_INFO,
9252 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05309253 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05309254 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9255 {
9256 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009257 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05309258 __func__, vos_status);
9259 }
9260 }
9261
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 /**The get power cmd from the supplicant gets updated by the nl only
9263 *on successful execution of the function call
9264 *we are oppositely mapped w.r.t mode in the driver
9265 **/
9266 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
9267
Jeff Johnsone7245742012-09-05 17:12:55 -07009268 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009269 if (VOS_STATUS_E_FAILURE == vos_status)
9270 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309271 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9272 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009273 return -EINVAL;
9274 }
9275 return 0;
9276}
9277
9278
9279#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9280static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
9281 struct net_device *netdev,
9282 u8 key_index)
9283{
Jeff Johnsone7245742012-09-05 17:12:55 -07009284 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 return 0;
9286}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309287#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07009288
9289#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
9290static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
9291 struct net_device *dev,
9292 struct ieee80211_txq_params *params)
9293{
Jeff Johnsone7245742012-09-05 17:12:55 -07009294 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009295 return 0;
9296}
9297#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9298static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
9299 struct ieee80211_txq_params *params)
9300{
Jeff Johnsone7245742012-09-05 17:12:55 -07009301 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07009302 return 0;
9303}
9304#endif //LINUX_VERSION_CODE
9305
9306static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
9307 struct net_device *dev, u8 *mac)
9308{
9309 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309310 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009311 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309312 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009313 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009314
Jeff Johnsone7245742012-09-05 17:12:55 -07009315 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309316
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309317 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07009318 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309319 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009320 return -EINVAL;
9321 }
9322
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309323 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9324 TRACE_CODE_HDD_CFG80211_DEL_STA,
9325 pAdapter->sessionId, pAdapter->device_mode));
9326
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309327 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9328 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07009329
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309330 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009331 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309332 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9333 "%s: HDD context is not valid", __func__);
9334 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009335 }
9336
Jeff Johnson295189b2012-06-20 16:38:30 -07009337 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07009339 )
9340 {
9341 if( NULL == mac )
9342 {
9343 v_U16_t i;
9344 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
9345 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07009346 if ((pAdapter->aStaInfo[i].isUsed) &&
9347 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07009348 {
9349 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
9350 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08009351 "%s: Delete STA with MAC::"
9352 MAC_ADDRESS_STR,
9353 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07009354 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
9355 if (VOS_IS_STATUS_SUCCESS(vos_status))
9356 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009357 }
9358 }
9359 }
9360 else
9361 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009362
9363 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
9364 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9365 {
9366 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08009367 "%s: Skip this DEL STA as this is not used::"
9368 MAC_ADDRESS_STR,
9369 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009370 return -ENOENT;
9371 }
9372
9373 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
9374 {
9375 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08009376 "%s: Skip this DEL STA as deauth is in progress::"
9377 MAC_ADDRESS_STR,
9378 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009379 return -ENOENT;
9380 }
9381
9382 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
9383
Jeff Johnson295189b2012-06-20 16:38:30 -07009384 hddLog(VOS_TRACE_LEVEL_INFO,
9385 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -08009386 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009387 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08009388 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009389
9390 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
9391 if (!VOS_IS_STATUS_SUCCESS(vos_status))
9392 {
9393 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
9394 hddLog(VOS_TRACE_LEVEL_INFO,
9395 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -08009396 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009397 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08009398 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009399 return -ENOENT;
9400 }
9401
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 }
9403 }
9404
9405 EXIT();
9406
9407 return 0;
9408}
9409
Hoonki Lee11f7dda2013-02-14 16:55:44 -08009410static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
9411 struct net_device *dev, u8 *mac, struct station_parameters *params)
9412{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309413 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009414 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08009415#ifdef FEATURE_WLAN_TDLS
9416 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08009417 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309418
9419 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9420 TRACE_CODE_HDD_CFG80211_ADD_STA,
9421 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009422 mask = params->sta_flags_mask;
9423
9424 set = params->sta_flags_set;
9425
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07009426#ifdef WLAN_FEATURE_TDLS_DEBUG
9427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9428 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
9429 __func__, mask, set, MAC_ADDR_ARRAY(mac));
9430#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009431
9432 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
9433 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08009434 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009435 }
9436 }
9437#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08009438 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009439}
9440
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009441
9442#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07009443
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009444static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07009445 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009446{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309447 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009448 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309449 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009450 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309451 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309452 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009453 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309454 hdd_context_t *pHddCtx;
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009455 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
9456 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009457
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309458 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309459 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009460 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309461 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009462 return -EINVAL;
9463 }
9464
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309465 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9466 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009467
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309468 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009469 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309470 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9471 "%s: HDD context is not valid", __func__);
9472 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009473 }
9474
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309475 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009476 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309477 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009478
Agarwal Ashish3da95242014-05-21 14:57:17 +05309479 for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009480 {
Agarwal Ashish3da95242014-05-21 14:57:17 +05309481 if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009482 pmksa->bssid, WNI_CFG_BSSID_LEN))
9483 {
9484 /* BSSID matched previous entry. Overwrite it. */
9485 BSSIDMatched = 1;
Agarwal Ashish3da95242014-05-21 14:57:17 +05309486 vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009487 pmksa->bssid, WNI_CFG_BSSID_LEN);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309488 vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309489 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009490 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309491 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07009492 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009493 dump_bssid(pmksa->bssid);
9494 dump_pmkid(halHandle, pmksa->pmkid);
9495 break;
9496 }
9497 }
9498
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07009499 /* Check we compared all entries,if then take the first slot now */
Agarwal Ashish3da95242014-05-21 14:57:17 +05309500 if (j == MAX_PMKSAIDS_IN_CACHE) pHddStaCtx->PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07009501
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009502 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309503 {
9504 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Agarwal Ashish3da95242014-05-21 14:57:17 +05309505 vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309506 pmksa->bssid, ETHER_ADDR_LEN);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309507 vos_mem_copy(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309508 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009509 CSR_RSN_PMKID_SIZE);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309510 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Adding a new cache entry %d.",
9511 __func__, pHddStaCtx->PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009512 dump_bssid(pmksa->bssid);
9513 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309514 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009515 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Agarwal Ashish3da95242014-05-21 14:57:17 +05309516 if (pHddStaCtx->PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1))
9517 pHddStaCtx->PMKIDCacheIndex++;
9518 else
9519 pHddStaCtx->PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009520 }
9521
9522
9523 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Agarwal Ashish3da95242014-05-21 14:57:17 +05309524 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
9525 __func__, pHddStaCtx->PMKIDCacheIndex );
9526
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009527 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309528 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Agarwal Ashish3da95242014-05-21 14:57:17 +05309529 pHddStaCtx->PMKIDCache,
9530 pHddStaCtx->PMKIDCacheIndex);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309531 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9532 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
9533 pAdapter->sessionId, result));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009534 return 0;
9535}
9536
9537
Wilson Yang6507c4e2013-10-01 20:11:19 -07009538
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009539static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07009540 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009541{
Wilson Yang6507c4e2013-10-01 20:11:19 -07009542 tANI_U32 j=0;
9543 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309544 hdd_station_ctx_t *pHddStaCtx;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009545 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009546 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009547 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -08009548 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009549
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009550 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
9551 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07009552
9553 /* Validate pAdapter */
9554 if (NULL == pAdapter)
9555 {
9556 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
9557 return -EINVAL;
9558 }
9559
9560 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9561 status = wlan_hdd_validate_context(pHddCtx);
9562
9563 if (0 != status)
9564 {
9565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9566 "%s: HDD context is not valid", __func__);
9567 return status;
9568 }
9569
9570 /*Retrieve halHandle*/
9571 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309572 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Wilson Yang6507c4e2013-10-01 20:11:19 -07009573
9574 /*in case index is 0,no entry to delete*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05309575 if (0 == pHddStaCtx->PMKIDCacheIndex)
Wilson Yang6507c4e2013-10-01 20:11:19 -07009576 {
Agarwal Ashish3da95242014-05-21 14:57:17 +05309577 hddLog(VOS_TRACE_LEVEL_INFO, FL("No entries to flush"));
9578 return 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009579 }
9580
9581 /*find the matching PMKSA entry from j=0 to (index-1),
9582 * and delete the matched one
9583 */
Agarwal Ashish3da95242014-05-21 14:57:17 +05309584 for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
Wilson Yang6507c4e2013-10-01 20:11:19 -07009585 {
Agarwal Ashish3da95242014-05-21 14:57:17 +05309586 if (vos_mem_compare(pHddStaCtx->PMKIDCache[j].BSSID,
Wilson Yang6507c4e2013-10-01 20:11:19 -07009587 pmksa->bssid,
9588 WNI_CFG_BSSID_LEN))
9589 {
9590 /* BSSID matched entry */
9591 BSSIDMatched = 1;
Agarwal Ashish3da95242014-05-21 14:57:17 +05309592 if (j < pHddStaCtx->PMKIDCacheIndex-1)
Wilson Yang6507c4e2013-10-01 20:11:19 -07009593 {
9594 /*replace the matching entry with the last entry in HDD local cache*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05309595 vos_mem_copy(pHddStaCtx->PMKIDCache[j].BSSID,
9596 pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID,
9597 VOS_MAC_ADDR_SIZE);
9598 vos_mem_copy(pHddStaCtx->PMKIDCache[j].PMKID,
9599 pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID,
9600 CSR_RSN_PMKID_SIZE);
9601 }
Wilson Yang6507c4e2013-10-01 20:11:19 -07009602
9603 /*clear the last entry in HDD cache ---[index-1]*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05309604 vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].BSSID,
9605 VOS_MAC_ADDR_SIZE);
9606 vos_mem_zero(pHddStaCtx->PMKIDCache[pHddStaCtx->PMKIDCacheIndex-1].PMKID,
9607 CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -07009608 /*reduce the PMKID array index*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05309609 pHddStaCtx->PMKIDCacheIndex--;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009610 /*delete the last PMKID cache in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -08009611 if (eHAL_STATUS_SUCCESS !=
9612 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid))
Wilson Yang6507c4e2013-10-01 20:11:19 -07009613 {
9614 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
Agarwal Ashish3da95242014-05-21 14:57:17 +05309615 __func__, pHddStaCtx->PMKIDCacheIndex);
Wilson Yangef657d32014-01-15 19:19:23 -08009616 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009617 }
9618
9619 dump_bssid(pmksa->bssid);
9620 dump_pmkid(halHandle,pmksa->pmkid);
9621
9622 break;
9623 }
9624 }
9625
9626 /* we compare all entries,but cannot find matching entry */
9627 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
9628 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07009629 hddLog(VOS_TRACE_LEVEL_FATAL,
9630 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
9631 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07009632 dump_bssid(pmksa->bssid);
9633 dump_pmkid(halHandle, pmksa->pmkid);
9634 return -EINVAL;
9635 }
Wilson Yangef657d32014-01-15 19:19:23 -08009636 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009637}
9638
Wilson Yang6507c4e2013-10-01 20:11:19 -07009639
9640
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009641static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
9642{
Wilson Yang6507c4e2013-10-01 20:11:19 -07009643 tANI_U32 j=0;
9644 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309645 hdd_station_ctx_t *pHddStaCtx;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009646 tHalHandle halHandle;
9647 hdd_context_t *pHddCtx;
9648 tANI_U8 *pBSSId;
Wilson Yangef657d32014-01-15 19:19:23 -08009649 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009650
9651 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
9652
9653 /* Validate pAdapter */
9654 if (NULL == pAdapter)
9655 {
9656 hddLog(VOS_TRACE_LEVEL_ERROR,
9657 "%s: Invalid Adapter" ,__func__);
9658 return -EINVAL;
9659 }
9660
9661 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9662 status = wlan_hdd_validate_context(pHddCtx);
9663
9664 if (0 != status)
9665 {
9666 hddLog(VOS_TRACE_LEVEL_ERROR,
9667 "%s: HDD context is not valid", __func__);
9668 return status;
9669 }
9670
9671 /*Retrieve halHandle*/
9672 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Agarwal Ashish3da95242014-05-21 14:57:17 +05309673 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Wilson Yang6507c4e2013-10-01 20:11:19 -07009674
9675 /*in case index is 0,no entry to delete*/
Agarwal Ashish3da95242014-05-21 14:57:17 +05309676 if (0 == pHddStaCtx->PMKIDCacheIndex)
Wilson Yang6507c4e2013-10-01 20:11:19 -07009677 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05309678 hddLog(VOS_TRACE_LEVEL_ERROR, FL("No entries to flush"));
Agarwal Ashish3da95242014-05-21 14:57:17 +05309679 return 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009680 }
9681
9682 /*delete all the PMKSA one by one */
Agarwal Ashish3da95242014-05-21 14:57:17 +05309683 for (j = 0; j < pHddStaCtx->PMKIDCacheIndex; j++)
Wilson Yang6507c4e2013-10-01 20:11:19 -07009684 {
Agarwal Ashish3da95242014-05-21 14:57:17 +05309685 pBSSId =(tANI_U8 *)(pHddStaCtx->PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -07009686 /*delete the PMKID in CSR*/
Wilson Yangef657d32014-01-15 19:19:23 -08009687 if (eHAL_STATUS_SUCCESS !=
9688 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId))
Wilson Yang6507c4e2013-10-01 20:11:19 -07009689 {
9690 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
9691 __func__,j);
Wilson Yangef657d32014-01-15 19:19:23 -08009692 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -07009693 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +05309694 /*clear the entry in HDD cache 0--index-1 */
Agarwal Ashish3da95242014-05-21 14:57:17 +05309695 vos_mem_zero(pHddStaCtx->PMKIDCache[j].BSSID, VOS_MAC_ADDR_SIZE);
9696 vos_mem_zero(pHddStaCtx->PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
9697 }
Wilson Yang6507c4e2013-10-01 20:11:19 -07009698
Agarwal Ashish3da95242014-05-21 14:57:17 +05309699 pHddStaCtx->PMKIDCacheIndex = 0;
Wilson Yangef657d32014-01-15 19:19:23 -08009700 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009701}
9702#endif
9703
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009704#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309705static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009706 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
9707{
9708 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9709 hdd_station_ctx_t *pHddStaCtx;
9710
9711 if (NULL == pAdapter)
9712 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009713 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009714 return -ENODEV;
9715 }
9716
9717 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9718
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309719 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9720 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
9721 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009722 // Added for debug on reception of Re-assoc Req.
9723 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
9724 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009725 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009726 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -08009727 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009728 }
9729
9730#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -08009731 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009732 ftie->ie_len);
9733#endif
9734
9735 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05309736 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
9737 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009738 ftie->ie_len);
9739 return 0;
9740}
9741#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009742
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309743#ifdef FEATURE_WLAN_SCAN_PNO
9744
9745void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
9746 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
9747{
9748 int ret;
9749 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
9750 hdd_context_t *pHddCtx;
9751
Nirav Shah80830bf2013-12-31 16:35:12 +05309752 ENTER();
9753
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309754 if (NULL == pAdapter)
9755 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05309756 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309757 "%s: HDD adapter is Null", __func__);
9758 return ;
9759 }
9760
9761 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9762 if (NULL == pHddCtx)
9763 {
9764 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9765 "%s: HDD context is Null!!!", __func__);
9766 return ;
9767 }
9768
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309769 spin_lock(&pHddCtx->schedScan_lock);
9770 if (TRUE == pHddCtx->isWiphySuspended)
9771 {
9772 pHddCtx->isSchedScanUpdatePending = TRUE;
9773 spin_unlock(&pHddCtx->schedScan_lock);
9774 hddLog(VOS_TRACE_LEVEL_INFO,
9775 "%s: Update cfg80211 scan database after it resume", __func__);
9776 return ;
9777 }
9778 spin_unlock(&pHddCtx->schedScan_lock);
9779
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309780 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
9781
9782 if (0 > ret)
9783 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
9784
9785 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9787 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309788}
9789
9790/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309791 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05309792 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309793 */
9794static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
9795{
9796 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
9797 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05309798 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309799 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9800 int status = 0;
9801 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
9802
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05309803 /* The current firmware design does not allow PNO during any
9804 * active sessions. Hence, determine the active sessions
9805 * and return a failure.
9806 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309807 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
9808 {
9809 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05309810 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309811
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05309812 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
9813 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
9814 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
9815 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
9816 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
9817 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309818 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05309819 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309820 }
9821 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9822 pAdapterNode = pNext;
9823 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05309824 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309825}
9826
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +05309827void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
9828{
9829 hdd_adapter_t *pAdapter = callbackContext;
9830 hdd_context_t *pHddCtx;
9831
9832 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
9833 {
9834 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9835 FL("Invalid adapter or adapter has invalid magic"));
9836 return;
9837 }
9838
9839 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9840 if (0 != wlan_hdd_validate_context(pHddCtx))
9841 {
9842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9843 FL("HDD context is not valid"));
9844 return;
9845 }
9846
9847 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9848 FL("PNO enable response status = %d"), status);
9849
9850 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
9851 complete(&pAdapter->pno_comp_var);
9852}
9853
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309854/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +05309855 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
9856 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309857 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +05309858static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309859 struct net_device *dev, struct cfg80211_sched_scan_request *request)
9860{
9861 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
9862 tpSirPNOScanReq pPnoRequest = NULL;
9863 hdd_context_t *pHddCtx;
9864 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05309865 v_U32_t i, indx, num_ch, tempInterval;
Sushant Kaushikd62d9782014-02-19 15:39:40 +05309866 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
9867 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309868 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
9869 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05309870 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309871
9872 if (NULL == pAdapter)
9873 {
9874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9875 "%s: HDD adapter is Null", __func__);
9876 return -ENODEV;
9877 }
9878
9879 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309880 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309881
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309882 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309883 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309884 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9885 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05309886 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309887 }
9888
9889 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9890 if (NULL == hHal)
9891 {
9892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9893 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309894 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309895 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05309896
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05309897 ret = wlan_hdd_scan_abort(pAdapter);
9898 if (ret <= 0)
9899 {
9900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9901 "%s: aborting the existing scan is unsuccessfull", __func__);
9902 return -EBUSY;
9903 }
9904
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05309905 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309906 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +05309907 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +05309908 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +05309909 return -EBUSY;
9910 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309911
c_hpothu37f21312014-04-09 21:49:54 +05309912 if (TRUE == pHddCtx->isPnoEnable)
9913 {
9914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9915 FL("already PNO is enabled"));
9916 return -EBUSY;
9917 }
9918 pHddCtx->isPnoEnable = TRUE;
9919
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309920 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
9921 if (NULL == pPnoRequest)
9922 {
9923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9924 "%s: vos_mem_malloc failed", __func__);
c_hpothu37f21312014-04-09 21:49:54 +05309925 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05309926 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309927 }
9928
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05309929 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309930 pPnoRequest->enable = 1; /*Enable PNO */
9931 pPnoRequest->ucNetworksCount = request->n_match_sets;
9932
9933 if (( !pPnoRequest->ucNetworksCount ) ||
9934 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
9935 {
9936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +05309937 "%s: Network input is not correct %d Max Network supported is %d",
9938 __func__, pPnoRequest->ucNetworksCount,
9939 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05309940 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309941 goto error;
9942 }
9943
9944 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
9945 {
9946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05309947 "%s: Incorrect number of channels %d",
9948 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05309949 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309950 goto error;
9951 }
9952
9953 /* Framework provides one set of channels(all)
9954 * common for all saved profile */
9955 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
9956 channels_allowed, &num_channels_allowed))
9957 {
9958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9959 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05309960 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309961 goto error;
9962 }
9963 /* Checking each channel against allowed channel list */
9964 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +05309965 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309966 {
Nirav Shah80830bf2013-12-31 16:35:12 +05309967 char chList [(request->n_channels*5)+1];
9968 int len;
9969 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309970 {
Nirav Shah80830bf2013-12-31 16:35:12 +05309971 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309972 {
Nirav Shah80830bf2013-12-31 16:35:12 +05309973 if (request->channels[i]->hw_value == channels_allowed[indx])
9974 {
9975 valid_ch[num_ch++] = request->channels[i]->hw_value;
9976 len += snprintf(chList+len, 5, "%d ",
9977 request->channels[i]->hw_value);
9978 break ;
9979 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309980 }
9981 }
Nirav Shah80830bf2013-12-31 16:35:12 +05309982 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
9983 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309984
9985 /* Filling per profile params */
9986 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
9987 {
9988 pPnoRequest->aNetworks[i].ssId.length =
9989 request->match_sets[i].ssid.ssid_len;
9990
9991 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
9992 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
9993 {
9994 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +05309995 "%s: SSID Len %d is not correct for network %d",
9996 __func__, pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05309997 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309998 goto error;
9999 }
10000
10001 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
10002 request->match_sets[i].ssid.ssid,
10003 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053010004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10005 "%s: SSID of network %d is %s ", __func__,
10006 i, pPnoRequest->aNetworks[i].ssId.ssId);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010007 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
10008 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
10009 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
10010
10011 /*Copying list of valid channel into request */
10012 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
10013 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
10014
10015 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
10016 }
10017
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053010018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080010019 "request->ie_len = %zu", request->ie_len);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053010020 if ((0 < request->ie_len) && (NULL != request->ie))
10021 {
10022 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
10023 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
10024 pPnoRequest->us24GProbeTemplateLen);
10025
10026 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
10027 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
10028 pPnoRequest->us5GProbeTemplateLen);
10029 }
10030
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053010031 /* Driver gets only one time interval which is hardcoded in
10032 * supplicant for 10000ms. Taking power consumption into account 6 timers
10033 * will be used, Timervalue is increased exponentially i.e 10,20,40,
10034 * 80,160,320 secs. And number of scan cycle for each timer
10035 * is configurable through INI param gPNOScanTimerRepeatValue.
10036 * If it is set to 0 only one timer will be used and PNO scan cycle
10037 * will be repeated after each interval specified by supplicant
10038 * till PNO is disabled.
10039 */
10040 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
10041 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
10042 else
10043 pPnoRequest->scanTimers.ucScanTimersCount =
10044 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
10045
10046 tempInterval = (request->interval)/1000;
10047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10048 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
10049 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
10050 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
10051 {
10052 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
10053 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
10054 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
10055 tempInterval *= 2;
10056 }
10057 //Repeat last timer until pno disabled.
10058 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
10059
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +053010060 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010061
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010062 INIT_COMPLETION(pAdapter->pno_comp_var);
10063 pPnoRequest->statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
10064 pPnoRequest->callbackContext = pAdapter;
10065 pAdapter->pno_req_status = 0;
10066
Nirav Shah80830bf2013-12-31 16:35:12 +053010067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10068 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
10069 pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO,
10070 pPnoRequest->scanTimers.ucScanTimersCount);
10071
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010072 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
10073 pPnoRequest, pAdapter->sessionId,
10074 hdd_cfg80211_sched_scan_done_callback, pAdapter);
10075 if (eHAL_STATUS_SUCCESS != status)
10076 {
10077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053010078 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010079 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010080 goto error;
10081 }
10082
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010083 ret = wait_for_completion_timeout(
10084 &pAdapter->pno_comp_var,
10085 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
10086 if (0 >= ret)
10087 {
10088 // Did not receive the response for PNO enable in time.
10089 // Assuming the PNO enable was success.
10090 // Returning error from here, because we timeout, results
10091 // in side effect of Wifi (Wifi Setting) not to work.
10092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10093 FL("Timed out waiting for PNO to be Enabled"));
10094 ret = 0;
10095 goto error;
10096 }
10097
10098 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053010099 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010100
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010101error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10103 FL("PNO scanRequest offloaded ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010104 vos_mem_free(pPnoRequest);
c_hpothu37f21312014-04-09 21:49:54 +053010105 pHddCtx->isPnoEnable = FALSE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010106 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010107}
10108
10109/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053010110 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
10111 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010112 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053010113static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
10114 struct net_device *dev, struct cfg80211_sched_scan_request *request)
10115{
10116 int ret;
10117
10118 vos_ssr_protect(__func__);
10119 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
10120 vos_ssr_unprotect(__func__);
10121
10122 return ret;
10123}
10124
10125/*
10126 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
10127 * Function to disable PNO
10128 */
10129static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010130 struct net_device *dev)
10131{
10132 eHalStatus status = eHAL_STATUS_FAILURE;
10133 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10134 hdd_context_t *pHddCtx;
10135 tHalHandle hHal;
10136 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010137 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010138
10139 ENTER();
10140
10141 if (NULL == pAdapter)
10142 {
10143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10144 "%s: HDD adapter is Null", __func__);
10145 return -ENODEV;
10146 }
10147
10148 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010149
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010150 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010151 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053010152 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010153 "%s: HDD context is Null", __func__);
10154 return -ENODEV;
10155 }
10156
10157 /* The return 0 is intentional when isLogpInProgress and
10158 * isLoadUnloadInProgress. We did observe a crash due to a return of
10159 * failure in sched_scan_stop , especially for a case where the unload
10160 * of the happens at the same time. The function __cfg80211_stop_sched_scan
10161 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
10162 * success. If it returns a failure , then its next invocation due to the
10163 * clean up of the second interface will have the dev pointer corresponding
10164 * to the first one leading to a crash.
10165 */
10166 if (pHddCtx->isLogpInProgress)
10167 {
10168 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10169 "%s: LOGP in Progress. Ignore!!!", __func__);
10170 return ret;
10171 }
10172
Mihir Shete18156292014-03-11 15:38:30 +053010173 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010174 {
10175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10176 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
10177 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010178 }
10179
10180 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10181 if (NULL == hHal)
10182 {
10183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10184 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010185 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010186 }
10187
10188 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
10189 if (NULL == pPnoRequest)
10190 {
10191 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10192 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010193 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010194 }
10195
10196 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
10197 pPnoRequest->enable = 0; /* Disable PNO */
10198 pPnoRequest->ucNetworksCount = 0;
10199
10200 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
10201 pAdapter->sessionId,
10202 NULL, pAdapter);
10203 if (eHAL_STATUS_SUCCESS != status)
10204 {
10205 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10206 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010207 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010208 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010209 }
c_hpothu37f21312014-04-09 21:49:54 +053010210 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010211
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010212error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053010213 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053010214 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010215 vos_mem_free(pPnoRequest);
10216
10217 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053010218 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010219}
10220
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053010221/*
10222 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
10223 * NL interface to disable PNO
10224 */
10225static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
10226 struct net_device *dev)
10227{
10228 int ret;
10229
10230 vos_ssr_protect(__func__);
10231 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
10232 vos_ssr_unprotect(__func__);
10233
10234 return ret;
10235}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053010236#endif /*FEATURE_WLAN_SCAN_PNO*/
10237
10238
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010239#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053010240#if TDLS_MGMT_VERSION2
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010241static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
10242 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053010243 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
10244#else
10245static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
10246 u8 *peer, u8 action_code, u8 dialog_token,
10247 u16 status_code, const u8 *buf, size_t len)
10248#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010249{
10250
10251 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10252 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010253 u8 peerMac[6];
10254 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070010255 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080010256 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070010257 long rc;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053010258#if !(TDLS_MGMT_VERSION2)
10259 u32 peer_capability = 0;
10260#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010261 tANI_U16 numCurrTdlsPeers;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010262
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010263 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10264 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
10265 pAdapter->sessionId, action_code));
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010266 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010267 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010268 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010269 "Invalid arguments");
10270 return -EINVAL;
10271 }
10272
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010273 if (pHddCtx->isLogpInProgress)
10274 {
10275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10276 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010277 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010278 return -EBUSY;
10279 }
10280
Hoonki Lee27511902013-03-14 18:19:06 -070010281 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010282 {
Hoonki Lee27511902013-03-14 18:19:06 -070010283 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
10284 "%s: TDLS mode is disabled OR not enabled in FW."
10285 MAC_ADDRESS_STR " action %d declined.",
10286 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010287 return -ENOTSUPP;
10288 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080010289
Hoonki Lee27511902013-03-14 18:19:06 -070010290 /* other than teardown frame, other mgmt frames are not sent if disabled */
10291 if (SIR_MAC_TDLS_TEARDOWN != action_code)
10292 {
10293 /* if tdls_mode is disabled to respond to peer's request */
10294 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
10295 {
10296 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
10297 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010298 " TDLS mode is disabled. action %d declined.",
10299 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070010300
10301 return -ENOTSUPP;
10302 }
10303 }
10304
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010305 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
10306 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010307 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010308 {
10309 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010310 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010311 " TDLS setup is ongoing. action %d declined.",
10312 __func__, MAC_ADDR_ARRAY(peer), action_code);
10313 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010314 }
10315 }
10316
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010317 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
10318 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080010319 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010320 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
10321 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080010322 {
10323 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
10324 we return error code at 'add_station()'. Hence we have this
10325 check again in addtion to add_station().
10326 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010327 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080010328 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010329 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10330 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010331 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
10332 __func__, MAC_ADDR_ARRAY(peer), action_code,
10333 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053010334 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080010335 }
10336 else
10337 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010338 /* maximum reached. tweak to send error code to peer and return
10339 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080010340 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010341 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10342 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053010343 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
10344 __func__, MAC_ADDR_ARRAY(peer), status_code,
10345 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010346 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010347 /* fall through to send setup resp with failure status
10348 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080010349 }
10350 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010351 else
10352 {
10353 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010354 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010355 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010356 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010357 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070010358 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
10359 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010360 return -EPERM;
10361 }
10362 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080010363 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010364 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010365
Hoonki Lee1090c6a2013-01-16 17:40:54 -080010366#ifdef WLAN_FEATURE_TDLS_DEBUG
10367 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053010368 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010369 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
10370 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -080010371#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010372
Hoonki Leea34dd892013-02-05 22:56:02 -080010373 /*Except teardown responder will not be used so just make 0*/
10374 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080010375 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080010376 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070010377
10378 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053010379 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070010380
10381 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
10382 responder = pTdlsPeer->is_responder;
10383 else
Hoonki Leea34dd892013-02-05 22:56:02 -080010384 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070010385 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053010386 "%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 -070010387 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
10388 dialog_token, status_code, len);
10389 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080010390 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010391 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010392
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053010393 /* For explicit trigger of DIS_REQ come out of BMPS for
10394 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070010395 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053010396 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
10397 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070010398 {
10399 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
10400 {
10401 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053010402 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -070010403 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
10404 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053010405 if (SIR_MAC_TDLS_DIS_REQ != action_code)
10406 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -070010407 }
10408
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010409 /* make sure doesn't call send_mgmt() while it is pending */
10410 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
10411 {
10412 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010413 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010414 __func__, MAC_ADDR_ARRAY(peer), action_code);
10415 return -EBUSY;
10416 }
10417
10418 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010419 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
10420
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010421 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053010422 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010423
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010424 if (VOS_STATUS_SUCCESS != status)
10425 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10427 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010428 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -070010429 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053010430 return -EINVAL;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010431 }
10432
Hoonki Leed37cbb32013-04-20 00:31:14 -070010433 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
10434 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
10435
10436 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010437 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070010438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070010439 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070010440 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010441 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080010442
10443 if (pHddCtx->isLogpInProgress)
10444 {
10445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10446 "%s: LOGP in Progress. Ignore!!!", __func__);
10447 return -EAGAIN;
10448 }
10449
Hoonki Leed37cbb32013-04-20 00:31:14 -070010450 wlan_hdd_tdls_check_bmps(pAdapter);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053010451 return -EINVAL;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010452 }
10453
Gopichand Nakkala05922802013-03-14 12:23:19 -070010454 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070010455 {
10456 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -070010457 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070010458 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010459
Hoonki Leea34dd892013-02-05 22:56:02 -080010460 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
10461 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080010462 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -080010463 }
10464 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
10465 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080010466 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -080010467 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010468
10469 return 0;
10470}
10471
10472static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
10473 u8 *peer, enum nl80211_tdls_operation oper)
10474{
10475 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10476 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010477 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010478 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010479
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010480 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10481 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
10482 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010483 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010484 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080010485 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070010486 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010487 return -EINVAL;
10488 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080010489
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010490 status = wlan_hdd_validate_context(pHddCtx);
10491
10492 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010493 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010494 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10495 "%s: HDD context is not valid", __func__);
10496 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080010497 }
10498
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010499
10500 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080010501 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010502 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080010503 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070010504 "TDLS Disabled in INI OR not enabled in FW. "
10505 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010506 return -ENOTSUPP;
10507 }
10508
10509 switch (oper) {
10510 case NL80211_TDLS_ENABLE_LINK:
10511 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010512 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010513 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010514 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010515
Sunil Dutt41de4e22013-11-14 18:09:02 +053010516 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
10517
10518 if ( NULL == pTdlsPeer ) {
10519 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
10520 " (oper %d) not exsting. ignored",
10521 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
10522 return -EINVAL;
10523 }
10524
10525 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10526 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
10527 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
10528 "NL80211_TDLS_ENABLE_LINK");
10529
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070010530 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
10531 {
10532 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
10533 MAC_ADDRESS_STR " failed",
10534 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
10535 return -EINVAL;
10536 }
10537
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010538 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010539 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053010540 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053010541
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053010542 if (0 != wlan_hdd_tdls_get_link_establish_params(
10543 pAdapter, peer,&tdlsLinkEstablishParams)) {
10544 return -EINVAL;
10545 }
10546 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010547
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053010548 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
10549 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
10550 /* Send TDLS peer UAPSD capabilities to the firmware and
10551 * register with the TL on after the response for this operation
10552 * is received .
10553 */
10554 ret = wait_for_completion_interruptible_timeout(
10555 &pAdapter->tdls_link_establish_req_comp,
10556 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
10557 if (ret <= 0)
10558 {
10559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10560 "%s: Link Establish Request Faled Status %ld",
10561 __func__, ret);
10562 return -EINVAL;
10563 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010564 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070010565 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +053010566 /* Mark TDLS client Authenticated .*/
10567 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
10568 pTdlsPeer->staId,
10569 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070010570 if (VOS_STATUS_SUCCESS == status)
10571 {
Hoonki Lee14621352013-04-16 17:51:19 -070010572 if (pTdlsPeer->is_responder == 0)
10573 {
10574 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
10575
10576 wlan_hdd_tdls_timer_restart(pAdapter,
10577 &pTdlsPeer->initiatorWaitTimeoutTimer,
10578 WAIT_TIME_TDLS_INITIATOR);
10579 /* suspend initiator TX until it receives direct packet from the
10580 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
10581 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
10582 &staId, NULL);
10583 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070010584 wlan_hdd_tdls_increment_peer_count(pAdapter);
10585 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010586 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010587
10588 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010589 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
10590 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010591 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053010592 int ac;
10593 uint8 ucAc[4] = { WLANTL_AC_VO,
10594 WLANTL_AC_VI,
10595 WLANTL_AC_BK,
10596 WLANTL_AC_BE };
10597 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
10598 for(ac=0; ac < 4; ac++)
10599 {
10600 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
10601 pTdlsPeer->staId, ucAc[ac],
10602 tlTid[ac], tlTid[ac], 0, 0,
10603 WLANTL_BI_DIR );
10604 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053010605 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010606 }
10607
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010608 }
10609 break;
10610 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080010611 {
Sunil Dutt41de4e22013-11-14 18:09:02 +053010612 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
10613
10614 if ( NULL == pTdlsPeer ) {
10615 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
10616 " (oper %d) not exsting. ignored",
10617 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
10618 return -EINVAL;
10619 }
10620
10621 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10622 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
10623 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
10624 "NL80211_TDLS_DISABLE_LINK");
10625
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010626 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080010627 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010628 long status;
10629
10630 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
10631
Lee Hoonkic1262f22013-01-24 21:59:00 -080010632 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
10633 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010634
10635 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
10636 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
10637 if (status <= 0)
10638 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010639 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070010640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10641 "%s: Del station failed status %ld",
10642 __func__, status);
10643 return -EPERM;
10644 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -070010645 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -080010646 }
10647 else
10648 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010649 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10650 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080010651 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080010652 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070010653 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010654 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053010655 {
10656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10657 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
10658 __func__, MAC_ADDR_ARRAY(peer));
10659
10660 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
10661 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
10662
10663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10664 " %s TDLS External control and Implicit Trigger not enabled ",
10665 __func__);
10666 return -ENOTSUPP;
10667 }
10668
Sunil Dutt41de4e22013-11-14 18:09:02 +053010669
10670 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
10671
10672 if ( NULL == pTdlsPeer ) {
10673 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
10674 " peer not exsting",
10675 __func__, MAC_ADDR_ARRAY(peer));
Naresh Jayaram937abdf2013-11-26 19:50:25 +053010676 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +053010677 }
10678 else {
10679 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
10680 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
10681 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +053010682
10683 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) )
10684 return -EINVAL;
Sunil Dutt41de4e22013-11-14 18:09:02 +053010685 break;
10686 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010687 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053010688 {
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053010689 hddTdlsPeer_t *pTdlsPeer;
Sunil Dutt41de4e22013-11-14 18:09:02 +053010690 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10691 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
10692 __func__, MAC_ADDR_ARRAY(peer));
10693
10694 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
10695 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
10696
10697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10698 " %s TDLS External control and Implicit Trigger not enabled ",
10699 __func__);
10700 return -ENOTSUPP;
10701 }
10702
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053010703 /* To cater the requirement of establishing the TDLS link
10704 * irrespective of the data traffic , get an entry of TDLS peer.
10705 */
10706 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
10707 if (pTdlsPeer == NULL) {
10708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10709 "%s: peer " MAC_ADDRESS_STR " not existing",
10710 __func__, MAC_ADDR_ARRAY(peer));
10711 return -EINVAL;
10712 }
Naresh Jayaram937abdf2013-11-26 19:50:25 +053010713
10714 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
10715
10716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10717 " %s TDLS Add Force Peer Failed",
10718 __func__);
10719 return -EINVAL;
10720 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053010721 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053010722 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010723 case NL80211_TDLS_DISCOVERY_REQ:
10724 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
10726 "%s: We don't support in-driver setup/teardown/discovery "
10727 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010728 return -ENOTSUPP;
10729 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010730 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10731 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010732 return -ENOTSUPP;
10733 }
10734 return 0;
10735}
Chilam NG571c65a2013-01-19 12:27:36 +053010736
10737int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
10738 struct net_device *dev, u8 *peer)
10739{
Arif Hussaina7c8e412013-11-20 11:06:42 -080010740 hddLog(VOS_TRACE_LEVEL_INFO,
10741 "tdls send discover req: "MAC_ADDRESS_STR,
10742 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053010743
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053010744#if TDLS_MGMT_VERSION2
10745 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
10746 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
10747#else
Chilam NG571c65a2013-01-19 12:27:36 +053010748 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
10749 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053010750#endif
Chilam NG571c65a2013-01-19 12:27:36 +053010751}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080010752#endif
10753
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010754#ifdef WLAN_FEATURE_GTK_OFFLOAD
10755/*
10756 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
10757 * Callback rountine called upon receiving response for
10758 * get offload info
10759 */
10760void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
10761 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
10762{
10763
10764 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010765 tANI_U8 tempReplayCounter[8];
10766 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010767
10768 ENTER();
10769
10770 if (NULL == pAdapter)
10771 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053010772 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010773 "%s: HDD adapter is Null", __func__);
10774 return ;
10775 }
10776
10777 if (NULL == pGtkOffloadGetInfoRsp)
10778 {
10779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10780 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
10781 return ;
10782 }
10783
10784 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
10785 {
10786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10787 "%s: wlan Failed to get replay counter value",
10788 __func__);
10789 return ;
10790 }
10791
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010792 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10793 /* Update replay counter */
10794 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
10795 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
10796
10797 {
10798 /* changing from little to big endian since supplicant
10799 * works on big endian format
10800 */
10801 int i;
10802 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
10803
10804 for (i = 0; i < 8; i++)
10805 {
10806 tempReplayCounter[7-i] = (tANI_U8)p[i];
10807 }
10808 }
10809
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010810 /* Update replay counter to NL */
10811 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010812 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010813}
10814
10815/*
10816 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
10817 * This function is used to offload GTK rekeying job to the firmware.
10818 */
10819int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
10820 struct cfg80211_gtk_rekey_data *data)
10821{
10822 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10823 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
10824 hdd_station_ctx_t *pHddStaCtx;
10825 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010826 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010827 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010828 eHalStatus status = eHAL_STATUS_FAILURE;
10829
10830 ENTER();
10831
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010832
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010833 if (NULL == pAdapter)
10834 {
10835 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10836 "%s: HDD adapter is Null", __func__);
10837 return -ENODEV;
10838 }
10839
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053010840 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10841 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
10842 pAdapter->sessionId, pAdapter->device_mode));
10843
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010844 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010845
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010846 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010847 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010848 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10849 "%s: HDD context is not valid", __func__);
10850 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010851 }
10852
10853 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10854 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
10855 if (NULL == hHal)
10856 {
10857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10858 "%s: HAL context is Null!!!", __func__);
10859 return -EAGAIN;
10860 }
10861
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010862 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
10863 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
10864 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
10865 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010866 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010867 {
10868 /* changing from big to little endian since driver
10869 * works on little endian format
10870 */
10871 tANI_U8 *p =
10872 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
10873 int i;
10874
10875 for (i = 0; i < 8; i++)
10876 {
10877 p[7-i] = data->replay_ctr[i];
10878 }
10879 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010880
10881 if (TRUE == pHddCtx->hdd_wlan_suspended)
10882 {
10883 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010884 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
10885 sizeof (tSirGtkOffloadParams));
10886 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010887 pAdapter->sessionId);
10888
10889 if (eHAL_STATUS_SUCCESS != status)
10890 {
10891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10892 "%s: sme_SetGTKOffload failed, returned %d",
10893 __func__, status);
10894 return status;
10895 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10897 "%s: sme_SetGTKOffload successfull", __func__);
10898 }
10899 else
10900 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
10902 "%s: wlan not suspended GTKOffload request is stored",
10903 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010904 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053010905
10906 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053010907}
10908#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
10909
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053010910/*
10911 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
10912 * This function is used to set access control policy
10913 */
10914static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
10915 struct net_device *dev, const struct cfg80211_acl_data *params)
10916{
10917 int i;
10918 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
10919 hdd_hostapd_state_t *pHostapdState;
10920 tsap_Config_t *pConfig;
10921 v_CONTEXT_t pVosContext = NULL;
10922 hdd_context_t *pHddCtx;
10923 int status;
10924
10925 ENTER();
10926
10927 if (NULL == pAdapter)
10928 {
10929 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10930 "%s: HDD adapter is Null", __func__);
10931 return -ENODEV;
10932 }
10933
10934 if (NULL == params)
10935 {
10936 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10937 "%s: params is Null", __func__);
10938 return -EINVAL;
10939 }
10940
10941 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10942 status = wlan_hdd_validate_context(pHddCtx);
10943
10944 if (0 != status)
10945 {
10946 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10947 "%s: HDD context is not valid", __func__);
10948 return status;
10949 }
10950
10951 pVosContext = pHddCtx->pvosContext;
10952 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
10953
10954 if (NULL == pHostapdState)
10955 {
10956 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
10957 "%s: pHostapdState is Null", __func__);
10958 return -EINVAL;
10959 }
10960
10961 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
10962 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
10963
10964 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
10965 {
10966 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
10967
10968 /* default value */
10969 pConfig->num_accept_mac = 0;
10970 pConfig->num_deny_mac = 0;
10971
10972 /**
10973 * access control policy
10974 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
10975 * listed in hostapd.deny file.
10976 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
10977 * listed in hostapd.accept file.
10978 */
10979 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
10980 {
10981 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
10982 }
10983 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
10984 {
10985 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
10986 }
10987 else
10988 {
10989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10990 "%s:Acl Policy : %d is not supported",
10991 __func__, params->acl_policy);
10992 return -ENOTSUPP;
10993 }
10994
10995 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
10996 {
10997 pConfig->num_accept_mac = params->n_acl_entries;
10998 for (i = 0; i < params->n_acl_entries; i++)
10999 {
11000 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11001 "** Add ACL MAC entry %i in WhiletList :"
11002 MAC_ADDRESS_STR, i,
11003 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
11004
11005 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
11006 sizeof(qcmacaddr));
11007 }
11008 }
11009 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
11010 {
11011 pConfig->num_deny_mac = params->n_acl_entries;
11012 for (i = 0; i < params->n_acl_entries; i++)
11013 {
11014 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11015 "** Add ACL MAC entry %i in BlackList :"
11016 MAC_ADDRESS_STR, i,
11017 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
11018
11019 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
11020 sizeof(qcmacaddr));
11021 }
11022 }
11023
11024 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
11025 {
11026 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11027 "%s: SAP Set Mac Acl fail", __func__);
11028 return -EINVAL;
11029 }
11030 }
11031 else
11032 {
11033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053011034 "%s: Invalid device_mode = %s (%d)",
11035 __func__, hdd_device_modetoString(pAdapter->device_mode),
11036 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011037 return -EINVAL;
11038 }
11039
11040 return 0;
11041}
11042
Leo Chang9056f462013-08-01 19:21:11 -070011043#ifdef WLAN_NL80211_TESTMODE
11044#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070011045void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070011046(
11047 void *pAdapter,
11048 void *indCont
11049)
11050{
Leo Changd9df8aa2013-09-26 13:32:26 -070011051 tSirLPHBInd *lphbInd;
11052 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053011053 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070011054
11055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070011056 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070011057
c_hpothu73f35e62014-04-18 13:40:08 +053011058 if (pAdapter == NULL)
11059 {
11060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11061 "%s: pAdapter is NULL\n",__func__);
11062 return;
11063 }
11064
Leo Chang9056f462013-08-01 19:21:11 -070011065 if (NULL == indCont)
11066 {
11067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070011068 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070011069 return;
11070 }
11071
c_hpothu73f35e62014-04-18 13:40:08 +053011072 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070011073 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070011074 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053011075 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070011076 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070011077 GFP_ATOMIC);
11078 if (!skb)
11079 {
11080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11081 "LPHB timeout, NL buffer alloc fail");
11082 return;
11083 }
11084
Leo Changac3ba772013-10-07 09:47:04 -070011085 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070011086 {
11087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11088 "WLAN_HDD_TM_ATTR_CMD put fail");
11089 goto nla_put_failure;
11090 }
Leo Changac3ba772013-10-07 09:47:04 -070011091 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070011092 {
11093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11094 "WLAN_HDD_TM_ATTR_TYPE put fail");
11095 goto nla_put_failure;
11096 }
Leo Changac3ba772013-10-07 09:47:04 -070011097 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070011098 sizeof(tSirLPHBInd), lphbInd))
11099 {
11100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11101 "WLAN_HDD_TM_ATTR_DATA put fail");
11102 goto nla_put_failure;
11103 }
Leo Chang9056f462013-08-01 19:21:11 -070011104 cfg80211_testmode_event(skb, GFP_ATOMIC);
11105 return;
11106
11107nla_put_failure:
11108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11109 "NLA Put fail");
11110 kfree_skb(skb);
11111
11112 return;
11113}
11114#endif /* FEATURE_WLAN_LPHB */
11115
11116static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
11117{
11118 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
11119 int err = 0;
11120#ifdef FEATURE_WLAN_LPHB
11121 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070011122 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -070011123#endif /* FEATURE_WLAN_LPHB */
11124
11125 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
11126 if (err)
11127 {
11128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11129 "%s Testmode INV ATTR", __func__);
11130 return err;
11131 }
11132
11133 if (!tb[WLAN_HDD_TM_ATTR_CMD])
11134 {
11135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11136 "%s Testmode INV CMD", __func__);
11137 return -EINVAL;
11138 }
11139
11140 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
11141 {
11142#ifdef FEATURE_WLAN_LPHB
11143 /* Low Power Heartbeat configuration request */
11144 case WLAN_HDD_TM_CMD_WLAN_HB:
11145 {
11146 int buf_len;
11147 void *buf;
11148 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080011149 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070011150
11151 if (!tb[WLAN_HDD_TM_ATTR_DATA])
11152 {
11153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11154 "%s Testmode INV DATA", __func__);
11155 return -EINVAL;
11156 }
11157
11158 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
11159 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080011160
11161 hb_params_temp =(tSirLPHBReq *)buf;
11162 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
11163 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
11164 return -EINVAL;
11165
Leo Chang9056f462013-08-01 19:21:11 -070011166 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
11167 if (NULL == hb_params)
11168 {
11169 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11170 "%s Request Buffer Alloc Fail", __func__);
11171 return -EINVAL;
11172 }
11173
11174 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070011175 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
11176 hb_params,
11177 wlan_hdd_cfg80211_lphb_ind_handler);
11178 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070011179 {
Leo Changd9df8aa2013-09-26 13:32:26 -070011180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11181 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070011182 vos_mem_free(hb_params);
11183 }
Leo Chang9056f462013-08-01 19:21:11 -070011184 return 0;
11185 }
11186#endif /* FEATURE_WLAN_LPHB */
11187 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053011188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11189 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070011190 return -EOPNOTSUPP;
11191 }
11192
11193 return err;
11194}
11195#endif /* CONFIG_NL80211_TESTMODE */
11196
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011197static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
11198 struct net_device *dev,
11199 int idx, struct survey_info *survey)
11200{
11201 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
11202 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053011203 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011204 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053011205 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011206 v_S7_t snr,rssi;
11207 int status, i, j, filled = 0;
11208
11209 ENTER();
11210
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011211 if (NULL == pAdapter)
11212 {
11213 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11214 "%s: HDD adapter is Null", __func__);
11215 return -ENODEV;
11216 }
11217
11218 if (NULL == wiphy)
11219 {
11220 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11221 "%s: wiphy is Null", __func__);
11222 return -ENODEV;
11223 }
11224
11225 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11226 status = wlan_hdd_validate_context(pHddCtx);
11227
11228 if (0 != status)
11229 {
11230 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11231 "%s: HDD context is not valid", __func__);
11232 return status;
11233 }
11234
Mihir Sheted9072e02013-08-21 17:02:29 +053011235 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11236
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011237 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053011238 0 != pAdapter->survey_idx ||
11239 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011240 {
11241 /* The survey dump ops when implemented completely is expected to
11242 * return a survey of all channels and the ops is called by the
11243 * kernel with incremental values of the argument 'idx' till it
11244 * returns -ENONET. But we can only support the survey for the
11245 * operating channel for now. survey_idx is used to track
11246 * that the ops is called only once and then return -ENONET for
11247 * the next iteration
11248 */
11249 pAdapter->survey_idx = 0;
11250 return -ENONET;
11251 }
11252
11253 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
11254
11255 wlan_hdd_get_snr(pAdapter, &snr);
11256 wlan_hdd_get_rssi(pAdapter, &rssi);
11257
11258 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
11259 hdd_wlan_get_freq(channel, &freq);
11260
11261
11262 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
11263 {
11264 if (NULL == wiphy->bands[i])
11265 {
11266 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
11267 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
11268 continue;
11269 }
11270
11271 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
11272 {
11273 struct ieee80211_supported_band *band = wiphy->bands[i];
11274
11275 if (band->channels[j].center_freq == (v_U16_t)freq)
11276 {
11277 survey->channel = &band->channels[j];
11278 /* The Rx BDs contain SNR values in dB for the received frames
11279 * while the supplicant expects noise. So we calculate and
11280 * return the value of noise (dBm)
11281 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
11282 */
11283 survey->noise = rssi - snr;
11284 survey->filled = SURVEY_INFO_NOISE_DBM;
11285 filled = 1;
11286 }
11287 }
11288 }
11289
11290 if (filled)
11291 pAdapter->survey_idx = 1;
11292 else
11293 {
11294 pAdapter->survey_idx = 0;
11295 return -ENONET;
11296 }
11297
11298 return 0;
11299}
11300
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011301/*
11302 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
11303 * this is called when cfg80211 driver resume
11304 * driver updates latest sched_scan scan result(if any) to cfg80211 database
11305 */
11306int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
11307{
11308 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
11309 hdd_adapter_t *pAdapter;
11310 hdd_adapter_list_node_t *pAdapterNode, *pNext;
11311 VOS_STATUS status = VOS_STATUS_SUCCESS;
11312
11313 ENTER();
11314
11315 if ( NULL == pHddCtx )
11316 {
11317 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11318 "%s: HddCtx validation failed", __func__);
11319 return 0;
11320 }
11321
11322 if (pHddCtx->isLogpInProgress)
11323 {
11324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11325 "%s: LOGP in Progress. Ignore!!!", __func__);
11326 return 0;
11327 }
11328
Mihir Shete18156292014-03-11 15:38:30 +053011329 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011330 {
11331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
11332 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
11333 return 0;
11334 }
11335
11336 spin_lock(&pHddCtx->schedScan_lock);
11337 pHddCtx->isWiphySuspended = FALSE;
11338 if (TRUE != pHddCtx->isSchedScanUpdatePending)
11339 {
11340 spin_unlock(&pHddCtx->schedScan_lock);
11341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11342 "%s: Return resume is not due to PNO indication", __func__);
11343 return 0;
11344 }
11345 // Reset flag to avoid updatating cfg80211 data old results again
11346 pHddCtx->isSchedScanUpdatePending = FALSE;
11347 spin_unlock(&pHddCtx->schedScan_lock);
11348
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053011349
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011350 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
11351
11352 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
11353 {
11354 pAdapter = pAdapterNode->pAdapter;
11355 if ( (NULL != pAdapter) &&
11356 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
11357 {
11358 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053011359 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
11361 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053011362 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011363 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053011364 {
11365 /* Acquire wakelock to handle the case where APP's tries to
11366 * suspend immediately after updating the scan results. Whis
11367 * results in app's is in suspended state and not able to
11368 * process the connect request to AP
11369 */
11370 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011371 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053011372 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011373
11374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11375 "%s : cfg80211 scan result database updated", __func__);
11376
11377 return 0;
11378
11379 }
11380 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
11381 pAdapterNode = pNext;
11382 }
11383
11384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11385 "%s: Failed to find Adapter", __func__);
11386 return 0;
11387}
11388
11389/*
11390 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
11391 * this is called when cfg80211 driver suspends
11392 */
11393int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
11394 struct cfg80211_wowlan *wow)
11395{
11396 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
11397
11398 ENTER();
11399 if (NULL == pHddCtx)
11400 {
11401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
11402 "%s: HddCtx validation failed", __func__);
11403 return 0;
11404 }
11405
11406 pHddCtx->isWiphySuspended = TRUE;
11407
11408 EXIT();
11409
11410 return 0;
11411}
11412
Jeff Johnson295189b2012-06-20 16:38:30 -070011413/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011414static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070011415{
11416 .add_virtual_intf = wlan_hdd_add_virtual_intf,
11417 .del_virtual_intf = wlan_hdd_del_virtual_intf,
11418 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
11419 .change_station = wlan_hdd_change_station,
11420#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
11421 .add_beacon = wlan_hdd_cfg80211_add_beacon,
11422 .del_beacon = wlan_hdd_cfg80211_del_beacon,
11423 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011424#else
11425 .start_ap = wlan_hdd_cfg80211_start_ap,
11426 .change_beacon = wlan_hdd_cfg80211_change_beacon,
11427 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070011428#endif
11429 .change_bss = wlan_hdd_cfg80211_change_bss,
11430 .add_key = wlan_hdd_cfg80211_add_key,
11431 .get_key = wlan_hdd_cfg80211_get_key,
11432 .del_key = wlan_hdd_cfg80211_del_key,
11433 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080011434#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070011435 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080011436#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011437 .scan = wlan_hdd_cfg80211_scan,
11438 .connect = wlan_hdd_cfg80211_connect,
11439 .disconnect = wlan_hdd_cfg80211_disconnect,
11440 .join_ibss = wlan_hdd_cfg80211_join_ibss,
11441 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
11442 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
11443 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
11444 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
11446 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053011447 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070011448#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
11449 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
11450 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
11451 .set_txq_params = wlan_hdd_set_txq_params,
11452#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 .get_station = wlan_hdd_cfg80211_get_station,
11454 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
11455 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070011456 .add_station = wlan_hdd_cfg80211_add_station,
11457#ifdef FEATURE_WLAN_LFR
11458 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
11459 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
11460 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
11461#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011462#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
11463 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
11464#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080011465#ifdef FEATURE_WLAN_TDLS
11466 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
11467 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
11468#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011469#ifdef WLAN_FEATURE_GTK_OFFLOAD
11470 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
11471#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053011472#ifdef FEATURE_WLAN_SCAN_PNO
11473 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
11474 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
11475#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053011476 .resume = wlan_hdd_cfg80211_resume_wlan,
11477 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053011478 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070011479#ifdef WLAN_NL80211_TESTMODE
11480 .testmode_cmd = wlan_hdd_cfg80211_testmode,
11481#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053011482 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070011483};
11484