blob: aa64d3d73f338eccf718a45e7c911cf46a2df6d0 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20*/
Jeff Johnson295189b2012-06-20 16:38:30 -070021
22/**========================================================================
23
24 \file wlan_hdd_cfg80211.c
25
26 \brief WLAN Host Device Driver implementation
27
Gopichand Nakkala747461f2013-04-24 19:24:45 +053028 Copyright 2008 (c) Qualcomm Technologies, Inc. All Rights Reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070029
Gopichand Nakkala747461f2013-04-24 19:24:45 +053030 Qualcomm Technologies Confidential and Proprietary.
Jeff Johnson295189b2012-06-20 16:38:30 -070031
32 ========================================================================*/
33
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070034/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070035
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070036 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070037
38
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070039 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070043 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070044
45
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070046 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070047 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070048 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070049
50 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070051 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070052 ==========================================================================*/
53
Jeff Johnson295189b2012-06-20 16:38:30 -070054
55#include <linux/version.h>
56#include <linux/module.h>
57#include <linux/kernel.h>
58#include <linux/init.h>
59#include <linux/wireless.h>
60#include <wlan_hdd_includes.h>
61#include <net/arp.h>
62#include <net/cfg80211.h>
63#include <linux/wireless.h>
64#include <wlan_hdd_wowl.h>
65#include <aniGlobal.h>
66#include "ccmApi.h"
67#include "sirParams.h"
68#include "dot11f.h"
69#include "wlan_hdd_assoc.h"
70#include "wlan_hdd_wext.h"
71#include "sme_Api.h"
72#include "wlan_hdd_p2p.h"
73#include "wlan_hdd_cfg80211.h"
74#include "wlan_hdd_hostapd.h"
75#include "sapInternal.h"
76#include "wlan_hdd_softap_tx_rx.h"
77#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053078#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053079#include "wlan_hdd_power.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070080#ifdef WLAN_BTAMP_FEATURE
81#include "bap_hdd_misc.h"
82#endif
83#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080084#ifdef FEATURE_WLAN_TDLS
85#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053086#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053087#include "wlan_qct_wda.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080088#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053089#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070090#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070091
92#define g_mode_rates_size (12)
93#define a_mode_rates_size (8)
94#define FREQ_BASE_80211G (2407)
95#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070096#define MAX_SCAN_SSID 9
Jeff Johnson295189b2012-06-20 16:38:30 -070097#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
98 ((int) OFFSET_OF( tSirBssDescription, ieFields)))
99
100#define HDD2GHZCHAN(freq, chan, flag) { \
101 .band = IEEE80211_BAND_2GHZ, \
102 .center_freq = (freq), \
103 .hw_value = (chan),\
104 .flags = (flag), \
105 .max_antenna_gain = 0 ,\
106 .max_power = 30, \
107}
108
109#define HDD5GHZCHAN(freq, chan, flag) { \
110 .band = IEEE80211_BAND_5GHZ, \
111 .center_freq = (freq), \
112 .hw_value = (chan),\
113 .flags = (flag), \
114 .max_antenna_gain = 0 ,\
115 .max_power = 30, \
116}
117
118#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
119{\
120 .bitrate = rate, \
121 .hw_value = rate_id, \
122 .flags = flag, \
123}
124
Lee Hoonkic1262f22013-01-24 21:59:00 -0800125#ifndef WLAN_FEATURE_TDLS_DEBUG
126#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
127#else
128#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
129#endif
130
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530131#ifdef WLAN_FEATURE_VOWIFI_11R
132#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
133#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
134#endif
135
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530136static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700137{
138 WLAN_CIPHER_SUITE_WEP40,
139 WLAN_CIPHER_SUITE_WEP104,
140 WLAN_CIPHER_SUITE_TKIP,
141#ifdef FEATURE_WLAN_CCX
142#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
143 WLAN_CIPHER_SUITE_KRK,
144 WLAN_CIPHER_SUITE_CCMP,
145#else
146 WLAN_CIPHER_SUITE_CCMP,
147#endif
148#ifdef FEATURE_WLAN_WAPI
149 WLAN_CIPHER_SUITE_SMS4,
150#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700151#ifdef WLAN_FEATURE_11W
152 WLAN_CIPHER_SUITE_AES_CMAC,
153#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700154};
155
156static inline int is_broadcast_ether_addr(const u8 *addr)
157{
158 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
159 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
160}
161
162static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530163{
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 HDD2GHZCHAN(2412, 1, 0) ,
165 HDD2GHZCHAN(2417, 2, 0) ,
166 HDD2GHZCHAN(2422, 3, 0) ,
167 HDD2GHZCHAN(2427, 4, 0) ,
168 HDD2GHZCHAN(2432, 5, 0) ,
169 HDD2GHZCHAN(2437, 6, 0) ,
170 HDD2GHZCHAN(2442, 7, 0) ,
171 HDD2GHZCHAN(2447, 8, 0) ,
172 HDD2GHZCHAN(2452, 9, 0) ,
173 HDD2GHZCHAN(2457, 10, 0) ,
174 HDD2GHZCHAN(2462, 11, 0) ,
175 HDD2GHZCHAN(2467, 12, 0) ,
176 HDD2GHZCHAN(2472, 13, 0) ,
177 HDD2GHZCHAN(2484, 14, 0) ,
178};
179
Jeff Johnson295189b2012-06-20 16:38:30 -0700180static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
181{
182 HDD2GHZCHAN(2412, 1, 0) ,
183 HDD2GHZCHAN(2437, 6, 0) ,
184 HDD2GHZCHAN(2462, 11, 0) ,
185};
Jeff Johnson295189b2012-06-20 16:38:30 -0700186
187static struct ieee80211_channel hdd_channels_5_GHZ[] =
188{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700189 HDD5GHZCHAN(4920, 240, 0) ,
190 HDD5GHZCHAN(4940, 244, 0) ,
191 HDD5GHZCHAN(4960, 248, 0) ,
192 HDD5GHZCHAN(4980, 252, 0) ,
193 HDD5GHZCHAN(5040, 208, 0) ,
194 HDD5GHZCHAN(5060, 212, 0) ,
195 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700196 HDD5GHZCHAN(5180, 36, 0) ,
197 HDD5GHZCHAN(5200, 40, 0) ,
198 HDD5GHZCHAN(5220, 44, 0) ,
199 HDD5GHZCHAN(5240, 48, 0) ,
200 HDD5GHZCHAN(5260, 52, 0) ,
201 HDD5GHZCHAN(5280, 56, 0) ,
202 HDD5GHZCHAN(5300, 60, 0) ,
203 HDD5GHZCHAN(5320, 64, 0) ,
204 HDD5GHZCHAN(5500,100, 0) ,
205 HDD5GHZCHAN(5520,104, 0) ,
206 HDD5GHZCHAN(5540,108, 0) ,
207 HDD5GHZCHAN(5560,112, 0) ,
208 HDD5GHZCHAN(5580,116, 0) ,
209 HDD5GHZCHAN(5600,120, 0) ,
210 HDD5GHZCHAN(5620,124, 0) ,
211 HDD5GHZCHAN(5640,128, 0) ,
212 HDD5GHZCHAN(5660,132, 0) ,
213 HDD5GHZCHAN(5680,136, 0) ,
214 HDD5GHZCHAN(5700,140, 0) ,
215 HDD5GHZCHAN(5745,149, 0) ,
216 HDD5GHZCHAN(5765,153, 0) ,
217 HDD5GHZCHAN(5785,157, 0) ,
218 HDD5GHZCHAN(5805,161, 0) ,
219 HDD5GHZCHAN(5825,165, 0) ,
220};
221
222static struct ieee80211_rate g_mode_rates[] =
223{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530224 HDD_G_MODE_RATETAB(10, 0x1, 0),
225 HDD_G_MODE_RATETAB(20, 0x2, 0),
226 HDD_G_MODE_RATETAB(55, 0x4, 0),
227 HDD_G_MODE_RATETAB(110, 0x8, 0),
228 HDD_G_MODE_RATETAB(60, 0x10, 0),
229 HDD_G_MODE_RATETAB(90, 0x20, 0),
230 HDD_G_MODE_RATETAB(120, 0x40, 0),
231 HDD_G_MODE_RATETAB(180, 0x80, 0),
232 HDD_G_MODE_RATETAB(240, 0x100, 0),
233 HDD_G_MODE_RATETAB(360, 0x200, 0),
234 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530236};
Jeff Johnson295189b2012-06-20 16:38:30 -0700237
238static struct ieee80211_rate a_mode_rates[] =
239{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530240 HDD_G_MODE_RATETAB(60, 0x10, 0),
241 HDD_G_MODE_RATETAB(90, 0x20, 0),
242 HDD_G_MODE_RATETAB(120, 0x40, 0),
243 HDD_G_MODE_RATETAB(180, 0x80, 0),
244 HDD_G_MODE_RATETAB(240, 0x100, 0),
245 HDD_G_MODE_RATETAB(360, 0x200, 0),
246 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700247 HDD_G_MODE_RATETAB(540, 0x800, 0),
248};
249
250static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
251{
252 .channels = hdd_channels_2_4_GHZ,
253 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
254 .band = IEEE80211_BAND_2GHZ,
255 .bitrates = g_mode_rates,
256 .n_bitrates = g_mode_rates_size,
257 .ht_cap.ht_supported = 1,
258 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
259 | IEEE80211_HT_CAP_GRN_FLD
260 | IEEE80211_HT_CAP_DSSSCCK40
261 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
262 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
263 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
264 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
265 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
266 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
267};
268
Jeff Johnson295189b2012-06-20 16:38:30 -0700269static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
270{
271 .channels = hdd_social_channels_2_4_GHZ,
272 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
273 .band = IEEE80211_BAND_2GHZ,
274 .bitrates = g_mode_rates,
275 .n_bitrates = g_mode_rates_size,
276 .ht_cap.ht_supported = 1,
277 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
278 | IEEE80211_HT_CAP_GRN_FLD
279 | IEEE80211_HT_CAP_DSSSCCK40
280 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
281 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
282 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
283 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
284 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
285 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
286};
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
289{
290 .channels = hdd_channels_5_GHZ,
291 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
292 .band = IEEE80211_BAND_5GHZ,
293 .bitrates = a_mode_rates,
294 .n_bitrates = a_mode_rates_size,
295 .ht_cap.ht_supported = 1,
296 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
297 | IEEE80211_HT_CAP_GRN_FLD
298 | IEEE80211_HT_CAP_DSSSCCK40
299 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
300 | IEEE80211_HT_CAP_SGI_40
301 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
302 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
303 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
304 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
305 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
306 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
307};
308
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530309/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 TX/RX direction for each kind of interface */
311static const struct ieee80211_txrx_stypes
312wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
313 [NL80211_IFTYPE_STATION] = {
314 .tx = 0xffff,
315 .rx = BIT(SIR_MAC_MGMT_ACTION) |
316 BIT(SIR_MAC_MGMT_PROBE_REQ),
317 },
318 [NL80211_IFTYPE_AP] = {
319 .tx = 0xffff,
320 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
321 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
322 BIT(SIR_MAC_MGMT_PROBE_REQ) |
323 BIT(SIR_MAC_MGMT_DISASSOC) |
324 BIT(SIR_MAC_MGMT_AUTH) |
325 BIT(SIR_MAC_MGMT_DEAUTH) |
326 BIT(SIR_MAC_MGMT_ACTION),
327 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700328 [NL80211_IFTYPE_ADHOC] = {
329 .tx = 0xffff,
330 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
331 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
332 BIT(SIR_MAC_MGMT_PROBE_REQ) |
333 BIT(SIR_MAC_MGMT_DISASSOC) |
334 BIT(SIR_MAC_MGMT_AUTH) |
335 BIT(SIR_MAC_MGMT_DEAUTH) |
336 BIT(SIR_MAC_MGMT_ACTION),
337 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 [NL80211_IFTYPE_P2P_CLIENT] = {
339 .tx = 0xffff,
340 .rx = BIT(SIR_MAC_MGMT_ACTION) |
341 BIT(SIR_MAC_MGMT_PROBE_REQ),
342 },
343 [NL80211_IFTYPE_P2P_GO] = {
344 /* This is also same as for SoftAP */
345 .tx = 0xffff,
346 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
347 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
348 BIT(SIR_MAC_MGMT_PROBE_REQ) |
349 BIT(SIR_MAC_MGMT_DISASSOC) |
350 BIT(SIR_MAC_MGMT_AUTH) |
351 BIT(SIR_MAC_MGMT_DEAUTH) |
352 BIT(SIR_MAC_MGMT_ACTION),
353 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700354};
355
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800356#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800357static const struct ieee80211_iface_limit
358wlan_hdd_iface_limit[] = {
359 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800360 /* max = 3 ; Our driver create two interfaces during driver init
361 * wlan0 and p2p0 interfaces. p2p0 is considered as station
362 * interface until a group is formed. In JB architecture, once the
363 * group is formed, interface type of p2p0 is changed to P2P GO or
364 * Client.
365 * When supplicant remove the group, it first issue a set interface
366 * cmd to change the mode back to Station. In JB this works fine as
367 * we advertize two station type interface during driver init.
368 * Some vendors create separate interface for P2P GO/Client,
369 * after group formation(Third one). But while group remove
370 * supplicant first tries to change the mode(3rd interface) to STATION
371 * But as we advertized only two sta type interfaces nl80211 was
372 * returning error for the third one which was leading to failure in
373 * delete interface. Ideally while removing the group, supplicant
374 * should not try to change the 3rd interface mode to Station type.
375 * Till we get a fix in wpa_supplicant, we advertize max STA
376 * interface type to 3
377 */
378 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800379 .types = BIT(NL80211_IFTYPE_STATION),
380 },
381 {
382 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700383 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800384 },
385 {
386 .max = 1,
387 .types = BIT(NL80211_IFTYPE_P2P_GO) |
388 BIT(NL80211_IFTYPE_P2P_CLIENT),
389 },
390};
391
392/* By default, only single channel concurrency is allowed */
393static struct ieee80211_iface_combination
394wlan_hdd_iface_combination = {
395 .limits = wlan_hdd_iface_limit,
396 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800397 /*
398 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
399 * and p2p0 interfaces during driver init
400 * Some vendors create separate interface for P2P operations.
401 * wlan0: STA interface
402 * p2p0: P2P Device interface, action frames goes
403 * through this interface.
404 * p2p-xx: P2P interface, After GO negotiation this interface is
405 * created for p2p operations(GO/CLIENT interface).
406 */
407 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800408 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
409 .beacon_int_infra_match = false,
410};
411#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800412
Jeff Johnson295189b2012-06-20 16:38:30 -0700413static struct cfg80211_ops wlan_hdd_cfg80211_ops;
414
415/* Data rate 100KBPS based on IE Index */
416struct index_data_rate_type
417{
418 v_U8_t beacon_rate_index;
419 v_U16_t supported_rate[4];
420};
421
422/* 11B, 11G Rate table include Basic rate and Extended rate
423 The IDX field is the rate index
424 The HI field is the rate when RSSI is strong or being ignored
425 (in this case we report actual rate)
426 The MID field is the rate when RSSI is moderate
427 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
428 The LO field is the rate when RSSI is low
429 (in this case we don't report rates, actual current rate used)
430 */
431static const struct
432{
433 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700434 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700435} supported_data_rate[] =
436{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700437/* IDX HI HM LM LO (RSSI-based index */
438 {2, { 10, 10, 10, 0}},
439 {4, { 20, 20, 10, 0}},
440 {11, { 55, 20, 10, 0}},
441 {12, { 60, 55, 20, 0}},
442 {18, { 90, 55, 20, 0}},
443 {22, {110, 55, 20, 0}},
444 {24, {120, 90, 60, 0}},
445 {36, {180, 120, 60, 0}},
446 {44, {220, 180, 60, 0}},
447 {48, {240, 180, 90, 0}},
448 {66, {330, 180, 90, 0}},
449 {72, {360, 240, 90, 0}},
450 {96, {480, 240, 120, 0}},
451 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700452};
453
454/* MCS Based rate table */
455static struct index_data_rate_type supported_mcs_rate[] =
456{
457/* MCS L20 L40 S20 S40 */
458 {0, {65, 135, 72, 150}},
459 {1, {130, 270, 144, 300}},
460 {2, {195, 405, 217, 450}},
461 {3, {260, 540, 289, 600}},
462 {4, {390, 810, 433, 900}},
463 {5, {520, 1080, 578, 1200}},
464 {6, {585, 1215, 650, 1350}},
465 {7, {650, 1350, 722, 1500}}
466};
467
Leo Chang6f8870f2013-03-26 18:11:36 -0700468#ifdef WLAN_FEATURE_11AC
469
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530470#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700471
472struct index_vht_data_rate_type
473{
474 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530475 v_U16_t supported_VHT80_rate[2];
476 v_U16_t supported_VHT40_rate[2];
477 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700478};
479
480typedef enum
481{
482 DATA_RATE_11AC_MAX_MCS_7,
483 DATA_RATE_11AC_MAX_MCS_8,
484 DATA_RATE_11AC_MAX_MCS_9,
485 DATA_RATE_11AC_MAX_MCS_NA
486} eDataRate11ACMaxMcs;
487
488/* MCS Based VHT rate table */
489static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
490{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530491/* MCS L80 S80 L40 S40 L20 S40*/
492 {0, {293, 325}, {135, 150}, {65, 72}},
493 {1, {585, 650}, {270, 300}, {130, 144}},
494 {2, {878, 975}, {405, 450}, {195, 217}},
495 {3, {1170, 1300}, {540, 600}, {260, 289}},
496 {4, {1755, 1950}, {810, 900}, {390, 433}},
497 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
498 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
499 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
500 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
501 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700502};
503#endif /* WLAN_FEATURE_11AC */
504
Jeff Johnson295189b2012-06-20 16:38:30 -0700505extern struct net_device_ops net_ops_struct;
506
Leo Chang9056f462013-08-01 19:21:11 -0700507#ifdef WLAN_NL80211_TESTMODE
508enum wlan_hdd_tm_attr
509{
510 WLAN_HDD_TM_ATTR_INVALID = 0,
511 WLAN_HDD_TM_ATTR_CMD = 1,
512 WLAN_HDD_TM_ATTR_DATA = 2,
513 WLAN_HDD_TM_ATTR_TYPE = 3,
514 /* keep last */
515 WLAN_HDD_TM_ATTR_AFTER_LAST,
516 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
517};
518
519enum wlan_hdd_tm_cmd
520{
521 WLAN_HDD_TM_CMD_WLAN_HB = 1,
522};
523
524#define WLAN_HDD_TM_DATA_MAX_LEN 5000
525
526static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
527{
528 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
529 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
530 .len = WLAN_HDD_TM_DATA_MAX_LEN },
531};
532#endif /* WLAN_NL80211_TESTMODE */
533
Jeff Johnson295189b2012-06-20 16:38:30 -0700534/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530535 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530536 * This function is called by hdd_wlan_startup()
537 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530538 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530540struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -0700541{
542 struct wiphy *wiphy;
543 ENTER();
544
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530545 /*
546 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 */
548 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
549
550 if (!wiphy)
551 {
552 /* Print error and jump into err label and free the memory */
553 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
554 return NULL;
555 }
556
557 return wiphy;
558}
559
560/*
561 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530562 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 * private ioctl to change the band value
564 */
565int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
566{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530567 int i, j;
568 eNVChannelEnabledType channelEnabledState;
569
Jeff Johnsone7245742012-09-05 17:12:55 -0700570 ENTER();
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530571 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530573
574 if (NULL == wiphy->bands[i])
575 {
576 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
577 __func__, i);
578 continue;
579 }
580
581 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
582 {
583 struct ieee80211_supported_band *band = wiphy->bands[i];
584
585 channelEnabledState = vos_nv_getChannelEnabledState(
586 band->channels[j].hw_value);
587
588 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
589 {
590 // Enable Social channels for P2P
591 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
592 NV_CHANNEL_ENABLE == channelEnabledState)
593 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
594 else
595 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
596 continue;
597 }
598 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
599 {
600 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
601 continue;
602 }
603
604 if (NV_CHANNEL_DISABLE == channelEnabledState ||
605 NV_CHANNEL_INVALID == channelEnabledState)
606 {
607 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
608 }
609 else if (NV_CHANNEL_DFS == channelEnabledState)
610 {
611 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
612 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
613 }
614 else
615 {
616 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
617 |IEEE80211_CHAN_RADAR);
618 }
619 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 }
621 return 0;
622}
623/*
624 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530625 * This function is called by hdd_wlan_startup()
626 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 * This function is used to initialize and register wiphy structure.
628 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530629int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 struct wiphy *wiphy,
631 hdd_config_t *pCfg
632 )
633{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530634 int i, j;
Jeff Johnsone7245742012-09-05 17:12:55 -0700635 ENTER();
636
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 /* Now bind the underlying wlan device with wiphy */
638 set_wiphy_dev(wiphy, dev);
639
640 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700641
Amar Singhala49cbc52013-10-08 18:37:44 -0700642 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
643
644
Amar Singhalfddc28c2013-09-05 13:03:40 -0700645 /* This will disable updating of NL channels from passive to
646 * active if a beacon is received on passive channel. */
647 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -0700648
Amar Singhalfddc28c2013-09-05 13:03:40 -0700649
Amar Singhala49cbc52013-10-08 18:37:44 -0700650
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700651#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700652 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
653 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
654 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700655 | WIPHY_FLAG_OFFCHAN_TX;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700656#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700657
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700658#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
659 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800660#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700661 || pCfg->isFastRoamIniFeatureEnabled
662#endif
663#ifdef FEATURE_WLAN_CCX
664 || pCfg->isCcxIniFeatureEnabled
665#endif
666 )
667 {
668 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
669 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800670#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800671#ifdef FEATURE_WLAN_TDLS
672 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
673 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
674#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530675#ifdef FEATURE_WLAN_SCAN_PNO
676 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
Madan Mohan Koyyalamudi75de0102013-09-17 14:56:29 +0530677 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530678 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +0530679 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530680#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800681
Amar Singhalfddc28c2013-09-05 13:03:40 -0700682#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700683 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
684 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -0700685 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700686 driver need to determine what to do with both
687 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -0700688
689 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -0700690#else
691 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700692#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700693
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530694 wiphy->max_scan_ssids = MAX_SCAN_SSID;
695
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530696 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700697
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530698 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
699
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530701 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700702 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 | BIT(NL80211_IFTYPE_P2P_CLIENT)
704 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700705 | BIT(NL80211_IFTYPE_AP);
706
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800707#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800708 if( pCfg->enableMCC )
709 {
710 /* Currently, supports up to two channels */
711 wlan_hdd_iface_combination.num_different_channels = 2;
712
713 if( !pCfg->allowMCCGODiffBI )
714 wlan_hdd_iface_combination.beacon_int_infra_match = true;
715
716 }
717 wiphy->iface_combinations = &wlan_hdd_iface_combination;
718 wiphy->n_iface_combinations = 1;
719#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800720
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 /* Before registering we need to update the ht capabilitied based
722 * on ini values*/
723 if( !pCfg->ShortGI20MhzEnable )
724 {
725 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
726 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
727 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
728 }
729
730 if( !pCfg->ShortGI40MhzEnable )
731 {
732 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
733 }
734
735 if( !pCfg->nChannelBondingMode5GHz )
736 {
737 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
738 }
739
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530740 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
741 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
742
743 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
744 {
745
746 if (NULL == wiphy->bands[i])
747 {
748 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
749 __func__, i);
750 continue;
751 }
752
753 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
754 {
755 struct ieee80211_supported_band *band = wiphy->bands[i];
756
757 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
758 {
759 // Enable social channels for P2P
760 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
761 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
762 else
763 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
764 continue;
765 }
766 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
767 {
768 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
769 continue;
770 }
771 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 }
773 /*Initialise the supported cipher suite details*/
774 wiphy->cipher_suites = hdd_cipher_suites;
775 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
776
777 /*signal strength in mBm (100*dBm) */
778 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
779
780#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700781 wiphy->max_remain_on_channel_duration = 1000;
782#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700783
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530784 EXIT();
785 return 0;
786}
787
788/* In this function we are registering wiphy. */
789int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
790{
791 ENTER();
792 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 if (0 > wiphy_register(wiphy))
794 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530795 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
797 return -EIO;
798 }
799
800 EXIT();
801 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530802}
Jeff Johnson295189b2012-06-20 16:38:30 -0700803
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530804/* In this function we are updating channel list when,
805 regulatory domain is FCC and country code is US.
806 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
807 As per FCC smart phone is not a indoor device.
808 GO should not opeate on indoor channels */
809void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
810{
811 int j;
812 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
813 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
814 //Default counrtycode from NV at the time of wiphy initialization.
815 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
816 &defaultCountryCode[0]))
817 {
818 hddLog(LOGE, FL("%s Failed to get default country code from NV"));
819 }
820 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
821 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530822 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
823 {
824 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
825 return;
826 }
827 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
828 {
829 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
830 // Mark UNII -1 band channel as passive
831 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
832 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
833 }
834 }
835}
836
Jeff Johnson295189b2012-06-20 16:38:30 -0700837/* In this function we will do all post VOS start initialization.
838 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530839 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700840*/
841void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
842{
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
844 /* Register for all P2P action, public action etc frames */
845 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
846
Jeff Johnsone7245742012-09-05 17:12:55 -0700847 ENTER();
848
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 /* Right now we are registering these frame when driver is getting
850 initialized. Once we will move to 2.6.37 kernel, in which we have
851 frame register ops, we will move this code as a part of that */
852 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530853 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
855
856 /* GAS Initial Response */
857 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
858 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530859
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 /* GAS Comeback Request */
861 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
862 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
863
864 /* GAS Comeback Response */
865 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
866 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
867
868 /* P2P Public Action */
869 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530870 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 P2P_PUBLIC_ACTION_FRAME_SIZE );
872
873 /* P2P Action */
874 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
875 (v_U8_t*)P2P_ACTION_FRAME,
876 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700877
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530878 /* WNM BSS Transition Request frame */
879 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
880 (v_U8_t*)WNM_BSS_ACTION_FRAME,
881 WNM_BSS_ACTION_FRAME_SIZE );
882
Chet Lanctot186b5732013-03-18 10:26:30 -0700883#ifdef WLAN_FEATURE_11W
884 /* SA Query Response Action Frame */
885 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
886 (v_U8_t*)SA_QUERY_FRAME_RSP,
887 SA_QUERY_FRAME_RSP_SIZE );
888#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700889}
890
891void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
892{
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
894 /* Register for all P2P action, public action etc frames */
895 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
896
Jeff Johnsone7245742012-09-05 17:12:55 -0700897 ENTER();
898
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 /* Right now we are registering these frame when driver is getting
900 initialized. Once we will move to 2.6.37 kernel, in which we have
901 frame register ops, we will move this code as a part of that */
902 /* GAS Initial Request */
903
904 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
905 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
906
907 /* GAS Initial Response */
908 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
909 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530910
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 /* GAS Comeback Request */
912 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
913 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
914
915 /* GAS Comeback Response */
916 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
917 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
918
919 /* P2P Public Action */
920 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530921 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 P2P_PUBLIC_ACTION_FRAME_SIZE );
923
924 /* P2P Action */
925 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
926 (v_U8_t*)P2P_ACTION_FRAME,
927 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700928
929#ifdef WLAN_FEATURE_11W
930 /* SA Query Response Action Frame */
931 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
932 (v_U8_t*)SA_QUERY_FRAME_RSP,
933 SA_QUERY_FRAME_RSP_SIZE );
934#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700935}
936
937#ifdef FEATURE_WLAN_WAPI
938void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
939 const u8 *mac_addr, u8 *key , int key_Len)
940{
941 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
942 tCsrRoamSetKey setKey;
943 v_BOOL_t isConnected = TRUE;
944 int status = 0;
945 v_U32_t roamId= 0xFF;
946 tANI_U8 *pKeyPtr = NULL;
947 int n = 0;
948
949 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
950 __func__,pAdapter->device_mode);
951
Gopichand Nakkalae7480202013-02-11 15:24:22 +0530952 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 setKey.keyId = key_index; // Store Key ID
954 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
955 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
956 setKey.paeRole = 0 ; // the PAE role
957 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
958 {
959 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
960 }
961 else
962 {
963 isConnected = hdd_connIsConnected(pHddStaCtx);
964 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
965 }
966 setKey.keyLength = key_Len;
967 pKeyPtr = setKey.Key;
968 memcpy( pKeyPtr, key, key_Len);
969
970 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
971 __func__, key_Len);
972 for (n = 0 ; n < key_Len; n++)
973 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
974 __func__,n,setKey.Key[n]);
975
976 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
977 if ( isConnected )
978 {
979 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
980 pAdapter->sessionId, &setKey, &roamId );
981 }
982 if ( status != 0 )
983 {
984 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
985 "[%4d] sme_RoamSetKey returned ERROR status= %d",
986 __LINE__, status );
987 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
988 }
989}
990#endif /* FEATURE_WLAN_WAPI*/
991
992#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530993int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 beacon_data_t **ppBeacon,
995 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700996#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530997int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700998 beacon_data_t **ppBeacon,
999 struct cfg80211_beacon_data *params,
1000 int dtim_period)
1001#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301002{
Jeff Johnson295189b2012-06-20 16:38:30 -07001003 int size;
1004 beacon_data_t *beacon = NULL;
1005 beacon_data_t *old = NULL;
1006 int head_len,tail_len;
1007
Jeff Johnsone7245742012-09-05 17:12:55 -07001008 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 if (params->head && !params->head_len)
1010 return -EINVAL;
1011
1012 old = pAdapter->sessionCtx.ap.beacon;
1013
1014 if (!params->head && !old)
1015 return -EINVAL;
1016
1017 if (params->tail && !params->tail_len)
1018 return -EINVAL;
1019
1020#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1021 /* Kernel 3.0 is not updating dtim_period for set beacon */
1022 if (!params->dtim_period)
1023 return -EINVAL;
1024#endif
1025
1026 if(params->head)
1027 head_len = params->head_len;
1028 else
1029 head_len = old->head_len;
1030
1031 if(params->tail || !old)
1032 tail_len = params->tail_len;
1033 else
1034 tail_len = old->tail_len;
1035
1036 size = sizeof(beacon_data_t) + head_len + tail_len;
1037
1038 beacon = kzalloc(size, GFP_KERNEL);
1039
1040 if( beacon == NULL )
1041 return -ENOMEM;
1042
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001043#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 if(params->dtim_period || !old )
1045 beacon->dtim_period = params->dtim_period;
1046 else
1047 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001048#else
1049 if(dtim_period || !old )
1050 beacon->dtim_period = dtim_period;
1051 else
1052 beacon->dtim_period = old->dtim_period;
1053#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301054
Jeff Johnson295189b2012-06-20 16:38:30 -07001055 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1056 beacon->tail = beacon->head + head_len;
1057 beacon->head_len = head_len;
1058 beacon->tail_len = tail_len;
1059
1060 if(params->head) {
1061 memcpy (beacon->head,params->head,beacon->head_len);
1062 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301063 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 if(old)
1065 memcpy (beacon->head,old->head,beacon->head_len);
1066 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301067
Jeff Johnson295189b2012-06-20 16:38:30 -07001068 if(params->tail) {
1069 memcpy (beacon->tail,params->tail,beacon->tail_len);
1070 }
1071 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301072 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 memcpy (beacon->tail,old->tail,beacon->tail_len);
1074 }
1075
1076 *ppBeacon = beacon;
1077
1078 kfree(old);
1079
1080 return 0;
1081
1082}
Jeff Johnson295189b2012-06-20 16:38:30 -07001083
1084v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1085{
1086 int left = length;
1087 v_U8_t *ptr = pIes;
1088 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301089
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301091 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 elem_id = ptr[0];
1093 elem_len = ptr[1];
1094 left -= 2;
1095 if(elem_len > left)
1096 {
1097 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001098 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 eid,elem_len,left);
1100 return NULL;
1101 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301102 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 {
1104 return ptr;
1105 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301106
Jeff Johnson295189b2012-06-20 16:38:30 -07001107 left -= elem_len;
1108 ptr += (elem_len + 2);
1109 }
1110 return NULL;
1111}
1112
Jeff Johnson295189b2012-06-20 16:38:30 -07001113/* Check if rate is 11g rate or not */
1114static int wlan_hdd_rate_is_11g(u8 rate)
1115{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001116 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001117 u8 i;
1118 for (i = 0; i < 8; i++)
1119 {
1120 if(rate == gRateArray[i])
1121 return TRUE;
1122 }
1123 return FALSE;
1124}
1125
1126/* Check for 11g rate and set proper 11g only mode */
1127static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1128 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1129{
1130 u8 i, num_rates = pIe[0];
1131
1132 pIe += 1;
1133 for ( i = 0; i < num_rates; i++)
1134 {
1135 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1136 {
1137 /* If rate set have 11g rate than change the mode to 11G */
1138 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1139 if (pIe[i] & BASIC_RATE_MASK)
1140 {
1141 /* If we have 11g rate as basic rate, it means mode
1142 is 11g only mode.
1143 */
1144 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1145 *pCheckRatesfor11g = FALSE;
1146 }
1147 }
1148 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1149 {
1150 *require_ht = TRUE;
1151 }
1152 }
1153 return;
1154}
1155
1156static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1157{
1158 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1159 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1160 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1161 u8 checkRatesfor11g = TRUE;
1162 u8 require_ht = FALSE;
1163 u8 *pIe=NULL;
1164
1165 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1166
1167 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1168 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1169 if (pIe != NULL)
1170 {
1171 pIe += 1;
1172 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1173 &pConfig->SapHw_mode);
1174 }
1175
1176 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1177 WLAN_EID_EXT_SUPP_RATES);
1178 if (pIe != NULL)
1179 {
1180
1181 pIe += 1;
1182 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1183 &pConfig->SapHw_mode);
1184 }
1185
1186 if( pConfig->channel > 14 )
1187 {
1188 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1189 }
1190
1191 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1192 WLAN_EID_HT_CAPABILITY);
1193
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301194 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 {
1196 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1197 if(require_ht)
1198 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1199 }
1200}
1201
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301202static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1203 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1204{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001205 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301206 v_U8_t *pIe = NULL;
1207 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1208
1209 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1210 pBeacon->tail, pBeacon->tail_len);
1211
1212 if (pIe)
1213 {
1214 ielen = pIe[1] + 2;
1215 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1216 {
1217 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1218 }
1219 else
1220 {
1221 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1222 return -EINVAL;
1223 }
1224 *total_ielen += ielen;
1225 }
1226 return 0;
1227}
1228
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001229static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
1230 v_U8_t *genie, v_U8_t *total_ielen)
1231{
1232 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1233 int left = pBeacon->tail_len;
1234 v_U8_t *ptr = pBeacon->tail;
1235 v_U8_t elem_id, elem_len;
1236 v_U16_t ielen = 0;
1237
1238 if ( NULL == ptr || 0 == left )
1239 return;
1240
1241 while (left >= 2)
1242 {
1243 elem_id = ptr[0];
1244 elem_len = ptr[1];
1245 left -= 2;
1246 if (elem_len > left)
1247 {
1248 hddLog( VOS_TRACE_LEVEL_ERROR,
1249 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
1250 elem_id, elem_len, left);
1251 return;
1252 }
1253 if (IE_EID_VENDOR == elem_id)
1254 {
1255 /* skipping the VSIE's which we don't want to include or
1256 * it will be included by existing code
1257 */
1258 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
1259#ifdef WLAN_FEATURE_WFD
1260 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
1261#endif
1262 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1263 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1264 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
1265 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1266 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
1267 {
1268 ielen = ptr[1] + 2;
1269 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1270 {
1271 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
1272 *total_ielen += ielen;
1273 }
1274 else
1275 {
1276 hddLog( VOS_TRACE_LEVEL_ERROR,
1277 "IE Length is too big "
1278 "IEs eid=%d elem_len=%d total_ie_lent=%d",
1279 elem_id, elem_len, *total_ielen);
1280 }
1281 }
1282 }
1283
1284 left -= elem_len;
1285 ptr += (elem_len + 2);
1286 }
1287 return;
1288}
1289
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001290#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001291static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1292 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001293#else
1294static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1295 struct cfg80211_beacon_data *params)
1296#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001297{
1298 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301299 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001301 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001302
1303 genie = vos_mem_malloc(MAX_GENIE_LEN);
1304
1305 if(genie == NULL) {
1306
1307 return -ENOMEM;
1308 }
1309
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301310 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1311 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301313 ret = -EINVAL;
1314 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001315 }
1316
1317#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301318 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1319 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1320 {
1321 ret = -EINVAL;
1322 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 }
1324#endif
1325
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301326 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1327 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301329 ret = -EINVAL;
1330 goto done;
1331 }
1332
1333 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1334 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001335 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001337
1338 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1339 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1340 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1341 {
1342 hddLog(LOGE,
1343 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001344 ret = -EINVAL;
1345 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 }
1347
1348 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1349 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1350 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1351 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1352 ==eHAL_STATUS_FAILURE)
1353 {
1354 hddLog(LOGE,
1355 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001356 ret = -EINVAL;
1357 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001358 }
1359
1360 // Added for ProResp IE
1361 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1362 {
1363 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1364 u8 probe_rsp_ie_len[3] = {0};
1365 u8 counter = 0;
1366 /* Check Probe Resp Length if it is greater then 255 then Store
1367 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1368 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1369 Store More then 255 bytes into One Variable.
1370 */
1371 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1372 {
1373 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1374 {
1375 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1376 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1377 }
1378 else
1379 {
1380 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1381 rem_probe_resp_ie_len = 0;
1382 }
1383 }
1384
1385 rem_probe_resp_ie_len = 0;
1386
1387 if (probe_rsp_ie_len[0] > 0)
1388 {
1389 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1390 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1391 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1392 probe_rsp_ie_len[0], NULL,
1393 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1394 {
1395 hddLog(LOGE,
1396 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001397 ret = -EINVAL;
1398 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001399 }
1400 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1401 }
1402
1403 if (probe_rsp_ie_len[1] > 0)
1404 {
1405 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1406 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1407 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1408 probe_rsp_ie_len[1], NULL,
1409 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1410 {
1411 hddLog(LOGE,
1412 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001413 ret = -EINVAL;
1414 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 }
1416 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1417 }
1418
1419 if (probe_rsp_ie_len[2] > 0)
1420 {
1421 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1422 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1423 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1424 probe_rsp_ie_len[2], NULL,
1425 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1426 {
1427 hddLog(LOGE,
1428 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001429 ret = -EINVAL;
1430 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 }
1432 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1433 }
1434
1435 if (probe_rsp_ie_len[1] == 0 )
1436 {
1437 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1438 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1439 eANI_BOOLEAN_FALSE) )
1440 {
1441 hddLog(LOGE,
1442 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1443 }
1444 }
1445
1446 if (probe_rsp_ie_len[2] == 0 )
1447 {
1448 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1449 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1450 eANI_BOOLEAN_FALSE) )
1451 {
1452 hddLog(LOGE,
1453 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1454 }
1455 }
1456
1457 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1458 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1459 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1460 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1461 == eHAL_STATUS_FAILURE)
1462 {
1463 hddLog(LOGE,
1464 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001465 ret = -EINVAL;
1466 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 }
1468 }
1469 else
1470 {
1471 // Reset WNI_CFG_PROBE_RSP Flags
1472 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1473
1474 hddLog(VOS_TRACE_LEVEL_INFO,
1475 "%s: No Probe Response IE received in set beacon",
1476 __func__);
1477 }
1478
1479 // Added for AssocResp IE
1480 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1481 {
1482 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1483 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1484 params->assocresp_ies_len, NULL,
1485 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1486 {
1487 hddLog(LOGE,
1488 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001489 ret = -EINVAL;
1490 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 }
1492
1493 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1494 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1495 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1496 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1497 == eHAL_STATUS_FAILURE)
1498 {
1499 hddLog(LOGE,
1500 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001501 ret = -EINVAL;
1502 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 }
1504 }
1505 else
1506 {
1507 hddLog(VOS_TRACE_LEVEL_INFO,
1508 "%s: No Assoc Response IE received in set beacon",
1509 __func__);
1510
1511 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1512 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1513 eANI_BOOLEAN_FALSE) )
1514 {
1515 hddLog(LOGE,
1516 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1517 }
1518 }
1519
Jeff Johnsone7245742012-09-05 17:12:55 -07001520done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001521 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301522 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001523}
Jeff Johnson295189b2012-06-20 16:38:30 -07001524
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301525/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 * FUNCTION: wlan_hdd_validate_operation_channel
1527 * called by wlan_hdd_cfg80211_start_bss() and
1528 * wlan_hdd_cfg80211_set_channel()
1529 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301530 * channel list.
1531 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001532VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001533{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301534
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 v_U32_t num_ch = 0;
1536 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1537 u32 indx = 0;
1538 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301539 v_U8_t fValidChannel = FALSE, count = 0;
1540 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301541
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1543
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301544 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301546 /* Validate the channel */
1547 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001548 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301549 if ( channel == rfChannels[count].channelNum )
1550 {
1551 fValidChannel = TRUE;
1552 break;
1553 }
1554 }
1555 if (fValidChannel != TRUE)
1556 {
1557 hddLog(VOS_TRACE_LEVEL_ERROR,
1558 "%s: Invalid Channel [%d]", __func__, channel);
1559 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001560 }
1561 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301562 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301564 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1565 valid_ch, &num_ch))
1566 {
1567 hddLog(VOS_TRACE_LEVEL_ERROR,
1568 "%s: failed to get valid channel list", __func__);
1569 return VOS_STATUS_E_FAILURE;
1570 }
1571 for (indx = 0; indx < num_ch; indx++)
1572 {
1573 if (channel == valid_ch[indx])
1574 {
1575 break;
1576 }
1577 }
1578
1579 if (indx >= num_ch)
1580 {
1581 hddLog(VOS_TRACE_LEVEL_ERROR,
1582 "%s: Invalid Channel [%d]", __func__, channel);
1583 return VOS_STATUS_E_FAILURE;
1584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 }
1586 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301587
Jeff Johnson295189b2012-06-20 16:38:30 -07001588}
1589
Viral Modi3a32cc52013-02-08 11:14:52 -08001590/**
1591 * FUNCTION: wlan_hdd_cfg80211_set_channel
1592 * This function is used to set the channel number
1593 */
1594static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1595 struct ieee80211_channel *chan,
1596 enum nl80211_channel_type channel_type
1597 )
1598{
1599 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001600 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001601 hdd_adapter_t *pAdapter = NULL;
1602 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301603 hdd_context_t *pHddCtx;
1604 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001605
1606 ENTER();
1607
1608 if( NULL == dev )
1609 {
1610 hddLog(VOS_TRACE_LEVEL_ERROR,
1611 "%s: Called with dev = NULL.\n", __func__);
1612 return -ENODEV;
1613 }
1614 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1615
1616 hddLog(VOS_TRACE_LEVEL_INFO,
1617 "%s: device_mode = %d freq = %d \n",__func__,
1618 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301619
1620 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1621 status = wlan_hdd_validate_context(pHddCtx);
1622
1623 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001624 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301625 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1626 "%s: HDD context is not valid", __func__);
1627 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001628 }
1629
1630 /*
1631 * Do freq to chan conversion
1632 * TODO: for 11a
1633 */
1634
1635 channel = ieee80211_frequency_to_channel(freq);
1636
1637 /* Check freq range */
1638 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1639 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1640 {
1641 hddLog(VOS_TRACE_LEVEL_ERROR,
1642 "%s: Channel [%d] is outside valid range from %d to %d\n",
1643 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1644 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1645 return -EINVAL;
1646 }
1647
1648 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1649
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301650 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1651 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001652 {
1653 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1654 {
1655 hddLog(VOS_TRACE_LEVEL_ERROR,
1656 "%s: Invalid Channel [%d] \n", __func__, channel);
1657 return -EINVAL;
1658 }
1659 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1660 "%s: set channel to [%d] for device mode =%d",
1661 __func__, channel,pAdapter->device_mode);
1662 }
1663 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001664 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001665 )
1666 {
1667 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1668 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1669 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1670
1671 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1672 {
1673 /* Link is up then return cant set channel*/
1674 hddLog( VOS_TRACE_LEVEL_ERROR,
1675 "%s: IBSS Associated, can't set the channel\n", __func__);
1676 return -EINVAL;
1677 }
1678
1679 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1680 pHddStaCtx->conn_info.operationChannel = channel;
1681 pRoamProfile->ChannelInfo.ChannelList =
1682 &pHddStaCtx->conn_info.operationChannel;
1683 }
1684 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001685 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001686 )
1687 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301688 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1689 {
1690 if(VOS_STATUS_SUCCESS !=
1691 wlan_hdd_validate_operation_channel(pAdapter,channel))
1692 {
1693 hddLog(VOS_TRACE_LEVEL_ERROR,
1694 "%s: Invalid Channel [%d] \n", __func__, channel);
1695 return -EINVAL;
1696 }
1697 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1698 }
1699 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001700 {
1701 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1702
1703 /* If auto channel selection is configured as enable/ 1 then ignore
1704 channel set by supplicant
1705 */
1706 if ( cfg_param->apAutoChannelSelection )
1707 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301708 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1709 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001710 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1711 "%s: set channel to auto channel (0) for device mode =%d",
1712 __func__, pAdapter->device_mode);
1713 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301714 else
1715 {
1716 if(VOS_STATUS_SUCCESS !=
1717 wlan_hdd_validate_operation_channel(pAdapter,channel))
1718 {
1719 hddLog(VOS_TRACE_LEVEL_ERROR,
1720 "%s: Invalid Channel [%d] \n", __func__, channel);
1721 return -EINVAL;
1722 }
1723 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1724 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001725 }
1726 }
1727 else
1728 {
1729 hddLog(VOS_TRACE_LEVEL_FATAL,
1730 "%s: Invalid device mode failed to set valid channel", __func__);
1731 return -EINVAL;
1732 }
1733 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301734 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001735}
1736
Jeff Johnson295189b2012-06-20 16:38:30 -07001737#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1738static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1739 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001740#else
1741static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1742 struct cfg80211_beacon_data *params,
1743 const u8 *ssid, size_t ssid_len,
1744 enum nl80211_hidden_ssid hidden_ssid)
1745#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001746{
1747 tsap_Config_t *pConfig;
1748 beacon_data_t *pBeacon = NULL;
1749 struct ieee80211_mgmt *pMgmt_frame;
1750 v_U8_t *pIe=NULL;
1751 v_U16_t capab_info;
1752 eCsrAuthType RSNAuthType;
1753 eCsrEncryptionType RSNEncryptType;
1754 eCsrEncryptionType mcRSNEncryptType;
1755 int status = VOS_STATUS_SUCCESS;
1756 tpWLAN_SAPEventCB pSapEventCallback;
1757 hdd_hostapd_state_t *pHostapdState;
1758 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1759 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301760 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 struct qc_mac_acl_entry *acl_entry = NULL;
1762 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001763 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001764
1765 ENTER();
1766
1767 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1768
1769 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1770
1771 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1772
1773 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1774
1775 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1776
1777 //channel is already set in the set_channel Call back
1778 //pConfig->channel = pCommitConfig->channel;
1779
1780 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301781 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1783
1784 pConfig->dtim_period = pBeacon->dtim_period;
1785
1786 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1787 pConfig->dtim_period);
1788
1789
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001790 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001791 {
1792 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 WLAN_EID_COUNTRY);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001794 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001795 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001796 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001797 pConfig->ieee80211d = 1;
1798 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1799 sme_setRegInfo(hHal, pConfig->countryCode);
1800 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001801 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001802 else
1803 {
1804 pConfig->ieee80211d = 0;
1805 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301806 /*
1807 * If auto channel is configured i.e. channel is 0,
1808 * so skip channel validation.
1809 */
1810 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1811 {
1812 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1813 {
1814 hddLog(VOS_TRACE_LEVEL_ERROR,
1815 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1816 return -EINVAL;
1817 }
1818 }
1819 else
1820 {
1821 if(1 != pHddCtx->is_dynamic_channel_range_set)
1822 {
1823 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1824 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1825 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1826 }
1827 pHddCtx->is_dynamic_channel_range_set = 0;
1828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001830 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 {
1832 pConfig->ieee80211d = 0;
1833 }
1834 pConfig->authType = eSAP_AUTO_SWITCH;
1835
1836 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301837
1838 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1840
1841 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1842
1843 /*Set wps station to configured*/
1844 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1845
1846 if(pIe)
1847 {
1848 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1849 {
1850 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1851 return -EINVAL;
1852 }
1853 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1854 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001855 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 /* Check 15 bit of WPS IE as it contain information for wps state
1857 * WPS state
1858 */
1859 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1860 {
1861 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1862 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1863 {
1864 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1865 }
1866 }
1867 }
1868 else
1869 {
1870 pConfig->wps_state = SAP_WPS_DISABLED;
1871 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301872 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001873
1874 pConfig->RSNWPAReqIELength = 0;
1875 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301876 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 WLAN_EID_RSN);
1878 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301879 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1881 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1882 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301883 /* The actual processing may eventually be more extensive than
1884 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 * by the app.
1886 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301887 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001888 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1889 &RSNEncryptType,
1890 &mcRSNEncryptType,
1891 &RSNAuthType,
1892 pConfig->pRSNWPAReqIE[1]+2,
1893 pConfig->pRSNWPAReqIE );
1894
1895 if( VOS_STATUS_SUCCESS == status )
1896 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301897 /* Now copy over all the security attributes you have
1898 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 * */
1900 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1901 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1902 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1903 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301904 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001905 "EncryptionType = %d mcEncryptionType = %d\n"),
1906 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1907 }
1908 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301909
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1911 pBeacon->tail, pBeacon->tail_len);
1912
1913 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1914 {
1915 if (pConfig->pRSNWPAReqIE)
1916 {
1917 /*Mixed mode WPA/WPA2*/
1918 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1919 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1920 }
1921 else
1922 {
1923 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1924 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1925 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301926 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1928 &RSNEncryptType,
1929 &mcRSNEncryptType,
1930 &RSNAuthType,
1931 pConfig->pRSNWPAReqIE[1]+2,
1932 pConfig->pRSNWPAReqIE );
1933
1934 if( VOS_STATUS_SUCCESS == status )
1935 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301936 /* Now copy over all the security attributes you have
1937 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001938 * */
1939 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1940 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1941 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1942 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301943 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 "EncryptionType = %d mcEncryptionType = %d\n"),
1945 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1946 }
1947 }
1948 }
1949
Jeff Johnson4416a782013-03-25 14:17:50 -07001950 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1951 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1952 return -EINVAL;
1953 }
1954
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1956
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001957#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 if (params->ssid != NULL)
1959 {
1960 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1961 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1962 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1963 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1964 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001965#else
1966 if (ssid != NULL)
1967 {
1968 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1969 pConfig->SSIDinfo.ssid.length = ssid_len;
1970 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1971 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1972 }
1973#endif
1974
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301975 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301977
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 /* default value */
1979 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1980 pConfig->num_accept_mac = 0;
1981 pConfig->num_deny_mac = 0;
1982
1983 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1984 pBeacon->tail, pBeacon->tail_len);
1985
1986 /* pIe for black list is following form:
1987 type : 1 byte
1988 length : 1 byte
1989 OUI : 4 bytes
1990 acl type : 1 byte
1991 no of mac addr in black list: 1 byte
1992 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301993 */
1994 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001995 {
1996 pConfig->SapMacaddr_acl = pIe[6];
1997 pConfig->num_deny_mac = pIe[7];
1998 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
1999 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302000 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2001 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2003 for (i = 0; i < pConfig->num_deny_mac; i++)
2004 {
2005 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2006 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002008 }
2009 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2010 pBeacon->tail, pBeacon->tail_len);
2011
2012 /* pIe for white list is following form:
2013 type : 1 byte
2014 length : 1 byte
2015 OUI : 4 bytes
2016 acl type : 1 byte
2017 no of mac addr in white list: 1 byte
2018 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302019 */
2020 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 {
2022 pConfig->SapMacaddr_acl = pIe[6];
2023 pConfig->num_accept_mac = pIe[7];
2024 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
2025 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302026 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2027 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2029 for (i = 0; i < pConfig->num_accept_mac; i++)
2030 {
2031 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2032 acl_entry++;
2033 }
2034 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302035
Jeff Johnson295189b2012-06-20 16:38:30 -07002036 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2037
Jeff Johnsone7245742012-09-05 17:12:55 -07002038#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002039 /* Overwrite the hostapd setting for HW mode only for 11ac.
2040 * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini .
2041 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */
2042 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2043 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302044 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002045 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
2046 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002047 {
2048 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002049
2050 /* Disable VHT support in 2.4 GHz band */
2051 if (pConfig->channel <= 14 &&
2052 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2053 {
2054 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2055 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002056 }
2057#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302058
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002059 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2060 {
2061 sme_SelectCBMode(hHal,
2062 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2063 pConfig->channel);
2064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 // ht_capab is not what the name conveys,this is used for protection bitmap
2066 pConfig->ht_capab =
2067 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2068
2069 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2070 {
2071 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2072 return -EINVAL;
2073 }
2074
2075 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302076 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2078 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302079 pConfig->obssProtEnabled =
2080 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002081
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302082 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302084 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
2086 (int)pConfig->channel);
2087 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302088 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
2089 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302091 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
2093 pConfig->protEnabled, pConfig->obssProtEnabled);
2094
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302095 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 {
2097 //Bss already started. just return.
2098 //TODO Probably it should update some beacon params.
2099 hddLog( LOGE, "Bss Already started...Ignore the request");
2100 EXIT();
2101 return 0;
2102 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302103
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 pConfig->persona = pHostapdAdapter->device_mode;
2105
2106 pSapEventCallback = hdd_hostapd_SAPEventCB;
2107 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2108 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2109 {
2110 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2111 return -EINVAL;
2112 }
2113
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302114 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002115 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2116
2117 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302118
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302120 {
2121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 ("ERROR: HDD vos wait for single_event failed!!\n"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002123 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 VOS_ASSERT(0);
2125 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302126
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 //Succesfully started Bss update the state bit.
2128 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2129
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002130#ifdef WLAN_FEATURE_P2P_DEBUG
2131 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2132 {
2133 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2134 {
2135 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2136 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002137 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002138 }
2139 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2140 {
2141 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2142 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002143 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002144 }
2145 }
2146#endif
2147
Jeff Johnson295189b2012-06-20 16:38:30 -07002148 pHostapdState->bCommit = TRUE;
2149 EXIT();
2150
2151 return 0;
2152}
2153
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002154#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302155static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2156 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002157 struct beacon_parameters *params)
2158{
2159 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302160 hdd_context_t *pHddCtx;
2161 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002162
2163 ENTER();
2164
2165 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
2166
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302167 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2168 status = wlan_hdd_validate_context(pHddCtx);
2169
2170 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002171 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302172 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2173 "%s: HDD context is not valid", __func__);
2174 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002175 }
2176
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302177 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002178 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 )
2180 {
2181 beacon_data_t *old,*new;
2182
2183 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302184
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 if (old)
2186 return -EALREADY;
2187
2188 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2189
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302190 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 {
2192 hddLog(VOS_TRACE_LEVEL_FATAL,
2193 "%s:Error!!! Allocating the new beacon\n",__func__);
2194 return -EINVAL;
2195 }
2196
2197 pAdapter->sessionCtx.ap.beacon = new;
2198
2199 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2200 }
2201
2202 EXIT();
2203 return status;
2204}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302205
2206static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 struct net_device *dev,
2208 struct beacon_parameters *params)
2209{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302210 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302211 hdd_context_t *pHddCtx;
2212 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002213
2214 ENTER();
2215
2216 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2217 __func__,pAdapter->device_mode);
2218
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302219 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2220 status = wlan_hdd_validate_context(pHddCtx);
2221
2222 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002223 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302224 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2225 "%s: HDD context is not valid", __func__);
2226 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002227 }
2228
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302229 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302231 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 {
2233 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302234
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302236
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 if (!old)
2238 return -ENOENT;
2239
2240 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2241
2242 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302243 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 "%s: Error!!! Allocating the new beacon\n",__func__);
2245 return -EINVAL;
2246 }
2247
2248 pAdapter->sessionCtx.ap.beacon = new;
2249
2250 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2251 }
2252
2253 EXIT();
2254 return status;
2255}
2256
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002257#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2258
2259#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002260static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2261 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002262#else
2263static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2264 struct net_device *dev)
2265#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002266{
2267 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002268 hdd_context_t *pHddCtx = NULL;
2269 hdd_scaninfo_t *pScanInfo = NULL;
2270 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302271 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002272
2273 ENTER();
2274
2275 if (NULL == pAdapter)
2276 {
2277 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002278 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 return -ENODEV;
2280 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002281
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302282 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2283 status = wlan_hdd_validate_context(pHddCtx);
2284
2285 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002286 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302287 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2288 "%s: HDD context is not valid", __func__);
2289 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002290 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002291
2292 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2293 if (NULL == staAdapter)
2294 {
2295 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2296 if (NULL == staAdapter)
2297 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302298 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002299 "%s: HDD adapter context is Null", __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002300 return -ENODEV;
2301 }
2302 }
2303
2304 pScanInfo = &pHddCtx->scan_info;
2305
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2307 __func__,pAdapter->device_mode);
2308
Jeff Johnsone7245742012-09-05 17:12:55 -07002309 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
2310 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002311 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05302312 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002313 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002314 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002315 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2316 if (!status)
2317 {
2318 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson902c9832012-12-10 14:28:09 -08002319 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002320 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002321 VOS_ASSERT(pScanInfo->mScanPending);
2322 return 0;
2323 }
2324 }
2325
Jeff Johnson295189b2012-06-20 16:38:30 -07002326 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 )
2329 {
2330 beacon_data_t *old;
2331
2332 old = pAdapter->sessionCtx.ap.beacon;
2333
2334 if (!old)
2335 return -ENOENT;
2336
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002338
2339 mutex_lock(&pHddCtx->sap_lock);
2340 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2341 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002342 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 {
2344 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2345
2346 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2347
2348 if (!VOS_IS_STATUS_SUCCESS(status))
2349 {
2350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2351 ("ERROR: HDD vos wait for single_event failed!!\n"));
2352 VOS_ASSERT(0);
2353 }
2354 }
2355 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2356 }
2357 mutex_unlock(&pHddCtx->sap_lock);
2358
2359 if(status != VOS_STATUS_SUCCESS)
2360 {
2361 hddLog(VOS_TRACE_LEVEL_FATAL,
2362 "%s:Error!!! Stopping the BSS\n",__func__);
2363 return -EINVAL;
2364 }
2365
Jeff Johnson4416a782013-03-25 14:17:50 -07002366 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2368 ==eHAL_STATUS_FAILURE)
2369 {
2370 hddLog(LOGE,
2371 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2372 }
2373
Jeff Johnson4416a782013-03-25 14:17:50 -07002374 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2376 eANI_BOOLEAN_FALSE) )
2377 {
2378 hddLog(LOGE,
2379 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2380 }
2381
2382 // Reset WNI_CFG_PROBE_RSP Flags
2383 wlan_hdd_reset_prob_rspies(pAdapter);
2384
2385 pAdapter->sessionCtx.ap.beacon = NULL;
2386 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002387#ifdef WLAN_FEATURE_P2P_DEBUG
2388 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2389 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2390 {
2391 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2392 "GO got removed");
2393 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2394 }
2395#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002396 }
2397 EXIT();
2398 return status;
2399}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002400
2401#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2402
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302403static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2404 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002405 struct cfg80211_ap_settings *params)
2406{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302407 hdd_adapter_t *pAdapter;
2408 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302409 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002410
2411 ENTER();
2412
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302413 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002414 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302415 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302416 "%s: Device is Null", __func__);
2417 return -ENODEV;
2418 }
2419
2420 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2421 if (NULL == pAdapter)
2422 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302423 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302424 "%s: HDD adapter is Null", __func__);
2425 return -ENODEV;
2426 }
2427
2428 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2429 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302430 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302431 "%s: HDD adapter magic is invalid", __func__);
2432 return -ENODEV;
2433 }
2434
2435 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302436 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302437
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302438 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302439 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302440 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2441 "%s: HDD context is not valid", __func__);
2442 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302443 }
2444
2445 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2446 __func__, pAdapter->device_mode);
2447
2448 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002449 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002450 )
2451 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302452 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002453
2454 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302455
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002456 if (old)
2457 return -EALREADY;
2458
2459 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2460
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302461 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002462 {
2463 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302464 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002465 return -EINVAL;
2466 }
2467 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002468#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002469 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2470#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2471 params->channel, params->channel_type);
2472#else
2473 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2474#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002475#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002476 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2477 params->ssid_len, params->hidden_ssid);
2478 }
2479
2480 EXIT();
2481 return status;
2482}
2483
2484
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302485static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002486 struct net_device *dev,
2487 struct cfg80211_beacon_data *params)
2488{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302489 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302490 hdd_context_t *pHddCtx;
2491 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002492
2493 ENTER();
2494
2495 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2496 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302497
2498 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2499 status = wlan_hdd_validate_context(pHddCtx);
2500
2501 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002502 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302503 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2504 "%s: HDD context is not valid", __func__);
2505 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002506 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002507
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302508 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002509 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302510 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002511 {
2512 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302513
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002514 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302515
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002516 if (!old)
2517 return -ENOENT;
2518
2519 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2520
2521 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302522 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002523 "%s: Error!!! Allocating the new beacon\n",__func__);
2524 return -EINVAL;
2525 }
2526
2527 pAdapter->sessionCtx.ap.beacon = new;
2528
2529 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2530 }
2531
2532 EXIT();
2533 return status;
2534}
2535
2536#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2537
Jeff Johnson295189b2012-06-20 16:38:30 -07002538
2539static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2540 struct net_device *dev,
2541 struct bss_parameters *params)
2542{
2543 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2544
2545 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302546
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2548 __func__,pAdapter->device_mode);
2549
2550 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002551 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302552 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002553 {
2554 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2555 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302556 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 {
2558 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002560 }
2561
2562 EXIT();
2563 return 0;
2564}
2565
2566/*
2567 * FUNCTION: wlan_hdd_cfg80211_change_iface
2568 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2569 */
2570int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2571 struct net_device *ndev,
2572 enum nl80211_iftype type,
2573 u32 *flags,
2574 struct vif_params *params
2575 )
2576{
2577 struct wireless_dev *wdev;
2578 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2579 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002580 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 tCsrRoamProfile *pRoamProfile = NULL;
2582 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302583 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 eMib_dot11DesiredBssType connectedBssType;
2585 VOS_STATUS status;
2586
2587 ENTER();
2588
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302589 status = wlan_hdd_validate_context(pHddCtx);
2590
2591 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302593 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2594 "%s: HDD context is not valid", __func__);
2595 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 }
2597
2598 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2599 __func__, pAdapter->device_mode);
2600
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302601 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 wdev = ndev->ieee80211_ptr;
2603
2604#ifdef WLAN_BTAMP_FEATURE
2605 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2606 (NL80211_IFTYPE_ADHOC == type)||
2607 (NL80211_IFTYPE_AP == type)||
2608 (NL80211_IFTYPE_P2P_GO == type))
2609 {
2610 pHddCtx->isAmpAllowed = VOS_FALSE;
2611 // stop AMP traffic
2612 status = WLANBAP_StopAmp();
2613 if(VOS_STATUS_SUCCESS != status )
2614 {
2615 pHddCtx->isAmpAllowed = VOS_TRUE;
2616 hddLog(VOS_TRACE_LEVEL_FATAL,
2617 "%s: Failed to stop AMP", __func__);
2618 return -EINVAL;
2619 }
2620 }
2621#endif //WLAN_BTAMP_FEATURE
2622 /* Reset the current device mode bit mask*/
2623 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2624
2625 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002627 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 )
2629 {
2630 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2631 pRoamProfile = &pWextState->roamProfile;
2632 LastBSSType = pRoamProfile->BSSType;
2633
2634 switch (type)
2635 {
2636 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002638 hddLog(VOS_TRACE_LEVEL_INFO,
2639 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2640 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002641#ifdef WLAN_FEATURE_11AC
2642 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2643 {
2644 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2645 }
2646#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302647 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002648 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002650 //Check for sub-string p2p to confirm its a p2p interface
2651 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302652 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002653 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2654 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2655 }
2656 else
2657 {
2658 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002660 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302661#ifdef FEATURE_WLAN_TDLS
2662 /* The open adapter for the p2p shall skip initializations in
2663 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2664 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2665 * tdls_init when the change_iface sets the device mode to
2666 * WLAN_HDD_P2P_CLIENT.
2667 */
2668
2669 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2670 {
2671 if (0 != wlan_hdd_tdls_init (pAdapter))
2672 {
2673 return -EINVAL;
2674 }
2675 }
2676#endif
2677
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 break;
2679 case NL80211_IFTYPE_ADHOC:
2680 hddLog(VOS_TRACE_LEVEL_INFO,
2681 "%s: setting interface Type to ADHOC", __func__);
2682 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2683 pRoamProfile->phyMode =
2684 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002685 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 wdev->iftype = type;
2687 break;
2688
2689 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 {
2692 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2693 "%s: setting interface Type to %s", __func__,
2694 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2695
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002696 //Cancel any remain on channel for GO mode
2697 if (NL80211_IFTYPE_P2P_GO == type)
2698 {
2699 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2700 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002701 if (NL80211_IFTYPE_AP == type)
2702 {
2703 /* As Loading WLAN Driver one interface being created for p2p device
2704 * address. This will take one HW STA and the max number of clients
2705 * that can connect to softAP will be reduced by one. so while changing
2706 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2707 * interface as it is not required in SoftAP mode.
2708 */
2709
2710 // Get P2P Adapter
2711 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2712
2713 if (pP2pAdapter)
2714 {
2715 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2716 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2717 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2718 }
2719 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302720#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07002721
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302722 /* A Mutex Lock is introduced while changing the mode to
2723 * protect the concurrent access for the Adapters by TDLS
2724 * module.
2725 */
2726 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2727 {
2728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2729 "%s: unable to lock list", __func__);
2730 return -EINVAL;
2731 }
2732#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 //De-init the adapter.
2734 hdd_stop_adapter( pHddCtx, pAdapter );
2735 hdd_deinit_adapter( pHddCtx, pAdapter );
2736 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2738 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302739#ifdef FEATURE_WLAN_TDLS
2740 mutex_unlock(&pHddCtx->tdls_lock);
2741#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002742
2743 //Disable BMPS and IMPS if enabled
2744 //before starting Go
2745 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2746 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302747 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002748 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2749 {
2750 //Fail to Exit BMPS
2751 VOS_ASSERT(0);
2752 }
2753 }
2754
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002755 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2756 (pConfig->apRandomBssidEnabled))
2757 {
2758 /* To meet Android requirements create a randomized
2759 MAC address of the form 02:1A:11:Fx:xx:xx */
2760 get_random_bytes(&ndev->dev_addr[3], 3);
2761 ndev->dev_addr[0] = 0x02;
2762 ndev->dev_addr[1] = 0x1A;
2763 ndev->dev_addr[2] = 0x11;
2764 ndev->dev_addr[3] |= 0xF0;
2765 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2766 VOS_MAC_ADDR_SIZE);
2767 pr_info("wlan: Generated HotSpot BSSID "
2768 "%02x:%02x:%02x:%02x:%02x:%02x\n",
2769 ndev->dev_addr[0],
2770 ndev->dev_addr[1],
2771 ndev->dev_addr[2],
2772 ndev->dev_addr[3],
2773 ndev->dev_addr[4],
2774 ndev->dev_addr[5]);
2775 }
2776
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 hdd_set_ap_ops( pAdapter->dev );
2778
2779 status = hdd_init_ap_mode(pAdapter);
2780 if(status != VOS_STATUS_SUCCESS)
2781 {
2782 hddLog(VOS_TRACE_LEVEL_FATAL,
2783 "%s: Error initializing the ap mode", __func__);
2784 return -EINVAL;
2785 }
2786 hdd_set_conparam(1);
2787
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 /*interface type changed update in wiphy structure*/
2789 if(wdev)
2790 {
2791 wdev->iftype = type;
2792 pHddCtx->change_iface = type;
2793 }
2794 else
2795 {
2796 hddLog(VOS_TRACE_LEVEL_ERROR,
2797 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2798 return -EINVAL;
2799 }
2800 goto done;
2801 }
2802
2803 default:
2804 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2805 __func__);
2806 return -EOPNOTSUPP;
2807 }
2808 }
2809 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 )
2812 {
2813 switch(type)
2814 {
2815 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302818#ifdef FEATURE_WLAN_TDLS
2819
2820 /* A Mutex Lock is introduced while changing the mode to
2821 * protect the concurrent access for the Adapters by TDLS
2822 * module.
2823 */
2824 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2825 {
2826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2827 "%s: unable to lock list", __func__);
2828 return -EINVAL;
2829 }
2830#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002831 hdd_stop_adapter( pHddCtx, pAdapter );
2832 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002834 //Check for sub-string p2p to confirm its a p2p interface
2835 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002836 {
2837 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2838 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2839 }
2840 else
2841 {
2842 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002843 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 hdd_set_conparam(0);
2846 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2848 hdd_set_station_ops( pAdapter->dev );
2849 status = hdd_init_station_mode( pAdapter );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302850#ifdef FEATURE_WLAN_TDLS
2851 mutex_unlock(&pHddCtx->tdls_lock);
2852#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 if( VOS_STATUS_SUCCESS != status )
2854 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002855 /* In case of JB, for P2P-GO, only change interface will be called,
2856 * This is the right place to enable back bmps_imps()
2857 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302858 if (pHddCtx->hdd_wlan_suspended)
2859 {
2860 hdd_set_pwrparams(pHddCtx);
2861 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002862 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 goto done;
2864 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2868 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 goto done;
2870 default:
2871 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2872 __func__);
2873 return -EOPNOTSUPP;
2874
2875 }
2876
2877 }
2878 else
2879 {
2880 return -EOPNOTSUPP;
2881 }
2882
2883
2884 if(pRoamProfile)
2885 {
2886 if ( LastBSSType != pRoamProfile->BSSType )
2887 {
2888 /*interface type changed update in wiphy structure*/
2889 wdev->iftype = type;
2890
2891 /*the BSS mode changed, We need to issue disconnect
2892 if connected or in IBSS disconnect state*/
2893 if ( hdd_connGetConnectedBssType(
2894 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2895 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2896 {
2897 /*need to issue a disconnect to CSR.*/
2898 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2899 if( eHAL_STATUS_SUCCESS ==
2900 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2901 pAdapter->sessionId,
2902 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2903 {
2904 wait_for_completion_interruptible_timeout(
2905 &pAdapter->disconnect_comp_var,
2906 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2907 }
2908 }
2909 }
2910 }
2911
2912done:
2913 /*set bitmask based on updated value*/
2914 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002915
2916 /* Only STA mode support TM now
2917 * all other mode, TM feature should be disabled */
2918 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2919 (~VOS_STA & pHddCtx->concurrency_mode) )
2920 {
2921 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2922 }
2923
Jeff Johnson295189b2012-06-20 16:38:30 -07002924#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302925 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002926 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2927 {
2928 //we are ok to do AMP
2929 pHddCtx->isAmpAllowed = VOS_TRUE;
2930 }
2931#endif //WLAN_BTAMP_FEATURE
2932 EXIT();
2933 return 0;
2934}
2935
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002936#ifdef FEATURE_WLAN_TDLS
2937static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2938 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2939{
2940 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2941 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2942 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002943 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002944
2945 ENTER();
2946
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302947 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002948 {
2949 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2950 "Invalid arguments");
2951 return -EINVAL;
2952 }
Hoonki Lee27511902013-03-14 18:19:06 -07002953
2954 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
2955 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
2956 {
2957 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2958 "%s: TDLS mode is disabled OR not enabled in FW."
2959 MAC_ADDRESS_STR " Request declined.",
2960 __func__, MAC_ADDR_ARRAY(mac));
2961 return -ENOTSUPP;
2962 }
2963
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002964 if (pHddCtx->isLogpInProgress)
2965 {
2966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2967 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07002968 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002969 return -EBUSY;
2970 }
2971
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302972 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002973
2974 if ( NULL == pTdlsPeer ) {
2975 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2976 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
2977 __func__, MAC_ADDR_ARRAY(mac), update);
2978 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002979 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002980
2981 /* in add station, we accept existing valid staId if there is */
2982 if ((0 == update) &&
2983 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
2984 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002985 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002986 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002987 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002988 " link_status %d. staId %d. add station ignored.",
2989 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
2990 return 0;
2991 }
2992 /* in change station, we accept only when staId is valid */
2993 if ((1 == update) &&
2994 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
2995 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
2996 {
2997 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2998 "%s: " MAC_ADDRESS_STR
2999 " link status %d. staId %d. change station %s.",
3000 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
3001 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
3002 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003003 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003004
3005 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303006 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003007 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003008 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3009 "%s: " MAC_ADDRESS_STR
3010 " TDLS setup is ongoing. Request declined.",
3011 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003012 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003013 }
3014
3015 /* first to check if we reached to maximum supported TDLS peer.
3016 TODO: for now, return -EPERM looks working fine,
3017 but need to check if any other errno fit into this category.*/
3018 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
3019 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003020 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3021 "%s: " MAC_ADDRESS_STR
3022 " TDLS Max peer already connected. Request declined.",
3023 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003024 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003025 }
3026 else
3027 {
3028 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303029 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003030 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003031 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003032 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3033 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3034 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003035 return -EPERM;
3036 }
3037 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003038 if (0 == update)
3039 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003040
Jeff Johnsond75fe012013-04-06 10:53:06 -07003041 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303042 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003043 {
3044 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3045 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003046 if(StaParams->htcap_present)
3047 {
3048 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3049 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3050 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3051 "ht_capa->extended_capabilities: %0x",
3052 StaParams->HTCap.extendedHtCapInfo);
3053 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003054 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3055 "params->capability: %0x",StaParams->capability);
3056 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3057 "params->ext_capab_len: %0x",StaParams->extn_capability);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003058 if(StaParams->vhtcap_present)
3059 {
3060 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3061 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3062 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3063 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3064 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003065 {
3066 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003067 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003068 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3069 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3070 "[%d]: %x ", i, StaParams->supported_rates[i]);
3071 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003072 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303073 else if ((1 == update) && (NULL == StaParams))
3074 {
3075 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3076 "%s : update is true, but staParams is NULL. Error!", __func__);
3077 return -EPERM;
3078 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003079
3080 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3081
3082 if (!update)
3083 {
3084 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3085 pAdapter->sessionId, mac);
3086 }
3087 else
3088 {
3089 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3090 pAdapter->sessionId, mac, StaParams);
3091 }
3092
3093 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
3094 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3095
3096 if (!status)
3097 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003099 "%s: timeout waiting for tdls add station indication",
3100 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003101 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003102 }
3103 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3104 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003106 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003107 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003108 }
3109
3110 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003111
3112error:
3113 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3114 return -EPERM;
3115
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003116}
3117#endif
3118
Jeff Johnson295189b2012-06-20 16:38:30 -07003119static int wlan_hdd_change_station(struct wiphy *wiphy,
3120 struct net_device *dev,
3121 u8 *mac,
3122 struct station_parameters *params)
3123{
3124 VOS_STATUS status = VOS_STATUS_SUCCESS;
3125 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303126 hdd_context_t *pHddCtx;
3127 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003129#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003130 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003131 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003132#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003133 ENTER();
3134
Gopichand Nakkala29149562013-05-10 21:43:41 +05303135 if ((NULL == pAdapter))
3136 {
3137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3138 "invalid adapter ");
3139 return -EINVAL;
3140 }
3141
3142 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3143 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3144
3145 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3146 {
3147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3148 "invalid HDD state or HDD station context");
3149 return -EINVAL;
3150 }
3151
3152 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003153 {
3154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3155 "%s:LOGP in Progress. Ignore!!!", __func__);
3156 return -EAGAIN;
3157 }
3158
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3160
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003161 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3162 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003164 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303166 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 WLANTL_STA_AUTHENTICATED);
3168
Gopichand Nakkala29149562013-05-10 21:43:41 +05303169 if (status != VOS_STATUS_SUCCESS)
3170 {
3171 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3172 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3173 return -EINVAL;
3174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 }
3176 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003177 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3178 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303179#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003180 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3181 StaParams.capability = params->capability;
3182 StaParams.uapsd_queues = params->uapsd_queues;
3183 StaParams.max_sp = params->max_sp;
3184
3185 if (0 != params->ext_capab_len)
3186 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3187 sizeof(StaParams.extn_capability));
3188
3189 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003190 {
3191 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003192 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003193 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003194
3195 StaParams.supported_rates_len = params->supported_rates_len;
3196
3197 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3198 * The supported_rates array , for all the structures propogating till Add Sta
3199 * to the firmware has to be modified , if the supplicant (ieee80211) is
3200 * modified to send more rates.
3201 */
3202
3203 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3204 */
3205 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3206 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3207
3208 if (0 != StaParams.supported_rates_len) {
3209 int i = 0;
3210 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3211 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003212 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003213 "Supported Rates with Length %d", StaParams.supported_rates_len);
3214 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003215 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003216 "[%d]: %0x", i, StaParams.supported_rates[i]);
3217 }
3218
3219 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003220 {
3221 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003222 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003223 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003224
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003225 if (0 != params->ext_capab_len ) {
3226 /*Define A Macro : TODO Sunil*/
3227 if ((1<<4) & StaParams.extn_capability[3]) {
3228 isBufSta = 1;
3229 }
3230 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303231 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3232 params->max_sp, isBufSta);
3233 if (VOS_STATUS_SUCCESS != status) {
3234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3235 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3236 return -EINVAL;
3237 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003238 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3239
3240 if (VOS_STATUS_SUCCESS != status) {
3241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3242 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3243 return -EINVAL;
3244 }
3245 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003246#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303247 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003248 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 return status;
3250}
3251
3252/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 * FUNCTION: wlan_hdd_cfg80211_add_key
3254 * This function is used to initialize the key information
3255 */
3256#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003257static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 struct net_device *ndev,
3259 u8 key_index, bool pairwise,
3260 const u8 *mac_addr,
3261 struct key_params *params
3262 )
3263#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003264static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 struct net_device *ndev,
3266 u8 key_index, const u8 *mac_addr,
3267 struct key_params *params
3268 )
3269#endif
3270{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003271 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003272 tCsrRoamSetKey setKey;
3273 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303274 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003275 v_U32_t roamId= 0xFF;
3276 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 hdd_hostapd_state_t *pHostapdState;
3278 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003279 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303280 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003281
3282 ENTER();
3283
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303284 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3285 status = wlan_hdd_validate_context(pHddCtx);
3286
3287 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003288 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303289 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3290 "%s: HDD context is not valid", __func__);
3291 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003292 }
3293
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003294 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3295 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003296
3297 if (CSR_MAX_NUM_KEY <= key_index)
3298 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003299 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 key_index);
3301
3302 return -EINVAL;
3303 }
3304
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003305 if (CSR_MAX_KEY_LEN < params->key_len)
3306 {
3307 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3308 params->key_len);
3309
3310 return -EINVAL;
3311 }
3312
3313 hddLog(VOS_TRACE_LEVEL_INFO,
3314 "%s: called with key index = %d & key length %d",
3315 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003316
3317 /*extract key idx, key len and key*/
3318 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3319 setKey.keyId = key_index;
3320 setKey.keyLength = params->key_len;
3321 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3322
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003323 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 {
3325 case WLAN_CIPHER_SUITE_WEP40:
3326 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3327 break;
3328
3329 case WLAN_CIPHER_SUITE_WEP104:
3330 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3331 break;
3332
3333 case WLAN_CIPHER_SUITE_TKIP:
3334 {
3335 u8 *pKey = &setKey.Key[0];
3336 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3337
3338 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3339
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003340 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003341
3342 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003343 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 |--------------|----------|----------|
3345 <---16bytes---><--8bytes--><--8bytes-->
3346
3347 */
3348 /*Sme expects the 32 bytes key to be in the below order
3349
3350 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003351 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 |--------------|----------|----------|
3353 <---16bytes---><--8bytes--><--8bytes-->
3354 */
3355 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003356 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003357
3358 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003359 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003360
3361 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003362 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003363
3364
3365 break;
3366 }
3367
3368 case WLAN_CIPHER_SUITE_CCMP:
3369 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3370 break;
3371
3372#ifdef FEATURE_WLAN_WAPI
3373 case WLAN_CIPHER_SUITE_SMS4:
3374 {
3375 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3376 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3377 params->key, params->key_len);
3378 return 0;
3379 }
3380#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003381
Jeff Johnson295189b2012-06-20 16:38:30 -07003382#ifdef FEATURE_WLAN_CCX
3383 case WLAN_CIPHER_SUITE_KRK:
3384 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3385 break;
3386#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003387
3388#ifdef WLAN_FEATURE_11W
3389 case WLAN_CIPHER_SUITE_AES_CMAC:
3390 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003391 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003392#endif
3393
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 default:
3395 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu",
3396 __func__, params->cipher);
3397 return -EOPNOTSUPP;
3398 }
3399
3400 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3401 __func__, setKey.encType);
3402
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003403 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003404#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3405 (!pairwise)
3406#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003407 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003408#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003409 )
3410 {
3411 /* set group key*/
3412 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3413 "%s- %d: setting Broadcast key",
3414 __func__, __LINE__);
3415 setKey.keyDirection = eSIR_RX_ONLY;
3416 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3417 }
3418 else
3419 {
3420 /* set pairwise key*/
3421 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3422 "%s- %d: setting pairwise key",
3423 __func__, __LINE__);
3424 setKey.keyDirection = eSIR_TX_RX;
3425 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3426 }
3427 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3428 {
3429 setKey.keyDirection = eSIR_TX_RX;
3430 /*Set the group key*/
3431 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3432 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003433
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003434 if ( 0 != status )
3435 {
3436 hddLog(VOS_TRACE_LEVEL_ERROR,
3437 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3438 return -EINVAL;
3439 }
3440 /*Save the keys here and call sme_RoamSetKey for setting
3441 the PTK after peer joins the IBSS network*/
3442 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3443 &setKey, sizeof(tCsrRoamSetKey));
3444 return status;
3445 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303446 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3447 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3448 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003450 if( pHostapdState->bssState == BSS_START )
3451 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3453
3454 if ( status != eHAL_STATUS_SUCCESS )
3455 {
3456 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3457 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3458 __LINE__, status );
3459 }
3460 }
3461
3462 /* Saving WEP keys */
3463 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3464 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3465 {
3466 //Save the wep key in ap context. Issue setkey after the BSS is started.
3467 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3468 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3469 }
3470 else
3471 {
3472 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003473 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3475 }
3476 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003477 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3478 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 {
3480 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3481 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3482
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303483#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3484 if (!pairwise)
3485#else
3486 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3487#endif
3488 {
3489 /* set group key*/
3490 if (pHddStaCtx->roam_info.deferKeyComplete)
3491 {
3492 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3493 "%s- %d: Perform Set key Complete",
3494 __func__, __LINE__);
3495 hdd_PerformRoamSetKeyComplete(pAdapter);
3496 }
3497 }
3498
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3500
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003501 pWextState->roamProfile.Keys.defaultIndex = key_index;
3502
3503
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003504 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 params->key, params->key_len);
3506
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303507
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3509
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303510 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303512 __func__, setKey.peerMac[0], setKey.peerMac[1],
3513 setKey.peerMac[2], setKey.peerMac[3],
3514 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 setKey.keyDirection);
3516
3517 vos_status = wlan_hdd_check_ula_done(pAdapter);
3518
3519 if ( vos_status != VOS_STATUS_SUCCESS )
3520 {
3521 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3522 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3523 __LINE__, vos_status );
3524
3525 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3526
3527 return -EINVAL;
3528
3529 }
3530
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003531#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303532 /* The supplicant may attempt to set the PTK once pre-authentication
3533 is done. Save the key in the UMAC and include it in the ADD BSS
3534 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003535 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303536 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003537 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303538 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3539 "%s: Update PreAuth Key success", __func__);
3540 return 0;
3541 }
3542 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3543 {
3544 hddLog(VOS_TRACE_LEVEL_ERROR,
3545 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303546 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003547 }
3548#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003549
3550 /* issue set key request to SME*/
3551 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3552 pAdapter->sessionId, &setKey, &roamId );
3553
3554 if ( 0 != status )
3555 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303556 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3558 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3559 return -EINVAL;
3560 }
3561
3562
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303563 /* in case of IBSS as there was no information available about WEP keys during
3564 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003565 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303566 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3567 !( ( IW_AUTH_KEY_MGMT_802_1X
3568 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3570 )
3571 &&
3572 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3573 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3574 )
3575 )
3576 {
3577 setKey.keyDirection = eSIR_RX_ONLY;
3578 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3579
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303580 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303582 __func__, setKey.peerMac[0], setKey.peerMac[1],
3583 setKey.peerMac[2], setKey.peerMac[3],
3584 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003585 setKey.keyDirection);
3586
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303587 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 pAdapter->sessionId, &setKey, &roamId );
3589
3590 if ( 0 != status )
3591 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303592 hddLog(VOS_TRACE_LEVEL_ERROR,
3593 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003594 __func__, status);
3595 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3596 return -EINVAL;
3597 }
3598 }
3599 }
3600
3601 return 0;
3602}
3603
3604/*
3605 * FUNCTION: wlan_hdd_cfg80211_get_key
3606 * This function is used to get the key information
3607 */
3608#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303609static int wlan_hdd_cfg80211_get_key(
3610 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303612 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 const u8 *mac_addr, void *cookie,
3614 void (*callback)(void *cookie, struct key_params*)
3615 )
3616#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303617static int wlan_hdd_cfg80211_get_key(
3618 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 struct net_device *ndev,
3620 u8 key_index, const u8 *mac_addr, void *cookie,
3621 void (*callback)(void *cookie, struct key_params*)
3622 )
3623#endif
3624{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303625 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3627 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3628 struct key_params params;
3629
3630 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303631
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3633 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303634
Jeff Johnson295189b2012-06-20 16:38:30 -07003635 memset(&params, 0, sizeof(params));
3636
3637 if (CSR_MAX_NUM_KEY <= key_index)
3638 {
3639 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003641
3642 switch(pRoamProfile->EncryptionType.encryptionType[0])
3643 {
3644 case eCSR_ENCRYPT_TYPE_NONE:
3645 params.cipher = IW_AUTH_CIPHER_NONE;
3646 break;
3647
3648 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3649 case eCSR_ENCRYPT_TYPE_WEP40:
3650 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3651 break;
3652
3653 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3654 case eCSR_ENCRYPT_TYPE_WEP104:
3655 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3656 break;
3657
3658 case eCSR_ENCRYPT_TYPE_TKIP:
3659 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3660 break;
3661
3662 case eCSR_ENCRYPT_TYPE_AES:
3663 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3664 break;
3665
3666 default:
3667 params.cipher = IW_AUTH_CIPHER_NONE;
3668 break;
3669 }
3670
3671 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3672 params.seq_len = 0;
3673 params.seq = NULL;
3674 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3675 callback(cookie, &params);
3676 return 0;
3677}
3678
3679/*
3680 * FUNCTION: wlan_hdd_cfg80211_del_key
3681 * This function is used to delete the key information
3682 */
3683#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303684static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003685 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303686 u8 key_index,
3687 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 const u8 *mac_addr
3689 )
3690#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303691static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 struct net_device *ndev,
3693 u8 key_index,
3694 const u8 *mac_addr
3695 )
3696#endif
3697{
3698 int status = 0;
3699
3700 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303701 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 //it is observed that this is invalidating peer
3703 //key index whenever re-key is done. This is affecting data link.
3704 //It should be ok to ignore del_key.
3705#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303706 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3707 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3709 tCsrRoamSetKey setKey;
3710 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303711
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 ENTER();
3713
3714 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3715 __func__,pAdapter->device_mode);
3716
3717 if (CSR_MAX_NUM_KEY <= key_index)
3718 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303719 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 key_index);
3721
3722 return -EINVAL;
3723 }
3724
3725 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3726 setKey.keyId = key_index;
3727
3728 if (mac_addr)
3729 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3730 else
3731 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3732
3733 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3734
3735 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303737 )
3738 {
3739
3740 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3742 if( pHostapdState->bssState == BSS_START)
3743 {
3744 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303745
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 if ( status != eHAL_STATUS_SUCCESS )
3747 {
3748 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3749 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3750 __LINE__, status );
3751 }
3752 }
3753 }
3754 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303755 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 )
3757 {
3758 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3759
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303760 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3761
3762 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303764 __func__, setKey.peerMac[0], setKey.peerMac[1],
3765 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003766 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303767 if(pAdapter->sessionCtx.station.conn_info.connState ==
3768 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303770 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003771 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303772
Jeff Johnson295189b2012-06-20 16:38:30 -07003773 if ( 0 != status )
3774 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303775 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 "%s: sme_RoamSetKey failure, returned %d",
3777 __func__, status);
3778 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3779 return -EINVAL;
3780 }
3781 }
3782 }
3783#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003784 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 return status;
3786}
3787
3788/*
3789 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3790 * This function is used to set the default tx key index
3791 */
3792#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3793static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3794 struct net_device *ndev,
3795 u8 key_index,
3796 bool unicast, bool multicast)
3797#else
3798static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3799 struct net_device *ndev,
3800 u8 key_index)
3801#endif
3802{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303803 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303804 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303805 hdd_wext_state_t *pWextState;
3806 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303807 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003808
3809 ENTER();
3810
Gopichand Nakkala29149562013-05-10 21:43:41 +05303811 if ((NULL == pAdapter))
3812 {
3813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3814 "invalid adapter");
3815 return -EINVAL;
3816 }
3817
3818 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3819 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3820
3821 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3822 {
3823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3824 "invalid Wext state or HDD context");
3825 return -EINVAL;
3826 }
3827
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3829 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303830
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 if (CSR_MAX_NUM_KEY <= key_index)
3832 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303833 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003834 key_index);
3835
3836 return -EINVAL;
3837 }
3838
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303839 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3840 status = wlan_hdd_validate_context(pHddCtx);
3841
3842 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003843 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303844 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3845 "%s: HDD context is not valid", __func__);
3846 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003847 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303848
Jeff Johnson295189b2012-06-20 16:38:30 -07003849 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303851 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303853 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303855 (eCSR_ENCRYPT_TYPE_AES !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 pWextState->roamProfile.EncryptionType.encryptionType[0])
3857 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303858 {
3859 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303861
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 tCsrRoamSetKey setKey;
3863 v_U32_t roamId= 0xFF;
3864 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303865
3866 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303868
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 Keys->defaultIndex = (u8)key_index;
3870 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3871 setKey.keyId = key_index;
3872 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303873
3874 vos_mem_copy(&setKey.Key[0],
3875 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303877
Gopichand Nakkala29149562013-05-10 21:43:41 +05303878 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303879
3880 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 &pHddStaCtx->conn_info.bssId[0],
3882 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303883
Gopichand Nakkala29149562013-05-10 21:43:41 +05303884 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3885 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3886 eCSR_ENCRYPT_TYPE_WEP104)
3887 {
3888 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3889 even though ap is configured for WEP-40 encryption. In this canse the key length
3890 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3891 type(104) and switching encryption type to 40*/
3892 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3893 eCSR_ENCRYPT_TYPE_WEP40;
3894 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3895 eCSR_ENCRYPT_TYPE_WEP40;
3896 }
3897
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303898 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303900
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303902 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303904
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 if ( 0 != status )
3906 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303907 hddLog(VOS_TRACE_LEVEL_ERROR,
3908 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 status);
3910 return -EINVAL;
3911 }
3912 }
3913 }
3914
3915 /* In SoftAp mode setting key direction for default mode */
3916 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3917 {
3918 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3919 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3920 (eCSR_ENCRYPT_TYPE_AES !=
3921 pWextState->roamProfile.EncryptionType.encryptionType[0])
3922 )
3923 {
3924 /* Saving key direction for default key index to TX default */
3925 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3926 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3927 }
3928 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303929
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 return status;
3931}
3932
Jeff Johnson295189b2012-06-20 16:38:30 -07003933/*
3934 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3935 * This function is used to inform the BSS details to nl80211 interface.
3936 */
3937static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3938 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3939{
3940 struct net_device *dev = pAdapter->dev;
3941 struct wireless_dev *wdev = dev->ieee80211_ptr;
3942 struct wiphy *wiphy = wdev->wiphy;
3943 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3944 int chan_no;
3945 int ie_length;
3946 const char *ie;
3947 unsigned int freq;
3948 struct ieee80211_channel *chan;
3949 int rssi = 0;
3950 struct cfg80211_bss *bss = NULL;
3951
3952 ENTER();
3953
3954 if( NULL == pBssDesc )
3955 {
3956 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
3957 return bss;
3958 }
3959
3960 chan_no = pBssDesc->channelId;
3961 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
3962 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
3963
3964 if( NULL == ie )
3965 {
3966 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
3967 return bss;
3968 }
3969
3970#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
3971 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
3972 {
3973 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
3974 }
3975 else
3976 {
3977 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
3978 }
3979#else
3980 freq = ieee80211_channel_to_frequency(chan_no);
3981#endif
3982
3983 chan = __ieee80211_get_channel(wiphy, freq);
3984
3985 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
3986 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
3987 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
3988 if (bss == NULL)
3989 {
3990 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
3991
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303992 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
3993 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 pBssDesc->capabilityInfo,
3995 pBssDesc->beaconInterval, ie, ie_length,
3996 rssi, GFP_KERNEL ));
3997}
3998 else
3999 {
4000 return bss;
4001 }
4002}
4003
4004
4005
4006/*
4007 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4008 * This function is used to inform the BSS details to nl80211 interface.
4009 */
4010struct cfg80211_bss*
4011wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4012 tSirBssDescription *bss_desc
4013 )
4014{
4015 /*
4016 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4017 already exists in bss data base of cfg80211 for that particular BSS ID.
4018 Using cfg80211_inform_bss_frame to update the bss entry instead of
4019 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4020 now there is no possibility to get the mgmt(probe response) frame from PE,
4021 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4022 cfg80211_inform_bss_frame.
4023 */
4024 struct net_device *dev = pAdapter->dev;
4025 struct wireless_dev *wdev = dev->ieee80211_ptr;
4026 struct wiphy *wiphy = wdev->wiphy;
4027 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004028#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4029 qcom_ie_age *qie_age = NULL;
4030 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4031#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004033#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004034 const char *ie =
4035 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4036 unsigned int freq;
4037 struct ieee80211_channel *chan;
4038 struct ieee80211_mgmt *mgmt =
4039 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
4040 struct cfg80211_bss *bss_status = NULL;
4041 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4042 int rssi = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004043#ifdef WLAN_OPEN_SOURCE
4044 struct timespec ts;
4045#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004046
4047 ENTER();
4048
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004049 if (!mgmt)
4050 return NULL;
4051
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004053
4054#ifdef WLAN_OPEN_SOURCE
4055 /* Android does not want the timestamp from the frame.
4056 Instead it wants a monotonic increasing value */
4057 get_monotonic_boottime(&ts);
4058 mgmt->u.probe_resp.timestamp =
4059 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4060#else
4061 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4063 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004064
4065#endif
4066
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4068 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004069
4070#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4071 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4072 /* Assuming this is the last IE, copy at the end */
4073 ie_length -=sizeof(qcom_ie_age);
4074 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4075 qie_age->element_id = QCOM_VENDOR_IE_ID;
4076 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4077 qie_age->oui_1 = QCOM_OUI1;
4078 qie_age->oui_2 = QCOM_OUI2;
4079 qie_age->oui_3 = QCOM_OUI3;
4080 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4081 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4082#endif
4083
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304085 if (bss_desc->fProbeRsp)
4086 {
4087 mgmt->frame_control |=
4088 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4089 }
4090 else
4091 {
4092 mgmt->frame_control |=
4093 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004095
4096#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304097 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4099 {
4100 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4101 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304102 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4104
4105 {
4106 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4107 }
4108 else
4109 {
4110 kfree(mgmt);
4111 return NULL;
4112 }
4113#else
4114 freq = ieee80211_channel_to_frequency(chan_no);
4115#endif
4116 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004117 /*when the band is changed on the fly using the GUI, three things are done
4118 * 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)
4119 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4120 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4121 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4122 * and discards the channels correponding to previous band and calls back with zero bss results.
4123 * 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
4124 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4125 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4126 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4127 * So drop the bss and continue to next bss.
4128 */
4129 if(chan == NULL)
4130 {
4131 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004132 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004133 return NULL;
4134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004135 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304136 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004137 * */
4138 if (( eConnectionState_Associated ==
4139 pAdapter->sessionCtx.station.conn_info.connState ) &&
4140 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4141 pAdapter->sessionCtx.station.conn_info.bssId,
4142 WNI_CFG_BSSID_LEN)))
4143 {
4144 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4145 rssi = (pAdapter->rssi * 100);
4146 }
4147 else
4148 {
4149 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4150 }
4151
4152 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4153 frame_len, rssi, GFP_KERNEL);
4154 kfree(mgmt);
4155 return bss_status;
4156}
4157
4158/*
4159 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4160 * This function is used to update the BSS data base of CFG8011
4161 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304162struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 tCsrRoamInfo *pRoamInfo
4164 )
4165{
4166 tCsrRoamConnectedProfile roamProfile;
4167 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4168 struct cfg80211_bss *bss = NULL;
4169
4170 ENTER();
4171
4172 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4173 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4174
4175 if (NULL != roamProfile.pBssDesc)
4176 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304177 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 &roamProfile);
4179
4180 if (NULL == bss)
4181 {
4182 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4183 __func__);
4184 }
4185
4186 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4187 }
4188 else
4189 {
4190 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4191 __func__);
4192 }
4193 return bss;
4194}
4195
4196/*
4197 * FUNCTION: wlan_hdd_cfg80211_update_bss
4198 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304199static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4200 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304202{
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4204 tCsrScanResultInfo *pScanResult;
4205 eHalStatus status = 0;
4206 tScanResultHandle pResult;
4207 struct cfg80211_bss *bss_status = NULL;
4208
4209 ENTER();
4210
4211 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4212 {
4213 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
4214 return -EAGAIN;
4215 }
4216
4217 /*
4218 * start getting scan results and populate cgf80211 BSS database
4219 */
4220 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4221
4222 /* no scan results */
4223 if (NULL == pResult)
4224 {
4225 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4226 return status;
4227 }
4228
4229 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4230
4231 while (pScanResult)
4232 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304233 /*
4234 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4235 * entry already exists in bss data base of cfg80211 for that
4236 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4237 * bss entry instead of cfg80211_inform_bss, But this call expects
4238 * mgmt packet as input. As of now there is no possibility to get
4239 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 * ieee80211_mgmt(probe response) and passing to c
4241 * fg80211_inform_bss_frame.
4242 * */
4243
4244 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4245 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304246
Jeff Johnson295189b2012-06-20 16:38:30 -07004247
4248 if (NULL == bss_status)
4249 {
4250 hddLog(VOS_TRACE_LEVEL_INFO,
4251 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4252 }
4253 else
4254 {
Yue Maf49ba872013-08-19 12:04:25 -07004255 cfg80211_put_bss(
4256#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4257 wiphy,
4258#endif
4259 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004260 }
4261
4262 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4263 }
4264
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304265 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004266
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304267 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004268}
4269
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004270void
4271hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4272{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304273 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004274 "%02X:%02X:%02X:%02X:%02X:%02X\n",
4275 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
4276 macAddr[5]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004277} /****** end hddPrintMacAddr() ******/
4278
4279void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004280hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004281{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304282 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004283 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4284 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4285 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4286 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004287} /****** end hddPrintPmkId() ******/
4288
4289//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4290//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4291
4292//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4293//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4294
4295#define dump_bssid(bssid) \
4296 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004297 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4298 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4299 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004300 }
4301
4302#define dump_pmkid(pMac, pmkid) \
4303 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004304 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4305 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4306 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004307 }
4308
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004309#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004310/*
4311 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4312 * This function is used to notify the supplicant of a new PMKSA candidate.
4313 */
4314int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304315 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004316 int index, bool preauth )
4317{
Jeff Johnsone7245742012-09-05 17:12:55 -07004318#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004319 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004320 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004321
4322 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004323 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004324
4325 if( NULL == pRoamInfo )
4326 {
4327 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4328 return -EINVAL;
4329 }
4330
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004331 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4332 {
4333 dump_bssid(pRoamInfo->bssid);
4334 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004335 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004336 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004337#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304338 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004339}
4340#endif //FEATURE_WLAN_LFR
4341
Yue Maef608272013-04-08 23:09:17 -07004342#ifdef FEATURE_WLAN_LFR_METRICS
4343/*
4344 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
4345 * 802.11r/LFR metrics reporting function to report preauth initiation
4346 *
4347 */
4348#define MAX_LFR_METRICS_EVENT_LENGTH 100
4349VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
4350 tCsrRoamInfo *pRoamInfo)
4351{
4352 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4353 union iwreq_data wrqu;
4354
4355 ENTER();
4356
4357 if (NULL == pAdapter)
4358 {
4359 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4360 return VOS_STATUS_E_FAILURE;
4361 }
4362
4363 /* create the event */
4364 memset(&wrqu, 0, sizeof(wrqu));
4365 memset(metrics_notification, 0, sizeof(metrics_notification));
4366
4367 wrqu.data.pointer = metrics_notification;
4368 wrqu.data.length = scnprintf(metrics_notification,
4369 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
4370 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4371
4372 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4373
4374 EXIT();
4375
4376 return VOS_STATUS_SUCCESS;
4377}
4378
4379/*
4380 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
4381 * 802.11r/LFR metrics reporting function to report preauth completion
4382 * or failure
4383 */
4384VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
4385 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
4386{
4387 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4388 union iwreq_data wrqu;
4389
4390 ENTER();
4391
4392 if (NULL == pAdapter)
4393 {
4394 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4395 return VOS_STATUS_E_FAILURE;
4396 }
4397
4398 /* create the event */
4399 memset(&wrqu, 0, sizeof(wrqu));
4400 memset(metrics_notification, 0, sizeof(metrics_notification));
4401
4402 scnprintf(metrics_notification, sizeof(metrics_notification),
4403 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
4404 MAC_ADDR_ARRAY(pRoamInfo->bssid));
4405
4406 if (1 == preauth_status)
4407 strncat(metrics_notification, " TRUE", 5);
4408 else
4409 strncat(metrics_notification, " FALSE", 6);
4410
4411 wrqu.data.pointer = metrics_notification;
4412 wrqu.data.length = strlen(metrics_notification);
4413
4414 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4415
4416 EXIT();
4417
4418 return VOS_STATUS_SUCCESS;
4419}
4420
4421/*
4422 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
4423 * 802.11r/LFR metrics reporting function to report handover initiation
4424 *
4425 */
4426VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
4427 tCsrRoamInfo *pRoamInfo)
4428{
4429 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4430 union iwreq_data wrqu;
4431
4432 ENTER();
4433
4434 if (NULL == pAdapter)
4435 {
4436 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4437 return VOS_STATUS_E_FAILURE;
4438 }
4439
4440 /* create the event */
4441 memset(&wrqu, 0, sizeof(wrqu));
4442 memset(metrics_notification, 0, sizeof(metrics_notification));
4443
4444 wrqu.data.pointer = metrics_notification;
4445 wrqu.data.length = scnprintf(metrics_notification,
4446 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
4447 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4448
4449 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4450
4451 EXIT();
4452
4453 return VOS_STATUS_SUCCESS;
4454}
4455#endif
4456
Jeff Johnson295189b2012-06-20 16:38:30 -07004457/*
4458 * FUNCTION: hdd_cfg80211_scan_done_callback
4459 * scanning callback function, called after finishing scan
4460 *
4461 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304462static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4464{
4465 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304466 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004468 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4469 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 struct cfg80211_scan_request *req = NULL;
4471 int ret = 0;
4472
4473 ENTER();
4474
4475 hddLog(VOS_TRACE_LEVEL_INFO,
4476 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304477 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 __func__, halHandle, pContext, (int) scanId, (int) status);
4479
4480 //Block on scan req completion variable. Can't wait forever though.
4481 ret = wait_for_completion_interruptible_timeout(
4482 &pScanInfo->scan_req_completion_event,
4483 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4484 if (!ret)
4485 {
4486 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004487 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 }
4489
Yue Maef608272013-04-08 23:09:17 -07004490 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 {
4492 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004493 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 }
4495
4496 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304497 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 {
4499 hddLog(VOS_TRACE_LEVEL_INFO,
4500 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304501 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 (int) scanId);
4503 }
4504
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304505 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 pAdapter);
4507
4508 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304509 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004510
4511
4512 /* If any client wait scan result through WEXT
4513 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004514 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 {
4516 /* The other scan request waiting for current scan finish
4517 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004518 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004520 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 }
4522 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004523 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 {
4525 struct net_device *dev = pAdapter->dev;
4526 union iwreq_data wrqu;
4527 int we_event;
4528 char *msg;
4529
4530 memset(&wrqu, '\0', sizeof(wrqu));
4531 we_event = SIOCGIWSCAN;
4532 msg = NULL;
4533 wireless_send_event(dev, we_event, &wrqu, msg);
4534 }
4535 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004536 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004537
4538 /* Get the Scan Req */
4539 req = pAdapter->request;
4540
4541 if (!req)
4542 {
4543 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004544 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004545 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 }
4547
4548 /*
4549 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304550 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 req->n_ssids = 0;
4552 req->n_channels = 0;
4553 req->ie = 0;
4554
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004556 /* Scan is no longer pending */
4557 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004558
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004559 /*
4560 * cfg80211_scan_done informing NL80211 about completion
4561 * of scanning
4562 */
4563 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004564 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004565
Jeff Johnsone7245742012-09-05 17:12:55 -07004566allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004567 /* release the wake lock at the end of the scan*/
4568 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004569
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004570 /* Acquire wakelock to handle the case where APP's tries to suspend
4571 * immediatly after the driver gets connect request(i.e after scan)
4572 * from supplicant, this result in app's is suspending and not able
4573 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004574 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004575
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004576#ifdef FEATURE_WLAN_TDLS
4577 wlan_hdd_tdls_scan_done_callback(pAdapter);
4578#endif
4579
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 EXIT();
4581 return 0;
4582}
4583
4584/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004585 * FUNCTION: hdd_isScanAllowed
4586 * Go through each adapter and check if scan allowed
4587 *
4588 */
4589v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4590{
4591 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4592 hdd_station_ctx_t *pHddStaCtx = NULL;
4593 hdd_adapter_t *pAdapter = NULL;
4594 VOS_STATUS status = 0;
4595 v_U8_t staId = 0;
4596 v_U8_t *staMac = NULL;
4597
4598 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4599
4600 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4601 {
4602 pAdapter = pAdapterNode->pAdapter;
4603
4604 if( pAdapter )
4605 {
4606 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304607 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004608 __func__, pAdapter->device_mode);
4609 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4610 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4611 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4612 {
4613 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4614 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4615 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4616 {
4617 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4618 hddLog(VOS_TRACE_LEVEL_ERROR,
4619 "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304620 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004621 staMac[0], staMac[1], staMac[2],
4622 staMac[3], staMac[4], staMac[5]);
4623 return VOS_FALSE;
4624 }
4625 }
4626 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4627 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4628 {
4629 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4630 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304631 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004632 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4633 {
4634 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4635
4636 hddLog(VOS_TRACE_LEVEL_ERROR,
4637 "%s: client %02x:%02x:%02x:%02x:%02x:%02x of SoftAP/P2P-GO is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304638 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004639 staMac[0], staMac[1], staMac[2],
4640 staMac[3], staMac[4], staMac[5]);
4641 return VOS_FALSE;
4642 }
4643 }
4644 }
4645 }
4646 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4647 pAdapterNode = pNext;
4648 }
4649 hddLog(VOS_TRACE_LEVEL_INFO,
4650 "%s: Scan allowed", __func__);
4651 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304652}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004653
4654/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 * FUNCTION: wlan_hdd_cfg80211_scan
4656 * this scan respond to scan trigger and update cfg80211 scan database
4657 * later, scan dump command can be used to recieve scan results
4658 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004659int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4660#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4661 struct net_device *dev,
4662#endif
4663 struct cfg80211_scan_request *request)
4664{
4665#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4666 struct net_device *dev = request->wdev->netdev;
4667#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304668 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4670 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304671 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 tCsrScanRequest scanRequest;
4673 tANI_U8 *channelList = NULL, i;
4674 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304675 int status;
4676 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004678
4679 ENTER();
4680
4681 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4682 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004683
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304684 status = wlan_hdd_validate_context(pHddCtx);
4685
4686 if (0 != status)
4687 {
4688 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4689 "%s: HDD context is not valid", __func__);
4690 return status;
4691 }
4692
4693 cfg_param = pHddCtx->cfg_ini;
4694 pScanInfo = &pHddCtx->scan_info;
4695
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004696 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004697 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004698 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004699 {
4700 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004701 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4702 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004703 return -EBUSY;
4704 }
4705
Jeff Johnson295189b2012-06-20 16:38:30 -07004706#ifdef WLAN_BTAMP_FEATURE
4707 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004708 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004710 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004711 "%s: No scanning when AMP is on", __func__);
4712 return -EOPNOTSUPP;
4713 }
4714#endif
4715 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004716 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004718 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004719 "%s: Not scanning on device_mode = %d",
4720 __func__, pAdapter->device_mode);
4721 return -EOPNOTSUPP;
4722 }
4723
4724 if (TRUE == pScanInfo->mScanPending)
4725 {
4726 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004727 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 }
4729
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304730 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004731 //Channel and action frame is pending
4732 //Otherwise Cancel Remain On Channel and allow Scan
4733 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004734 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004735 {
4736 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__);
4737 return -EBUSY;
4738 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004739#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004740 /* if tdls disagree scan right now, return immediately.
4741 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4742 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4743 */
4744 status = wlan_hdd_tdls_scan_callback (pAdapter,
4745 wiphy,
4746#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4747 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004748#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004749 request);
4750 if(status <= 0)
4751 {
4752 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4753 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004754 }
4755#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004756
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4758 {
4759 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004760 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4764 {
4765 hddLog(VOS_TRACE_LEVEL_WARN,
4766 "%s: MAX TM Level Scan not allowed", __func__);
4767 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304768 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 }
4770 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4771
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004772 /* Check if scan is allowed at this point of time.
4773 */
4774 if (!hdd_isScanAllowed(pHddCtx))
4775 {
4776 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4777 return -EBUSY;
4778 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304779
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4781
4782 if (NULL != request)
4783 {
4784 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304785 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004786
4787 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4788 * Becasue of this, driver is assuming that this is not wildcard scan and so
4789 * is not aging out the scan results.
4790 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004791 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004792 {
4793 request->n_ssids = 0;
4794 }
4795
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004796 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004797 {
4798 tCsrSSIDInfo *SsidInfo;
4799 int j;
4800 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4801 /* Allocate num_ssid tCsrSSIDInfo structure */
4802 SsidInfo = scanRequest.SSIDs.SSIDList =
4803 ( tCsrSSIDInfo *)vos_mem_malloc(
4804 request->n_ssids*sizeof(tCsrSSIDInfo));
4805
4806 if(NULL == scanRequest.SSIDs.SSIDList)
4807 {
4808 hddLog(VOS_TRACE_LEVEL_ERROR,
4809 "memory alloc failed SSIDInfo buffer");
4810 return -ENOMEM;
4811 }
4812
4813 /* copy all the ssid's and their length */
4814 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4815 {
4816 /* get the ssid length */
4817 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4818 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4819 SsidInfo->SSID.length);
4820 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4821 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4822 j, SsidInfo->SSID.ssId);
4823 }
4824 /* set the scan type to active */
4825 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4826 }
4827 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4828 {
4829 /* set the scan type to active */
4830 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4831 }
4832 else
4833 {
4834 /*Set the scan type to default type, in this case it is ACTIVE*/
4835 scanRequest.scanType = pScanInfo->scan_mode;
4836 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304837 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004838 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4839 }
4840 else
4841 {
4842 /* set the scan type to active */
4843 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4844 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4845
4846 /* set min and max channel time to zero */
4847 scanRequest.minChnTime = 0;
4848 scanRequest.maxChnTime = 0;
4849 }
4850
4851 /* set BSSType to default type */
4852 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4853
4854 /*TODO: scan the requested channels only*/
4855
4856 /*Right now scanning all the channels */
4857 if( request )
4858 {
4859 if( request->n_channels )
4860 {
4861 channelList = vos_mem_malloc( request->n_channels );
4862 if( NULL == channelList )
4863 {
4864 status = -ENOMEM;
4865 goto free_mem;
4866 }
4867
4868 for( i = 0 ; i < request->n_channels ; i++ )
4869 channelList[i] = request->channels[i]->hw_value;
4870 }
4871
4872 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4873 scanRequest.ChannelInfo.ChannelList = channelList;
4874
4875 /* set requestType to full scan */
4876 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304877
4878 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004879 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304880 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004881 */
4882
4883 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304884 * and in that case driver shoudnt flush scan results. If
4885 * driver flushes the scan results here and unfortunately if
4886 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004887 * fails which is not desired
4888 */
4889
4890 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4891 {
4892 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4893 pAdapter->sessionId );
4894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004895
4896 if( request->ie_len )
4897 {
4898 /* save this for future association (join requires this) */
4899 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4900 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4901 pScanInfo->scanAddIE.length = request->ie_len;
4902
4903 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07004904 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4905 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004906 )
4907 {
4908 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
4909 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
4910 }
4911
4912 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
4913 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
4914
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
4916 request->ie_len);
4917 if (pP2pIe != NULL)
4918 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07004919#ifdef WLAN_FEATURE_P2P_DEBUG
4920 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
4921 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
4922 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4923 {
4924 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
4925 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4926 "Go nego completed to Connection is started");
4927 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4928 "for 8way Handshake");
4929 }
4930 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
4931 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4932 {
4933 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
4934 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4935 "Disconnected state to Connection is started");
4936 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4937 "for 4way Handshake");
4938 }
4939#endif
4940
Jeff Johnsone7245742012-09-05 17:12:55 -07004941 /* no_cck will be set during p2p find to disable 11b rates */
4942 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 hddLog(VOS_TRACE_LEVEL_INFO,
4945 "%s: This is a P2P Search", __func__);
4946 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07004947
Jeff Johnsone7245742012-09-05 17:12:55 -07004948 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
4949 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07004950 /* set requestType to P2P Discovery */
4951 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07004952 }
4953
4954 /*
4955 Skip Dfs Channel in case of P2P Search
4956 if it is set in ini file
4957 */
4958 if(cfg_param->skipDfsChnlInP2pSearch)
4959 {
4960 scanRequest.skipDfsChnlInP2pSearch = 1;
4961 }
4962 else
4963 {
4964 scanRequest.skipDfsChnlInP2pSearch = 0;
4965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004966
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 }
4968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 }
4970 }
4971
4972 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
4973
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004974 /* acquire the wakelock to avoid the apps suspend during the scan. To
4975 * address the following issues.
4976 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
4977 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
4978 * for long time, this result in apps running at full power for long time.
4979 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
4980 * be stuck in full power because of resume BMPS
4981 */
4982 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004983
4984 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 pAdapter->sessionId, &scanRequest, &scanId,
4986 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07004987
Jeff Johnson295189b2012-06-20 16:38:30 -07004988 if (eHAL_STATUS_SUCCESS != status)
4989 {
4990 hddLog(VOS_TRACE_LEVEL_ERROR,
4991 "%s: sme_ScanRequest returned error %d", __func__, status);
4992 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07004993 if(eHAL_STATUS_RESOURCES == status)
4994 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07004995 hddLog(VOS_TRACE_LEVEL_INFO, "%s: HO is in progress.So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07004996 status = -EBUSY;
4997 } else {
4998 status = -EIO;
4999 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005000 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 goto free_mem;
5002 }
5003
5004 pScanInfo->mScanPending = TRUE;
5005 pAdapter->request = request;
5006 pScanInfo->scanId = scanId;
5007
5008 complete(&pScanInfo->scan_req_completion_event);
5009
5010free_mem:
5011 if( scanRequest.SSIDs.SSIDList )
5012 {
5013 vos_mem_free(scanRequest.SSIDs.SSIDList);
5014 }
5015
5016 if( channelList )
5017 vos_mem_free( channelList );
5018
5019 EXIT();
5020
5021 return status;
5022}
5023
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005024
5025void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
5026{
5027 v_U8_t iniDot11Mode =
5028 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
5029 eHddDot11Mode hddDot11Mode = iniDot11Mode;
5030
5031 switch ( iniDot11Mode )
5032 {
5033 case eHDD_DOT11_MODE_AUTO:
5034 case eHDD_DOT11_MODE_11ac:
5035 case eHDD_DOT11_MODE_11ac_ONLY:
5036#ifdef WLAN_FEATURE_11AC
5037 hddDot11Mode = eHDD_DOT11_MODE_11ac;
5038#else
5039 hddDot11Mode = eHDD_DOT11_MODE_11n;
5040#endif
5041 break;
5042 case eHDD_DOT11_MODE_11n:
5043 case eHDD_DOT11_MODE_11n_ONLY:
5044 hddDot11Mode = eHDD_DOT11_MODE_11n;
5045 break;
5046 default:
5047 hddDot11Mode = iniDot11Mode;
5048 break;
5049 }
5050 /* This call decides required channel bonding mode */
5051 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
5052 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
5053 operationChannel);
5054}
5055
Jeff Johnson295189b2012-06-20 16:38:30 -07005056/*
5057 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305058 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07005059 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305060int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005061 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005062{
5063 int status = 0;
5064 hdd_wext_state_t *pWextState;
5065 v_U32_t roamId;
5066 tCsrRoamProfile *pRoamProfile;
5067 eMib_dot11DesiredBssType connectedBssType;
5068 eCsrAuthType RSNAuthType;
5069
5070 ENTER();
5071
5072 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305073
Jeff Johnson295189b2012-06-20 16:38:30 -07005074 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
5075 {
5076 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
5077 return -EINVAL;
5078 }
5079
5080 pRoamProfile = &pWextState->roamProfile;
5081
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305082 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005084 int ret = 0;
5085 hdd_station_ctx_t *pHddStaCtx;
5086 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5087 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
5088
5089 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
5090 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
5091 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 {
5093 /* Issue disconnect to CSR */
5094 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305095 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5097 pAdapter->sessionId,
5098 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
5099 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005100 ret = wait_for_completion_interruptible_timeout(
5101 &pAdapter->disconnect_comp_var,
5102 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5103 if (0 == ret)
5104 {
5105 VOS_ASSERT(0);
5106 }
5107 }
5108 }
5109 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
5110 {
5111 ret = wait_for_completion_interruptible_timeout(
5112 &pAdapter->disconnect_comp_var,
5113 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5114 if (0 == ret)
5115 {
5116 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005117 }
5118 }
5119
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305120 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5122 {
5123 /*QoS not enabled in cfg file*/
5124 pRoamProfile->uapsd_mask = 0;
5125 }
5126 else
5127 {
5128 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305129 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5131 }
5132
5133 pRoamProfile->SSIDs.numOfSSIDs = 1;
5134 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5135 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305136 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005137 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5138 ssid, ssid_len);
5139
5140 if (bssid)
5141 {
5142 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5143 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5144 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305145 /* Save BSSID in seperate variable as well, as RoamProfile
5146 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 case of join failure we should send valid BSSID to supplicant
5148 */
5149 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5150 WNI_CFG_BSSID_LEN);
5151 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005152 else
5153 {
5154 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005156
5157 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5158 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305159 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005160 /*set gen ie*/
5161 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5162 /*set auth*/
5163 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005165#ifdef FEATURE_WLAN_WAPI
5166 if (pAdapter->wapi_info.nWapiMode)
5167 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005168 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 switch (pAdapter->wapi_info.wapiAuthMode)
5170 {
5171 case WAPI_AUTH_MODE_PSK:
5172 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005173 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005174 pAdapter->wapi_info.wapiAuthMode);
5175 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5176 break;
5177 }
5178 case WAPI_AUTH_MODE_CERT:
5179 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005180 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005181 pAdapter->wapi_info.wapiAuthMode);
5182 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5183 break;
5184 }
5185 } // End of switch
5186 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5187 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5188 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005189 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 pRoamProfile->AuthType.numEntries = 1;
5191 pRoamProfile->EncryptionType.numEntries = 1;
5192 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5193 pRoamProfile->mcEncryptionType.numEntries = 1;
5194 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5195 }
5196 }
5197#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305198#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305199 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305200 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5201 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5202 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305203 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5204 sizeof (tSirGtkOffloadParams));
5205 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305206 }
5207#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 pRoamProfile->csrPersona = pAdapter->device_mode;
5209
Jeff Johnson32d95a32012-09-10 13:15:23 -07005210 if( operatingChannel )
5211 {
5212 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5213 pRoamProfile->ChannelInfo.numOfChannels = 1;
5214 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005215 else
5216 {
5217 pRoamProfile->ChannelInfo.ChannelList = NULL;
5218 pRoamProfile->ChannelInfo.numOfChannels = 0;
5219 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005220 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5221 {
5222 hdd_select_cbmode(pAdapter,operatingChannel);
5223 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005224 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5225 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305226 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005227 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005228 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5229 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305230 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5231 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005232 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5233 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305234
5235 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 pAdapter->sessionId, pRoamProfile, &roamId);
5237
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305238 if ((eHAL_STATUS_SUCCESS != status) &&
5239 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5240 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305241
5242 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005243 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5244 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5245 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305246 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005247 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305248 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005249
5250 pRoamProfile->ChannelInfo.ChannelList = NULL;
5251 pRoamProfile->ChannelInfo.numOfChannels = 0;
5252
Jeff Johnson295189b2012-06-20 16:38:30 -07005253 }
5254 else
5255 {
5256 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5257 return -EINVAL;
5258 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005259 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005260 return status;
5261}
5262
5263/*
5264 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5265 * This function is used to set the authentication type (OPEN/SHARED).
5266 *
5267 */
5268static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5269 enum nl80211_auth_type auth_type)
5270{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305271 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005272 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5273
5274 ENTER();
5275
5276 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305277 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305280 hddLog(VOS_TRACE_LEVEL_INFO,
5281 "%s: set authentication type to AUTOSWITCH", __func__);
5282 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5283 break;
5284
5285 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005286#ifdef WLAN_FEATURE_VOWIFI_11R
5287 case NL80211_AUTHTYPE_FT:
5288#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305289 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 "%s: set authentication type to OPEN", __func__);
5291 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5292 break;
5293
5294 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305295 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 "%s: set authentication type to SHARED", __func__);
5297 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5298 break;
5299#ifdef FEATURE_WLAN_CCX
5300 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305301 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 "%s: set authentication type to CCKM WPA", __func__);
5303 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5304 break;
5305#endif
5306
5307
5308 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305309 hddLog(VOS_TRACE_LEVEL_ERROR,
5310 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 auth_type);
5312 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5313 return -EINVAL;
5314 }
5315
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305316 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 pHddStaCtx->conn_info.authType;
5318 return 0;
5319}
5320
5321/*
5322 * FUNCTION: wlan_hdd_set_akm_suite
5323 * This function is used to set the key mgmt type(PSK/8021x).
5324 *
5325 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305326static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 u32 key_mgmt
5328 )
5329{
5330 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5331 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305332
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 /*set key mgmt type*/
5334 switch(key_mgmt)
5335 {
5336 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305337#ifdef WLAN_FEATURE_VOWIFI_11R
5338 case WLAN_AKM_SUITE_FT_PSK:
5339#endif
5340 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005341 __func__);
5342 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5343 break;
5344
5345 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305346#ifdef WLAN_FEATURE_VOWIFI_11R
5347 case WLAN_AKM_SUITE_FT_8021X:
5348#endif
5349 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005350 __func__);
5351 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5352 break;
5353#ifdef FEATURE_WLAN_CCX
5354#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5355#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5356 case WLAN_AKM_SUITE_CCKM:
5357 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5358 __func__);
5359 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5360 break;
5361#endif
5362
5363 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305364 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 __func__, key_mgmt);
5366 return -EINVAL;
5367
5368 }
5369 return 0;
5370}
5371
5372/*
5373 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305374 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 * (NONE/WEP40/WEP104/TKIP/CCMP).
5376 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305377static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5378 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 bool ucast
5380 )
5381{
5382 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305383 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5385
5386 ENTER();
5387
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305388 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305390 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 __func__, cipher);
5392 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5393 }
5394 else
5395 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305396
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305398 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 {
5400 case IW_AUTH_CIPHER_NONE:
5401 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5402 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305403
Jeff Johnson295189b2012-06-20 16:38:30 -07005404 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305405 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305407
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305409 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305411
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 case WLAN_CIPHER_SUITE_TKIP:
5413 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5414 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305415
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 case WLAN_CIPHER_SUITE_CCMP:
5417 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5418 break;
5419#ifdef FEATURE_WLAN_WAPI
5420 case WLAN_CIPHER_SUITE_SMS4:
5421 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5422 break;
5423#endif
5424
5425#ifdef FEATURE_WLAN_CCX
5426 case WLAN_CIPHER_SUITE_KRK:
5427 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5428 break;
5429#endif
5430 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305431 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005432 __func__, cipher);
5433 return -EOPNOTSUPP;
5434 }
5435 }
5436
5437 if (ucast)
5438 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305439 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 __func__, encryptionType);
5441 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5442 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305443 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 encryptionType;
5445 }
5446 else
5447 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305448 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005449 __func__, encryptionType);
5450 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5451 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5452 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5453 }
5454
5455 return 0;
5456}
5457
5458
5459/*
5460 * FUNCTION: wlan_hdd_cfg80211_set_ie
5461 * This function is used to parse WPA/RSN IE's.
5462 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305463int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5464 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005465 size_t ie_len
5466 )
5467{
5468 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5469 u8 *genie = ie;
5470 v_U16_t remLen = ie_len;
5471#ifdef FEATURE_WLAN_WAPI
5472 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5473 u16 *tmp;
5474 v_U16_t akmsuiteCount;
5475 int *akmlist;
5476#endif
5477 ENTER();
5478
5479 /* clear previous assocAddIE */
5480 pWextState->assocAddIE.length = 0;
5481 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5482
5483 while (remLen >= 2)
5484 {
5485 v_U16_t eLen = 0;
5486 v_U8_t elementId;
5487 elementId = *genie++;
5488 eLen = *genie++;
5489 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305490
5491 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305493
5494 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305496 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005497 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 -07005498 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305499 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 "%s: Invalid WPA IE", __func__);
5501 return -EINVAL;
5502 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305503 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 {
5505 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305506 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305508
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5510 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005511 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5512 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 VOS_ASSERT(0);
5514 return -ENOMEM;
5515 }
5516 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5517 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5518 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305519
Jeff Johnson295189b2012-06-20 16:38:30 -07005520 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5521 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5522 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5523 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305524 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5525 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5527 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5528 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5529 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5530 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5531 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305532 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
5533 P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 /*Consider P2P IE, only for P2P Client */
5535 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5536 {
5537 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305538 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305540
Jeff Johnson295189b2012-06-20 16:38:30 -07005541 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5542 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005543 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5544 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 VOS_ASSERT(0);
5546 return -ENOMEM;
5547 }
5548 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5549 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5550 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305551
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5553 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005555#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305556 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5557 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 /*Consider WFD IE, only for P2P Client */
5559 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5560 {
5561 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305562 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305564
Jeff Johnson295189b2012-06-20 16:38:30 -07005565 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5566 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005567 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5568 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005569 VOS_ASSERT(0);
5570 return -ENOMEM;
5571 }
5572 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5573 // WPS IE + P2P IE + WFD IE
5574 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5575 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305576
Jeff Johnson295189b2012-06-20 16:38:30 -07005577 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5578 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5579 }
5580#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005581 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305582 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005583 HS20_OUI_TYPE_SIZE)) )
5584 {
5585 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305586 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005587 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005588
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005589 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5590 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005591 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5592 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005593 VOS_ASSERT(0);
5594 return -ENOMEM;
5595 }
5596 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5597 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005598
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005599 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5600 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5601 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005602
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07005603 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
5604
5605 /* populating as ADDIE in beacon frames */
5606 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5607 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
5608 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
5609 {
5610 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5611 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5612 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5613 {
5614 hddLog(LOGE,
5615 "Coldn't pass "
5616 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
5617 }
5618 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
5619 else
5620 hddLog(LOGE,
5621 "Could not pass on "
5622 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
5623
5624 /* IBSS mode doesn't contain params->proberesp_ies still
5625 beaconIE's need to be populated in probe response frames */
5626 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
5627 {
5628 u16 rem_probe_resp_ie_len = eLen + 2;
5629 u8 probe_rsp_ie_len[3] = {0};
5630 u8 counter = 0;
5631
5632 /* Check Probe Resp Length if it is greater then 255 then
5633 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
5634 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
5635 not able Store More then 255 bytes into One Variable */
5636
5637 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5638 {
5639 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5640 {
5641 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5642 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5643 }
5644 else
5645 {
5646 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5647 rem_probe_resp_ie_len = 0;
5648 }
5649 }
5650
5651 rem_probe_resp_ie_len = 0;
5652
5653 if (probe_rsp_ie_len[0] > 0)
5654 {
5655 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5656 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5657 (tANI_U8*)(genie - 2),
5658 probe_rsp_ie_len[0], NULL,
5659 eANI_BOOLEAN_FALSE)
5660 == eHAL_STATUS_FAILURE)
5661 {
5662 hddLog(LOGE,
5663 "Could not pass"
5664 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
5665 }
5666 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5667 }
5668
5669 if (probe_rsp_ie_len[1] > 0)
5670 {
5671 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5672 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5673 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5674 probe_rsp_ie_len[1], NULL,
5675 eANI_BOOLEAN_FALSE)
5676 == eHAL_STATUS_FAILURE)
5677 {
5678 hddLog(LOGE,
5679 "Could not pass"
5680 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
5681 }
5682 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5683 }
5684
5685 if (probe_rsp_ie_len[2] > 0)
5686 {
5687 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5688 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5689 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5690 probe_rsp_ie_len[2], NULL,
5691 eANI_BOOLEAN_FALSE)
5692 == eHAL_STATUS_FAILURE)
5693 {
5694 hddLog(LOGE,
5695 "Could not pass"
5696 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
5697 }
5698 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5699 }
5700
5701 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5702 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5703 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5704 {
5705 hddLog(LOGE,
5706 "Could not pass"
5707 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
5708 }
5709 }
5710 else
5711 {
5712 // Reset WNI_CFG_PROBE_RSP Flags
5713 wlan_hdd_reset_prob_rspies(pAdapter);
5714
5715 hddLog(VOS_TRACE_LEVEL_INFO,
5716 "%s: No Probe Response IE received in set beacon",
5717 __func__);
5718 }
5719 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 break;
5721 case DOT11F_EID_RSN:
5722 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5723 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5724 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5725 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5726 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5727 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005728 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5729 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305730 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005731 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305732 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005733 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305734
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005735 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5736 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005737 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5738 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005739 VOS_ASSERT(0);
5740 return -ENOMEM;
5741 }
5742 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5743 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305744
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005745 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5746 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5747 break;
5748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005749#ifdef FEATURE_WLAN_WAPI
5750 case WLAN_EID_WAPI:
5751 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
5752 hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n",
5753 pAdapter->wapi_info.nWapiMode);
5754 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305755 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 akmsuiteCount = WPA_GET_LE16(tmp);
5757 tmp = tmp + 1;
5758 akmlist = (int *)(tmp);
5759 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5760 {
5761 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5762 }
5763 else
5764 {
5765 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5766 VOS_ASSERT(0);
5767 return -EINVAL;
5768 }
5769
5770 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5771 {
5772 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005773 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305775 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005776 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305777 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005778 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005779 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5781 }
5782 break;
5783#endif
5784 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305785 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005787 /* when Unknown IE is received we should break and continue
5788 * to the next IE in the buffer instead we were returning
5789 * so changing this to break */
5790 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005791 }
5792 genie += eLen;
5793 remLen -= eLen;
5794 }
5795 EXIT();
5796 return 0;
5797}
5798
5799/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305800 * FUNCTION: hdd_isWPAIEPresent
5801 * Parse the received IE to find the WPA IE
5802 *
5803 */
5804static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5805{
5806 v_U8_t eLen = 0;
5807 v_U16_t remLen = ie_len;
5808 v_U8_t elementId = 0;
5809
5810 while (remLen >= 2)
5811 {
5812 elementId = *ie++;
5813 eLen = *ie++;
5814 remLen -= 2;
5815 if (eLen > remLen)
5816 {
5817 hddLog(VOS_TRACE_LEVEL_ERROR,
5818 "%s: IE length is wrong %d", __func__, eLen);
5819 return FALSE;
5820 }
5821 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5822 {
5823 /* OUI - 0x00 0X50 0XF2
5824 WPA Information Element - 0x01
5825 WPA version - 0x01*/
5826 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5827 return TRUE;
5828 }
5829 ie += eLen;
5830 remLen -= eLen;
5831 }
5832 return FALSE;
5833}
5834
5835/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305837 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 * parameters during connect operation.
5839 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305840int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 struct cfg80211_connect_params *req
5842 )
5843{
5844 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305845 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 ENTER();
5847
5848 /*set wpa version*/
5849 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5850
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305851 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305853 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 {
5855 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5856 }
5857 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5858 {
5859 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5860 }
5861 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305862
5863 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 pWextState->wpaVersion);
5865
5866 /*set authentication type*/
5867 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5868
5869 if (0 > status)
5870 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305871 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 "%s: failed to set authentication type ", __func__);
5873 return status;
5874 }
5875
5876 /*set key mgmt type*/
5877 if (req->crypto.n_akm_suites)
5878 {
5879 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5880 if (0 > status)
5881 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305882 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 __func__);
5884 return status;
5885 }
5886 }
5887
5888 /*set pairwise cipher type*/
5889 if (req->crypto.n_ciphers_pairwise)
5890 {
5891 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5892 req->crypto.ciphers_pairwise[0], true);
5893 if (0 > status)
5894 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305895 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 "%s: failed to set unicast cipher type", __func__);
5897 return status;
5898 }
5899 }
5900 else
5901 {
5902 /*Reset previous cipher suite to none*/
5903 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5904 if (0 > status)
5905 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305906 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 "%s: failed to set unicast cipher type", __func__);
5908 return status;
5909 }
5910 }
5911
5912 /*set group cipher type*/
5913 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
5914 false);
5915
5916 if (0 > status)
5917 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305918 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 __func__);
5920 return status;
5921 }
5922
Chet Lanctot186b5732013-03-18 10:26:30 -07005923#ifdef WLAN_FEATURE_11W
5924 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
5925#endif
5926
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
5928 if (req->ie_len)
5929 {
5930 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
5931 if ( 0 > status)
5932 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305933 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 __func__);
5935 return status;
5936 }
5937 }
5938
5939 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305940 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 {
5942 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
5943 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
5944 )
5945 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305946 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5948 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305949 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 __func__);
5951 return -EOPNOTSUPP;
5952 }
5953 else
5954 {
5955 u8 key_len = req->key_len;
5956 u8 key_idx = req->key_idx;
5957
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305958 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 && (CSR_MAX_NUM_KEY > key_idx)
5960 )
5961 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305962 hddLog(VOS_TRACE_LEVEL_INFO,
5963 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 __func__, key_idx, key_len);
5965 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305966 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305968 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 (u8)key_len;
5970 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
5971 }
5972 }
5973 }
5974 }
5975
5976 return status;
5977}
5978
5979/*
5980 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305981 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 * parameters during connect operation.
5983 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305984static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 struct net_device *ndev,
5986 struct cfg80211_connect_params *req
5987 )
5988{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305989 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305990 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005991 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
5992 hdd_context_t *pHddCtx = NULL;
5993
5994 ENTER();
5995
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305996 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
5998
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305999 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6000 status = wlan_hdd_validate_context(pHddCtx);
6001
6002 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306004 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6005 "%s: HDD context is not valid", __func__);
6006 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006007 }
6008
6009#ifdef WLAN_BTAMP_FEATURE
6010 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306011 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306013 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08006015 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006016 }
6017#endif
6018 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306019 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07006020
6021 if ( 0 > status)
6022 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306023 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 __func__);
6025 return status;
6026 }
6027
6028 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006029 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
6031 (vos_concurrent_sessions_running()))
6032 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306033 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 }
6035
Mohit Khanna765234a2012-09-11 15:08:35 -07006036 if ( req->channel )
6037 {
6038 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
6039 req->ssid_len, req->bssid,
6040 req->channel->hw_value);
6041 }
6042 else
6043 {
6044 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306045 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07006046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006047
6048 if (0 > status)
6049 {
6050 //ReEnable BMPS if disabled
6051 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
6052 (NULL != pHddCtx))
6053 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306054 if (pHddCtx->hdd_wlan_suspended)
6055 {
6056 hdd_set_pwrparams(pHddCtx);
6057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 //ReEnable Bmps and Imps back
6059 hdd_enable_bmps_imps(pHddCtx);
6060 }
6061
6062 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6063 return status;
6064 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306065 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006066 EXIT();
6067 return status;
6068}
6069
6070
6071/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306072 * FUNCTION: wlan_hdd_disconnect
6073 * This function is used to issue a disconnect request to SME
6074 */
6075int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
6076{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306077 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306078 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306079 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6080
6081 status = wlan_hdd_validate_context(pHddCtx);
6082
6083 if (0 != status)
6084 {
6085 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6086 "%s: HDD context is not valid", __func__);
6087 return status;
6088 }
6089
6090 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306091 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306092 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306093
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306094 /*issue disconnect*/
6095 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6096 pAdapter->sessionId, reason);
6097
6098 if ( 0 != status )
6099 {
6100 hddLog(VOS_TRACE_LEVEL_ERROR,
6101 "%s csrRoamDisconnect failure, returned %d \n",
6102 __func__, (int)status );
6103 return -EINVAL;
6104 }
6105 wait_for_completion_interruptible_timeout(
6106 &pAdapter->disconnect_comp_var,
6107 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6108 /*stop tx queues*/
6109 netif_tx_disable(pAdapter->dev);
6110 netif_carrier_off(pAdapter->dev);
6111 return status;
6112}
6113
6114
6115/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 * FUNCTION: wlan_hdd_cfg80211_disconnect
6117 * This function is used to issue a disconnect request to SME
6118 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306119static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 struct net_device *dev,
6121 u16 reason
6122 )
6123{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306124 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6125 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306127 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006129 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306130#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006131 tANI_U8 staIdx;
6132#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306133
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306135
6136 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006137 __func__,pAdapter->device_mode);
6138
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306139 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6140 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006141
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306142 status = wlan_hdd_validate_context(pHddCtx);
6143
6144 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306146 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6147 "%s: HDD context is not valid", __func__);
6148 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306150
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 if (NULL != pRoamProfile)
6152 {
6153 /*issue disconnect request to SME, if station is in connected state*/
6154 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
6155 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306156 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306158 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 switch(reason)
6160 {
6161 case WLAN_REASON_MIC_FAILURE:
6162 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6163 break;
6164
6165 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6166 case WLAN_REASON_DISASSOC_AP_BUSY:
6167 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6168 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6169 break;
6170
6171 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6172 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6173 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6174 break;
6175
6176 case WLAN_REASON_DEAUTH_LEAVING:
6177 default:
6178 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6179 break;
6180 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306181 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6182 pScanInfo = &pHddCtx->scan_info;
6183 if (pScanInfo->mScanPending)
6184 {
6185 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
6186 "Aborting Scan");
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306187 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306188 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006189
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006190#ifdef FEATURE_WLAN_TDLS
6191 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006192 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006193 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006194 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6195 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006196 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006197 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006198 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006199 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006200 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006201 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006202 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006203 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006204 pAdapter->sessionId,
6205 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006206 }
6207 }
6208#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306209 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6210 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 {
6212 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306213 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 __func__, (int)status );
6215 return -EINVAL;
6216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006217 }
6218 }
6219 else
6220 {
6221 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6222 }
6223
6224 return status;
6225}
6226
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306227
Jeff Johnson295189b2012-06-20 16:38:30 -07006228/*
6229 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306230 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 * settings in IBSS mode.
6232 */
6233static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306234 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 struct cfg80211_ibss_params *params
6236 )
6237{
6238 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306239 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6241 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306242
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 ENTER();
6244
6245 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6246
6247 if (params->ie_len && ( NULL != params->ie) )
6248 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006249 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6250 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006251 {
6252 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6253 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6254 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006255 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006256 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006257 tDot11fIEWPA dot11WPAIE;
6258 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006259 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006260
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006261 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6262 params->ie_len, DOT11F_EID_WPA);
6263 if ( NULL != ie )
6264 {
6265 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6266 // Unpack the WPA IE
6267 //Skip past the EID byte and length byte - and four byte WiFi OUI
6268 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6269 &ie[2+4],
6270 ie[1] - 4,
6271 &dot11WPAIE);
6272 /*Extract the multicast cipher, the encType for unicast
6273 cipher for wpa-none is none*/
6274 encryptionType =
6275 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6276 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006278
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6280
6281 if (0 > status)
6282 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306283 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 __func__);
6285 return status;
6286 }
6287 }
6288
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306289 pWextState->roamProfile.AuthType.authType[0] =
6290 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6292
6293 if (params->privacy)
6294 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306295 /* Security enabled IBSS, At this time there is no information available
6296 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306298 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306300 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 *enable privacy bit in beacons */
6302
6303 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6304 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006305 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6306 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6308 pWextState->roamProfile.EncryptionType.numEntries = 1;
6309 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 return status;
6311}
6312
6313/*
6314 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306315 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306317static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 struct net_device *dev,
6319 struct cfg80211_ibss_params *params
6320 )
6321{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306322 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6324 tCsrRoamProfile *pRoamProfile;
6325 int status;
6326 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306327 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006328
6329 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306330
6331 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006332 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6333
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306334 status = wlan_hdd_validate_context(pHddCtx);
6335
6336 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306338 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6339 "%s: HDD context is not valid", __func__);
6340 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006341 }
6342
6343 if (NULL == pWextState)
6344 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306345 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 __func__);
6347 return -EIO;
6348 }
6349
6350 pRoamProfile = &pWextState->roamProfile;
6351
6352 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6353 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306354 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 "%s Interface type is not set to IBSS \n", __func__);
6356 return -EINVAL;
6357 }
6358
6359 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006360 if (NULL !=
6361#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6362 params->chandef.chan)
6363#else
6364 params->channel)
6365#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 {
6367 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006368 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6369 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6370 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6371 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006372
6373 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306374 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006375 ieee80211_frequency_to_channel(
6376#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6377 params->chandef.chan->center_freq);
6378#else
6379 params->channel->center_freq);
6380#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006381
6382 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6383 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006385 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6386 __func__);
6387 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006389
6390 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006392 if (channelNum == validChan[indx])
6393 {
6394 break;
6395 }
6396 }
6397 if (indx >= numChans)
6398 {
6399 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 __func__, channelNum);
6401 return -EINVAL;
6402 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006403 /* Set the Operational Channel */
6404 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6405 channelNum);
6406 pRoamProfile->ChannelInfo.numOfChannels = 1;
6407 pHddStaCtx->conn_info.operationChannel = channelNum;
6408 pRoamProfile->ChannelInfo.ChannelList =
6409 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 }
6411
6412 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306413 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006414 if (status < 0)
6415 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306416 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006417 __func__);
6418 return status;
6419 }
6420
6421 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306422 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006423 params->ssid_len, params->bssid,
6424 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006425
6426 if (0 > status)
6427 {
6428 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6429 return status;
6430 }
6431
6432 return 0;
6433}
6434
6435/*
6436 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306437 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006438 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306439static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 struct net_device *dev
6441 )
6442{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306443 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006444 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6445 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306446 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6447 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006448
6449 ENTER();
6450
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306451 status = wlan_hdd_validate_context(pHddCtx);
6452
6453 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006454 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306455 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6456 "%s: HDD context is not valid", __func__);
6457 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006458 }
6459
Jeff Johnson295189b2012-06-20 16:38:30 -07006460 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6461 if (NULL == pWextState)
6462 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306463 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006464 __func__);
6465 return -EIO;
6466 }
6467
6468 pRoamProfile = &pWextState->roamProfile;
6469
6470 /* Issue disconnect only if interface type is set to IBSS */
6471 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6472 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306473 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006474 __func__);
6475 return -EINVAL;
6476 }
6477
6478 /* Issue Disconnect request */
6479 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6480 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6481 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6482
6483 return 0;
6484}
6485
6486/*
6487 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6488 * This function is used to set the phy parameters
6489 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6490 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306491static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006492 u32 changed)
6493{
6494 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6495 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306496 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006497
6498 ENTER();
6499
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306500 status = wlan_hdd_validate_context(pHddCtx);
6501
6502 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006503 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306504 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6505 "%s: HDD context is not valid", __func__);
6506 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006507 }
6508
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6510 {
6511 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6512 WNI_CFG_RTS_THRESHOLD_STAMAX :
6513 wiphy->rts_threshold;
6514
6515 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306516 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006517 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306518 hddLog(VOS_TRACE_LEVEL_ERROR,
6519 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 __func__, rts_threshold);
6521 return -EINVAL;
6522 }
6523
6524 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6525 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306526 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306528 hddLog(VOS_TRACE_LEVEL_ERROR,
6529 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006530 __func__, rts_threshold);
6531 return -EIO;
6532 }
6533
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306534 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 rts_threshold);
6536 }
6537
6538 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6539 {
6540 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6541 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6542 wiphy->frag_threshold;
6543
6544 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306545 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006546 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306547 hddLog(VOS_TRACE_LEVEL_ERROR,
6548 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 frag_threshold);
6550 return -EINVAL;
6551 }
6552
6553 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6554 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306555 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006556 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306557 hddLog(VOS_TRACE_LEVEL_ERROR,
6558 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 __func__, frag_threshold);
6560 return -EIO;
6561 }
6562
6563 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6564 frag_threshold);
6565 }
6566
6567 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6568 || (changed & WIPHY_PARAM_RETRY_LONG))
6569 {
6570 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6571 wiphy->retry_short :
6572 wiphy->retry_long;
6573
6574 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6575 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6576 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306577 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 __func__, retry_value);
6579 return -EINVAL;
6580 }
6581
6582 if (changed & WIPHY_PARAM_RETRY_SHORT)
6583 {
6584 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6585 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306586 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006587 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306588 hddLog(VOS_TRACE_LEVEL_ERROR,
6589 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 __func__, retry_value);
6591 return -EIO;
6592 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306593 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 __func__, retry_value);
6595 }
6596 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6597 {
6598 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6599 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306600 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306602 hddLog(VOS_TRACE_LEVEL_ERROR,
6603 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006604 __func__, retry_value);
6605 return -EIO;
6606 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306607 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 __func__, retry_value);
6609 }
6610 }
6611
6612 return 0;
6613}
6614
6615/*
6616 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6617 * This function is used to set the txpower
6618 */
6619static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006620#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6621 struct wireless_dev *wdev,
6622#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006623#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306624 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006625#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306626 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006627#endif
6628 int dbm)
6629{
6630 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306631 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6633 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306634 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006635
6636 ENTER();
6637
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306638 status = wlan_hdd_validate_context(pHddCtx);
6639
6640 if (0 != status)
6641 {
6642 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6643 "%s: HDD context is not valid", __func__);
6644 return status;
6645 }
6646
6647 hHal = pHddCtx->hHal;
6648
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306649 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6650 dbm, ccmCfgSetCallback,
6651 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306653 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6655 return -EIO;
6656 }
6657
6658 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6659 dbm);
6660
6661 switch(type)
6662 {
6663 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6664 /* Fall through */
6665 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6666 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6667 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306668 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6669 __func__);
6670 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 }
6672 break;
6673 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306674 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 __func__);
6676 return -EOPNOTSUPP;
6677 break;
6678 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306679 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6680 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 return -EIO;
6682 }
6683
6684 return 0;
6685}
6686
6687/*
6688 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6689 * This function is used to read the txpower
6690 */
Yue Maf49ba872013-08-19 12:04:25 -07006691static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6692#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6693 struct wireless_dev *wdev,
6694#endif
6695 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006696{
6697
6698 hdd_adapter_t *pAdapter;
6699 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306700 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006701
Jeff Johnsone7245742012-09-05 17:12:55 -07006702 ENTER();
6703
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306704 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006705
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306706 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006707 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306708 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6709 "%s: HDD context is not valid", __func__);
6710 *dbm = 0;
6711 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006712 }
6713
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6715 if (NULL == pAdapter)
6716 {
6717 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6718 return -ENOENT;
6719 }
6720
6721 wlan_hdd_get_classAstats(pAdapter);
6722 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6723
Jeff Johnsone7245742012-09-05 17:12:55 -07006724 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006725 return 0;
6726}
6727
6728static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6729 u8* mac, struct station_info *sinfo)
6730{
6731 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6732 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6733 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6734 tANI_U8 rate_flags;
6735
6736 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6737 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006738
6739 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6740 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6741 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6742 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6743 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6744 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6745 tANI_U16 maxRate = 0;
6746 tANI_U16 myRate;
6747 tANI_U16 currentRate = 0;
6748 tANI_U8 maxSpeedMCS = 0;
6749 tANI_U8 maxMCSIdx = 0;
6750 tANI_U8 rateFlag = 1;
6751 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006752 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306753 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006754
Leo Chang6f8870f2013-03-26 18:11:36 -07006755#ifdef WLAN_FEATURE_11AC
6756 tANI_U32 vht_mcs_map;
6757 eDataRate11ACMaxMcs vhtMaxMcs;
6758#endif /* WLAN_FEATURE_11AC */
6759
Jeff Johnsone7245742012-09-05 17:12:55 -07006760 ENTER();
6761
Jeff Johnson295189b2012-06-20 16:38:30 -07006762 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6763 (0 == ssidlen))
6764 {
6765 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6766 " Invalid ssidlen, %d", __func__, ssidlen);
6767 /*To keep GUI happy*/
6768 return 0;
6769 }
6770
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306771 status = wlan_hdd_validate_context(pHddCtx);
6772
6773 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006774 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6776 "%s: HDD context is not valid", __func__);
6777 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006778 }
6779
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6781 sinfo->filled |= STATION_INFO_SIGNAL;
6782
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006783 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006784 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6785
6786 //convert to the UI units of 100kbps
6787 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6788
6789#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006790 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 -07006791 sinfo->signal,
6792 pCfg->reportMaxLinkSpeed,
6793 myRate,
6794 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006795 (int) pCfg->linkSpeedRssiMid,
6796 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006797 (int) rate_flags,
6798 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006799#endif //LINKSPEED_DEBUG_ENABLED
6800
6801 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6802 {
6803 // we do not want to necessarily report the current speed
6804 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6805 {
6806 // report the max possible speed
6807 rssidx = 0;
6808 }
6809 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6810 {
6811 // report the max possible speed with RSSI scaling
6812 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6813 {
6814 // report the max possible speed
6815 rssidx = 0;
6816 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006817 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006818 {
6819 // report middle speed
6820 rssidx = 1;
6821 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006822 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6823 {
6824 // report middle speed
6825 rssidx = 2;
6826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006827 else
6828 {
6829 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006830 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 }
6832 }
6833 else
6834 {
6835 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6836 hddLog(VOS_TRACE_LEVEL_ERROR,
6837 "%s: Invalid value for reportMaxLinkSpeed: %u",
6838 __func__, pCfg->reportMaxLinkSpeed);
6839 rssidx = 0;
6840 }
6841
6842 maxRate = 0;
6843
6844 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306845 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6846 OperationalRates, &ORLeng))
6847 {
6848 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6849 /*To keep GUI happy*/
6850 return 0;
6851 }
6852
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 for (i = 0; i < ORLeng; i++)
6854 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006855 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 {
6857 /* Validate Rate Set */
6858 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6859 {
6860 currentRate = supported_data_rate[j].supported_rate[rssidx];
6861 break;
6862 }
6863 }
6864 /* Update MAX rate */
6865 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6866 }
6867
6868 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306869 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
6870 ExtendedRates, &ERLeng))
6871 {
6872 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6873 /*To keep GUI happy*/
6874 return 0;
6875 }
6876
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 for (i = 0; i < ERLeng; i++)
6878 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006879 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006880 {
6881 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
6882 {
6883 currentRate = supported_data_rate[j].supported_rate[rssidx];
6884 break;
6885 }
6886 }
6887 /* Update MAX rate */
6888 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006890 /* Get MCS Rate Set -- but only if we are connected at MCS
6891 rates or if we are always reporting max speed or if we have
6892 good rssi */
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006893 if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306895 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
6896 MCSRates, &MCSLeng))
6897 {
6898 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6899 /*To keep GUI happy*/
6900 return 0;
6901 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006902 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07006903#ifdef WLAN_FEATURE_11AC
6904 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306905 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07006906 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006907 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306908 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07006909 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07006910 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006911 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006912 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006913 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07006914 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006915 maxMCSIdx = 7;
6916 }
6917 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
6918 {
6919 maxMCSIdx = 8;
6920 }
6921 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
6922 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306923 //VHT20 is supporting 0~8
6924 if (rate_flags & eHAL_TX_RATE_VHT20)
6925 maxMCSIdx = 8;
6926 else
6927 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07006928 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306929
6930 if (rate_flags & eHAL_TX_RATE_VHT80)
6931 {
6932 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
6933 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
6934 }
6935 else if (rate_flags & eHAL_TX_RATE_VHT40)
6936 {
6937 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
6938 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
6939 }
6940 else if (rate_flags & eHAL_TX_RATE_VHT20)
6941 {
6942 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
6943 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
6944 }
6945
Leo Chang6f8870f2013-03-26 18:11:36 -07006946 maxSpeedMCS = 1;
6947 if (currentRate > maxRate)
6948 {
6949 maxRate = currentRate;
6950 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306951
Leo Chang6f8870f2013-03-26 18:11:36 -07006952 }
6953 else
6954#endif /* WLAN_FEATURE_11AC */
6955 {
6956 if (rate_flags & eHAL_TX_RATE_HT40)
6957 {
6958 rateFlag |= 1;
6959 }
6960 if (rate_flags & eHAL_TX_RATE_SGI)
6961 {
6962 rateFlag |= 2;
6963 }
6964
6965 for (i = 0; i < MCSLeng; i++)
6966 {
6967 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
6968 for (j = 0; j < temp; j++)
6969 {
6970 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
6971 {
6972 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
6973 break;
6974 }
6975 }
6976 if ((j < temp) && (currentRate > maxRate))
6977 {
6978 maxRate = currentRate;
6979 maxSpeedMCS = 1;
6980 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
6981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006982 }
6983 }
6984 }
6985
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306986 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
6987 {
6988 maxRate = myRate;
6989 maxSpeedMCS = 1;
6990 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6991 }
6992
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006994 if (((maxRate < myRate) && (0 == rssidx)) ||
6995 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07006996 {
6997 maxRate = myRate;
6998 if (rate_flags & eHAL_TX_RATE_LEGACY)
6999 {
7000 maxSpeedMCS = 0;
7001 }
7002 else
7003 {
7004 maxSpeedMCS = 1;
7005 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7006 }
7007 }
7008
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307009 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 {
7011 sinfo->txrate.legacy = maxRate;
7012#ifdef LINKSPEED_DEBUG_ENABLED
7013 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7014#endif //LINKSPEED_DEBUG_ENABLED
7015 }
7016 else
7017 {
7018 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007019#ifdef WLAN_FEATURE_11AC
7020 sinfo->txrate.nss = 1;
7021 if (rate_flags & eHAL_TX_RATE_VHT80)
7022 {
7023 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307024 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007025 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307026 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007027 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307028 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7029 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7030 }
7031 else if (rate_flags & eHAL_TX_RATE_VHT20)
7032 {
7033 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7034 }
7035#endif /* WLAN_FEATURE_11AC */
7036 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7037 {
7038 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7039 if (rate_flags & eHAL_TX_RATE_HT40)
7040 {
7041 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7042 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 if (rate_flags & eHAL_TX_RATE_SGI)
7045 {
7046 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7047 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307048
Jeff Johnson295189b2012-06-20 16:38:30 -07007049#ifdef LINKSPEED_DEBUG_ENABLED
7050 pr_info("Reporting MCS rate %d flags %x\n",
7051 sinfo->txrate.mcs,
7052 sinfo->txrate.flags );
7053#endif //LINKSPEED_DEBUG_ENABLED
7054 }
7055 }
7056 else
7057 {
7058 // report current rate instead of max rate
7059
7060 if (rate_flags & eHAL_TX_RATE_LEGACY)
7061 {
7062 //provide to the UI in units of 100kbps
7063 sinfo->txrate.legacy = myRate;
7064#ifdef LINKSPEED_DEBUG_ENABLED
7065 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7066#endif //LINKSPEED_DEBUG_ENABLED
7067 }
7068 else
7069 {
7070 //must be MCS
7071 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007072#ifdef WLAN_FEATURE_11AC
7073 sinfo->txrate.nss = 1;
7074 if (rate_flags & eHAL_TX_RATE_VHT80)
7075 {
7076 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7077 }
7078 else
7079#endif /* WLAN_FEATURE_11AC */
7080 {
7081 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007083 if (rate_flags & eHAL_TX_RATE_SGI)
7084 {
7085 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7086 }
7087 if (rate_flags & eHAL_TX_RATE_HT40)
7088 {
7089 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7090 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007091#ifdef WLAN_FEATURE_11AC
7092 else if (rate_flags & eHAL_TX_RATE_VHT80)
7093 {
7094 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7095 }
7096#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007097#ifdef LINKSPEED_DEBUG_ENABLED
7098 pr_info("Reporting actual MCS rate %d flags %x\n",
7099 sinfo->txrate.mcs,
7100 sinfo->txrate.flags );
7101#endif //LINKSPEED_DEBUG_ENABLED
7102 }
7103 }
7104 sinfo->filled |= STATION_INFO_TX_BITRATE;
7105
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007106 sinfo->tx_packets =
7107 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7108 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7109 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7110 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7111
7112 sinfo->tx_retries =
7113 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7114 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7115 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7116 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7117
7118 sinfo->tx_failed =
7119 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7120 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7121 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7122 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7123
7124 sinfo->filled |=
7125 STATION_INFO_TX_PACKETS |
7126 STATION_INFO_TX_RETRIES |
7127 STATION_INFO_TX_FAILED;
7128
7129 EXIT();
7130 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007131}
7132
7133static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007134 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007135{
7136 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307137 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007138 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307139 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007140
Jeff Johnsone7245742012-09-05 17:12:55 -07007141 ENTER();
7142
Jeff Johnson295189b2012-06-20 16:38:30 -07007143 if (NULL == pAdapter)
7144 {
7145 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7146 return -ENODEV;
7147 }
7148
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307149 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307150 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307151
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307152 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307153 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307154 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7155 "%s: HDD context is not valid", __func__);
7156 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307157 }
7158
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307159 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7160 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7161 (pHddCtx->cfg_ini->fhostArpOffload) &&
7162 (eConnectionState_Associated ==
7163 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7164 {
Amar Singhald53568e2013-09-26 11:03:45 -07007165
7166 hddLog(VOS_TRACE_LEVEL_INFO,
7167 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307168 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307169 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7170 {
7171 hddLog(VOS_TRACE_LEVEL_INFO,
7172 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
7173 __func__, vos_status);
7174 }
7175 }
7176
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 /**The get power cmd from the supplicant gets updated by the nl only
7178 *on successful execution of the function call
7179 *we are oppositely mapped w.r.t mode in the driver
7180 **/
7181 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7182
Jeff Johnsone7245742012-09-05 17:12:55 -07007183 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007184 if (VOS_STATUS_E_FAILURE == vos_status)
7185 {
7186 return -EINVAL;
7187 }
7188 return 0;
7189}
7190
7191
7192#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7193static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7194 struct net_device *netdev,
7195 u8 key_index)
7196{
Jeff Johnsone7245742012-09-05 17:12:55 -07007197 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 return 0;
7199}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307200#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007201
7202#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7203static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7204 struct net_device *dev,
7205 struct ieee80211_txq_params *params)
7206{
Jeff Johnsone7245742012-09-05 17:12:55 -07007207 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 return 0;
7209}
7210#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7211static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7212 struct ieee80211_txq_params *params)
7213{
Jeff Johnsone7245742012-09-05 17:12:55 -07007214 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007215 return 0;
7216}
7217#endif //LINUX_VERSION_CODE
7218
7219static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7220 struct net_device *dev, u8 *mac)
7221{
7222 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307223 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007224 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307225 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007226 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007227
Jeff Johnsone7245742012-09-05 17:12:55 -07007228 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307229 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007230 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307231 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 return -EINVAL;
7233 }
7234
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307235 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7236 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007237
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307238 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007239 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307240 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7241 "%s: HDD context is not valid", __func__);
7242 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007243 }
7244
Jeff Johnson295189b2012-06-20 16:38:30 -07007245 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 )
7248 {
7249 if( NULL == mac )
7250 {
7251 v_U16_t i;
7252 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7253 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007254 if ((pAdapter->aStaInfo[i].isUsed) &&
7255 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 {
7257 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7258 hddLog(VOS_TRACE_LEVEL_INFO,
7259 "%s: Delete STA with MAC::"
7260 "%02x:%02x:%02x:%02x:%02x:%02x",
7261 __func__,
7262 macAddr[0], macAddr[1], macAddr[2],
7263 macAddr[3], macAddr[4], macAddr[5]);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007264 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7265 if (VOS_IS_STATUS_SUCCESS(vos_status))
7266 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 }
7268 }
7269 }
7270 else
7271 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007272
7273 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7274 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7275 {
7276 hddLog(VOS_TRACE_LEVEL_INFO,
7277 "%s: Skip this DEL STA as this is not used::"
7278 "%02x:%02x:%02x:%02x:%02x:%02x",
7279 __func__,
7280 mac[0], mac[1], mac[2],
7281 mac[3], mac[4], mac[5]);
7282 return -ENOENT;
7283 }
7284
7285 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7286 {
7287 hddLog(VOS_TRACE_LEVEL_INFO,
7288 "%s: Skip this DEL STA as deauth is in progress::"
7289 "%02x:%02x:%02x:%02x:%02x:%02x",
7290 __func__,
7291 mac[0], mac[1], mac[2],
7292 mac[3], mac[4], mac[5]);
7293 return -ENOENT;
7294 }
7295
7296 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7297
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 hddLog(VOS_TRACE_LEVEL_INFO,
7299 "%s: Delete STA with MAC::"
7300 "%02x:%02x:%02x:%02x:%02x:%02x",
7301 __func__,
7302 mac[0], mac[1], mac[2],
7303 mac[3], mac[4], mac[5]);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007304
7305 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7306 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7307 {
7308 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7309 hddLog(VOS_TRACE_LEVEL_INFO,
7310 "%s: STA removal failed for ::"
7311 "%02x:%02x:%02x:%02x:%02x:%02x",
7312 __func__,
7313 mac[0], mac[1], mac[2],
7314 mac[3], mac[4], mac[5]);
7315 return -ENOENT;
7316 }
7317
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 }
7319 }
7320
7321 EXIT();
7322
7323 return 0;
7324}
7325
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007326static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7327 struct net_device *dev, u8 *mac, struct station_parameters *params)
7328{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007329 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007330#ifdef FEATURE_WLAN_TDLS
7331 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007332 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007333 mask = params->sta_flags_mask;
7334
7335 set = params->sta_flags_set;
7336
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007337#ifdef WLAN_FEATURE_TDLS_DEBUG
7338 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7339 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7340 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7341#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007342
7343 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7344 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007345 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007346 }
7347 }
7348#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007349 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007350}
7351
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007352
7353#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07007354#define MAX_PMKSAIDS_IN_CACHE 8
7355
7356static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
7357static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
7358
7359
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007360static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007361 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007362{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307363 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007364 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7365 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307366 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307367 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007368 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307369 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307370
Jeff Johnsone7245742012-09-05 17:12:55 -07007371 ENTER();
7372
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307373 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307374 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007375 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307376 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007377 return -EINVAL;
7378 }
7379
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307380 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7381 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007382
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307383 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007384 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307385 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7386 "%s: HDD context is not valid", __func__);
7387 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007388 }
7389
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307390 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007391 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7392
Wilson Yang6507c4e2013-10-01 20:11:19 -07007393 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007394 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307395 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007396 pmksa->bssid, WNI_CFG_BSSID_LEN))
7397 {
7398 /* BSSID matched previous entry. Overwrite it. */
7399 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307400 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007401 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307402 vos_mem_copy(PMKIDCache[j].PMKID,
7403 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007404 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307405 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007406 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007407 dump_bssid(pmksa->bssid);
7408 dump_pmkid(halHandle, pmksa->pmkid);
7409 break;
7410 }
7411 }
7412
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007413 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07007414 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007415
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007416 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307417 {
7418 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07007419 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307420 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007421 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307422 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007423 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307424 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007425 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007426 dump_bssid(pmksa->bssid);
7427 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307428 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007429 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07007430 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007431 }
7432
7433
7434 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307435 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007436 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307437 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007438 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007439 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307440 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7441 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007442 PMKIDCacheIndex);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007443 return 0;
7444}
7445
7446
Wilson Yang6507c4e2013-10-01 20:11:19 -07007447
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007448static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007449 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007450{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007451 tANI_U32 j=0;
7452 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7453 tHalHandle halHandle;
7454 int status;
7455 tANI_U8 BSSIDMatched = 0;
7456 tANI_U8 *pBSSId;
7457 hdd_context_t *pHddCtx;
7458 int result = 0;
7459
7460 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA with PMKSA_ID %d .",
7461 __func__,pmksa->pmkid);
7462
7463 /* Validate pAdapter */
7464 if (NULL == pAdapter)
7465 {
7466 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
7467 return -EINVAL;
7468 }
7469
7470 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7471 status = wlan_hdd_validate_context(pHddCtx);
7472
7473 if (0 != status)
7474 {
7475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7476 "%s: HDD context is not valid", __func__);
7477 return status;
7478 }
7479
7480 /*Retrieve halHandle*/
7481 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7482
7483 /*in case index is 0,no entry to delete*/
7484 if (0 == PMKIDCacheIndex)
7485 {
7486 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7487 __func__);
7488 return -EINVAL;
7489 }
7490
7491 /*find the matching PMKSA entry from j=0 to (index-1),
7492 * and delete the matched one
7493 */
7494 for (j = 0; j<PMKIDCacheIndex; j++)
7495 {
7496 if (vos_mem_compare(PMKIDCache[j].BSSID,
7497 pmksa->bssid,
7498 WNI_CFG_BSSID_LEN))
7499 {
7500 /* BSSID matched entry */
7501 BSSIDMatched = 1;
7502
7503 if (j<PMKIDCacheIndex-1)
7504 {
7505 /*replace the matching entry with the last entry in HDD local cache*/
7506 vos_mem_copy(PMKIDCache[j].BSSID,
7507 PMKIDCache[PMKIDCacheIndex-1].BSSID,
7508 WNI_CFG_BSSID_LEN);
7509 vos_mem_copy(PMKIDCache[j].PMKID,
7510 PMKIDCache[PMKIDCacheIndex-1].PMKID,
7511 CSR_RSN_PMKID_SIZE);
7512 }
7513
7514 /*clear the last entry in HDD cache ---[index-1]*/
7515 pBSSId =(tANI_U8 *)(PMKIDCache[PMKIDCacheIndex-1].BSSID);
7516 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
7517 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
7518
7519 /*reduce the PMKID array index*/
7520 PMKIDCacheIndex--;
7521
7522 /*delete the last PMKID cache in CSR*/
7523 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7524 if (0 != result)
7525 {
7526 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
7527 __func__,PMKIDCacheIndex);
7528 }
7529
7530 dump_bssid(pmksa->bssid);
7531 dump_pmkid(halHandle,pmksa->pmkid);
7532
7533 break;
7534 }
7535 }
7536
7537 /* we compare all entries,but cannot find matching entry */
7538 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
7539 {
7540 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: No such PMKSA entry existed %d.",
7541 __func__,pmksa->bssid);
7542 dump_bssid(pmksa->bssid);
7543 dump_pmkid(halHandle, pmksa->pmkid);
7544 return -EINVAL;
7545 }
7546 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007547}
7548
Wilson Yang6507c4e2013-10-01 20:11:19 -07007549
7550
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007551static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7552{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007553 tANI_U32 j=0;
7554 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7555 tHalHandle halHandle;
7556 hdd_context_t *pHddCtx;
7557 tANI_U8 *pBSSId;
7558 int status;
7559 int result;
7560
7561 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
7562
7563 /* Validate pAdapter */
7564 if (NULL == pAdapter)
7565 {
7566 hddLog(VOS_TRACE_LEVEL_ERROR,
7567 "%s: Invalid Adapter" ,__func__);
7568 return -EINVAL;
7569 }
7570
7571 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7572 status = wlan_hdd_validate_context(pHddCtx);
7573
7574 if (0 != status)
7575 {
7576 hddLog(VOS_TRACE_LEVEL_ERROR,
7577 "%s: HDD context is not valid", __func__);
7578 return status;
7579 }
7580
7581 /*Retrieve halHandle*/
7582 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7583
7584 /*in case index is 0,no entry to delete*/
7585 if (0 == PMKIDCacheIndex)
7586 {
7587 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7588 __func__);
7589 return -EINVAL;
7590 }
7591
7592 /*delete all the PMKSA one by one */
7593 for (j = 0; j<PMKIDCacheIndex; j++)
7594 {
7595 /*clear the entry in HDD cache 0--index-1 */
7596 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
7597 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
7598 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
7599
7600 /*delete the PMKID in CSR*/
7601 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7602
7603 if (0!= result)
7604 {
7605 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
7606 __func__,j);
7607 }
7608 }
7609
7610 PMKIDCacheIndex = 0;
7611 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007612}
7613#endif
7614
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007615#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307616static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007617 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7618{
7619 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7620 hdd_station_ctx_t *pHddStaCtx;
7621
7622 if (NULL == pAdapter)
7623 {
7624 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7625 return -ENODEV;
7626 }
7627
7628 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7629
7630 // Added for debug on reception of Re-assoc Req.
7631 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7632 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307633 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007634 ftie->ie_len);
7635 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7636 }
7637
7638#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307639 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007640 ftie->ie_len);
7641#endif
7642
7643 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307644 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7645 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007646 ftie->ie_len);
7647 return 0;
7648}
7649#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007650
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307651#ifdef FEATURE_WLAN_SCAN_PNO
7652
7653void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7654 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7655{
7656 int ret;
7657 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7658 hdd_context_t *pHddCtx;
7659
7660 if (NULL == pAdapter)
7661 {
7662 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7663 "%s: HDD adapter is Null", __func__);
7664 return ;
7665 }
7666
7667 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7668 if (NULL == pHddCtx)
7669 {
7670 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7671 "%s: HDD context is Null!!!", __func__);
7672 return ;
7673 }
7674
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307675 spin_lock(&pHddCtx->schedScan_lock);
7676 if (TRUE == pHddCtx->isWiphySuspended)
7677 {
7678 pHddCtx->isSchedScanUpdatePending = TRUE;
7679 spin_unlock(&pHddCtx->schedScan_lock);
7680 hddLog(VOS_TRACE_LEVEL_INFO,
7681 "%s: Update cfg80211 scan database after it resume", __func__);
7682 return ;
7683 }
7684 spin_unlock(&pHddCtx->schedScan_lock);
7685
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307686 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7687
7688 if (0 > ret)
7689 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7690
7691 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7693 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307694}
7695
7696/*
7697 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7698 * NL interface to enable PNO
7699 */
7700static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7701 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7702{
7703 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7704 tpSirPNOScanReq pPnoRequest = NULL;
7705 hdd_context_t *pHddCtx;
7706 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307707 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307708 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7709 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7710 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7711 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307712 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307713
7714 if (NULL == pAdapter)
7715 {
7716 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7717 "%s: HDD adapter is Null", __func__);
7718 return -ENODEV;
7719 }
7720
7721 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307722 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307723
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307724 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307725 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307726 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7727 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307728 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307729 }
7730
7731 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7732 if (NULL == hHal)
7733 {
7734 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7735 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307736 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307737 }
7738
7739 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7740 if (NULL == pPnoRequest)
7741 {
7742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7743 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307744 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307745 }
7746
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05307747 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307748 pPnoRequest->enable = 1; /*Enable PNO */
7749 pPnoRequest->ucNetworksCount = request->n_match_sets;
7750
7751 if (( !pPnoRequest->ucNetworksCount ) ||
7752 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7753 {
7754 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7755 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307756 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307757 goto error;
7758 }
7759
7760 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7761 {
7762 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7763 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307764 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307765 goto error;
7766 }
7767
7768 /* Framework provides one set of channels(all)
7769 * common for all saved profile */
7770 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7771 channels_allowed, &num_channels_allowed))
7772 {
7773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7774 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307775 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307776 goto error;
7777 }
7778 /* Checking each channel against allowed channel list */
7779 num_ch = 0;
7780 for (i = 0; i < request->n_channels; i++)
7781 {
7782 for (indx = 0; indx < num_channels_allowed; indx++)
7783 {
7784 if (request->channels[i]->hw_value == channels_allowed[indx])
7785 {
7786 valid_ch[num_ch++] = request->channels[i]->hw_value;
7787 break ;
7788 }
7789 }
7790 }
7791
7792 /* Filling per profile params */
7793 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7794 {
7795 pPnoRequest->aNetworks[i].ssId.length =
7796 request->match_sets[i].ssid.ssid_len;
7797
7798 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7799 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7800 {
7801 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7802 "SSID Len %d is not correct for network %d",
7803 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307804 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307805 goto error;
7806 }
7807
7808 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7809 request->match_sets[i].ssid.ssid,
7810 request->match_sets[i].ssid.ssid_len);
7811 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7812 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7813 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7814
7815 /*Copying list of valid channel into request */
7816 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7817 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7818
7819 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7820 }
7821
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05307822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7823 "request->ie_len = %d", request->ie_len);
7824 if ((0 < request->ie_len) && (NULL != request->ie))
7825 {
7826 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
7827 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
7828 pPnoRequest->us24GProbeTemplateLen);
7829
7830 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
7831 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
7832 pPnoRequest->us5GProbeTemplateLen);
7833 }
7834
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307835 /* Driver gets only one time interval which is hardcoded in
7836 * supplicant for 10000ms. Taking power consumption into account 6 timers
7837 * will be used, Timervalue is increased exponentially i.e 10,20,40,
7838 * 80,160,320 secs. And number of scan cycle for each timer
7839 * is configurable through INI param gPNOScanTimerRepeatValue.
7840 * If it is set to 0 only one timer will be used and PNO scan cycle
7841 * will be repeated after each interval specified by supplicant
7842 * till PNO is disabled.
7843 */
7844 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
7845 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
7846 else
7847 pPnoRequest->scanTimers.ucScanTimersCount =
7848 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
7849
7850 tempInterval = (request->interval)/1000;
7851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7852 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
7853 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
7854 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
7855 {
7856 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
7857 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
7858 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
7859 tempInterval *= 2;
7860 }
7861 //Repeat last timer until pno disabled.
7862 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
7863
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05307864 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307865
7866 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7867 pPnoRequest, pAdapter->sessionId,
7868 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7869 if (eHAL_STATUS_SUCCESS != status)
7870 {
7871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7872 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307873 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307874 goto error;
7875 }
7876
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307877 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7878 "PNO scanRequest offloaded");
7879
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307880error:
7881 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307882 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307883}
7884
7885/*
7886 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
7887 * NL interface to disable PNO
7888 */
7889static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
7890 struct net_device *dev)
7891{
7892 eHalStatus status = eHAL_STATUS_FAILURE;
7893 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7894 hdd_context_t *pHddCtx;
7895 tHalHandle hHal;
7896 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307897 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307898
7899 ENTER();
7900
7901 if (NULL == pAdapter)
7902 {
7903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7904 "%s: HDD adapter is Null", __func__);
7905 return -ENODEV;
7906 }
7907
7908 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307909
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307910 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307911 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307912 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307913 "%s: HDD context is Null", __func__);
7914 return -ENODEV;
7915 }
7916
7917 /* The return 0 is intentional when isLogpInProgress and
7918 * isLoadUnloadInProgress. We did observe a crash due to a return of
7919 * failure in sched_scan_stop , especially for a case where the unload
7920 * of the happens at the same time. The function __cfg80211_stop_sched_scan
7921 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
7922 * success. If it returns a failure , then its next invocation due to the
7923 * clean up of the second interface will have the dev pointer corresponding
7924 * to the first one leading to a crash.
7925 */
7926 if (pHddCtx->isLogpInProgress)
7927 {
7928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7929 "%s: LOGP in Progress. Ignore!!!", __func__);
7930 return ret;
7931 }
7932
7933 if (pHddCtx->isLoadUnloadInProgress)
7934 {
7935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7936 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
7937 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307938 }
7939
7940 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7941 if (NULL == hHal)
7942 {
7943 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7944 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307945 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307946 }
7947
7948 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7949 if (NULL == pPnoRequest)
7950 {
7951 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7952 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307953 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307954 }
7955
7956 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
7957 pPnoRequest->enable = 0; /* Disable PNO */
7958 pPnoRequest->ucNetworksCount = 0;
7959
7960 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
7961 pAdapter->sessionId,
7962 NULL, pAdapter);
7963 if (eHAL_STATUS_SUCCESS != status)
7964 {
7965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7966 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307967 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307968 }
7969
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307970 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7971 "%s: PNO scan disabled", __func__);
7972
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307973 vos_mem_free(pPnoRequest);
7974
7975 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307976 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307977}
7978
7979#endif /*FEATURE_WLAN_SCAN_PNO*/
7980
7981
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007982#ifdef FEATURE_WLAN_TDLS
7983static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
7984 u8 *peer, u8 action_code, u8 dialog_token,
7985 u16 status_code, const u8 *buf, size_t len)
7986{
7987
7988 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7989 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007990 u8 peerMac[6];
7991 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007992 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08007993 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007994 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007995
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007996 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007997 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307998 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007999 "Invalid arguments");
8000 return -EINVAL;
8001 }
8002
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008003 if (pHddCtx->isLogpInProgress)
8004 {
8005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8006 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008007 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008008 return -EBUSY;
8009 }
8010
Hoonki Lee27511902013-03-14 18:19:06 -07008011 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008012 {
Hoonki Lee27511902013-03-14 18:19:06 -07008013 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8014 "%s: TDLS mode is disabled OR not enabled in FW."
8015 MAC_ADDRESS_STR " action %d declined.",
8016 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008017 return -ENOTSUPP;
8018 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008019
Hoonki Lee27511902013-03-14 18:19:06 -07008020 /* other than teardown frame, other mgmt frames are not sent if disabled */
8021 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8022 {
8023 /* if tdls_mode is disabled to respond to peer's request */
8024 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8025 {
8026 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8027 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008028 " TDLS mode is disabled. action %d declined.",
8029 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008030
8031 return -ENOTSUPP;
8032 }
8033 }
8034
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008035 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8036 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308037 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008038 {
8039 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008040 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008041 " TDLS setup is ongoing. action %d declined.",
8042 __func__, MAC_ADDR_ARRAY(peer), action_code);
8043 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008044 }
8045 }
8046
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008047 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8048 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008049 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008050 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008051 {
8052 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
8053 we return error code at 'add_station()'. Hence we have this
8054 check again in addtion to add_station().
8055 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008056 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008057 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008058 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8059 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008060 " TDLS Max peer already connected. action %d declined.",
8061 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008062 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08008063 }
8064 else
8065 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008066 /* maximum reached. tweak to send error code to peer and return
8067 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008068 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008069 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8070 "%s: " MAC_ADDRESS_STR
8071 " TDLS Max peer already connected send response status %d",
8072 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008073 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008074 /* fall through to send setup resp with failure status
8075 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008076 }
8077 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008078 else
8079 {
8080 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308081 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008082 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008083 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008084 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008085 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
8086 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008087 return -EPERM;
8088 }
8089 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008090 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008091 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008092
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008093#ifdef WLAN_FEATURE_TDLS_DEBUG
8094 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008095 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
8096 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
8097 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008098#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008099
Hoonki Leea34dd892013-02-05 22:56:02 -08008100 /*Except teardown responder will not be used so just make 0*/
8101 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008102 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08008103 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008104
8105 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308106 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008107
8108 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
8109 responder = pTdlsPeer->is_responder;
8110 else
Hoonki Leea34dd892013-02-05 22:56:02 -08008111 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8113 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
8114 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
8115 dialog_token, status_code, len);
8116 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08008117 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008118 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008119
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308120 /* For explicit trigger of DIS_REQ come out of BMPS for
8121 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008122 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308123 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8124 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008125 {
8126 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8127 {
8128 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308129 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008130 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8131 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308132 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8133 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008134 }
8135
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008136 /* make sure doesn't call send_mgmt() while it is pending */
8137 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8138 {
8139 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8140 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
8141 __func__, MAC_ADDR_ARRAY(peer), action_code);
8142 return -EBUSY;
8143 }
8144
8145 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008146 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
8147
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008148 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08008149 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008150
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008151 if (VOS_STATUS_SUCCESS != status)
8152 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8154 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008155 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07008156 wlan_hdd_tdls_check_bmps(pAdapter);
8157 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008158 }
8159
Hoonki Leed37cbb32013-04-20 00:31:14 -07008160 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
8161 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
8162
8163 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008164 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07008165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8166 "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu",
8167 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008168 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008169 wlan_hdd_tdls_check_bmps(pAdapter);
8170 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008171 }
8172
Gopichand Nakkala05922802013-03-14 12:23:19 -07008173 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07008174 {
8175 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008176 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07008177 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008178
Hoonki Leea34dd892013-02-05 22:56:02 -08008179 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
8180 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008181 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008182 }
8183 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
8184 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008185 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008186 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008187
8188 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008189error:
8190 /* max_sta_failed ; we didn't set to CONNECTING for this case,
8191 because we already know that this transaction will be failed,
8192 but we weren't sure if supplicant call DISABLE_LINK or not. So,
8193 to be safe, do not change the state mahine.
8194 */
8195 if(max_sta_failed == 0 &&
8196 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
8197 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
8198 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008199}
8200
8201static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
8202 u8 *peer, enum nl80211_tdls_operation oper)
8203{
8204 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8205 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308206 int status;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008207#ifdef WLAN_FEATURE_TDLS_DEBUG
8208 const char *tdls_oper_str[]= {
8209 "NL80211_TDLS_DISCOVERY_REQ",
8210 "NL80211_TDLS_SETUP",
8211 "NL80211_TDLS_TEARDOWN",
8212 "NL80211_TDLS_ENABLE_LINK",
8213 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05308214 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008215#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008216 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008217
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308218 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008219 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008220 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008221 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008222 return -EINVAL;
8223 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008224
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308225 status = wlan_hdd_validate_context(pHddCtx);
8226
8227 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008228 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308229 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8230 "%s: HDD context is not valid", __func__);
8231 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008232 }
8233
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308234 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008235
8236 if ( NULL == pTdlsPeer ) {
8237 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
8238 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8239 return -EINVAL;
8240 }
8241
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008242#ifdef WLAN_FEATURE_TDLS_DEBUG
8243 if((int)oper > 4)
8244 oper = 5;
8245
8246 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008247 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8248 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008249 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008250#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008251
8252 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008253 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008254 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008255 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008256 "TDLS Disabled in INI OR not enabled in FW. "
8257 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008258 return -ENOTSUPP;
8259 }
8260
8261 switch (oper) {
8262 case NL80211_TDLS_ENABLE_LINK:
8263 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008264 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308265 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008266
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07008267 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
8268 {
8269 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
8270 MAC_ADDRESS_STR " failed",
8271 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
8272 return -EINVAL;
8273 }
8274
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008275 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008276 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308277 long ret;
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308278 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308279
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308280 if (0 != wlan_hdd_tdls_get_link_establish_params(
8281 pAdapter, peer,&tdlsLinkEstablishParams)) {
8282 return -EINVAL;
8283 }
8284 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308285
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308286 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
8287 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
8288 /* Send TDLS peer UAPSD capabilities to the firmware and
8289 * register with the TL on after the response for this operation
8290 * is received .
8291 */
8292 ret = wait_for_completion_interruptible_timeout(
8293 &pAdapter->tdls_link_establish_req_comp,
8294 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
8295 if (ret <= 0)
8296 {
8297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8298 "%s: Link Establish Request Faled Status %ld",
8299 __func__, ret);
8300 return -EINVAL;
8301 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308302 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008303 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05308304 /* Mark TDLS client Authenticated .*/
8305 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
8306 pTdlsPeer->staId,
8307 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008308 if (VOS_STATUS_SUCCESS == status)
8309 {
Hoonki Lee14621352013-04-16 17:51:19 -07008310 if (pTdlsPeer->is_responder == 0)
8311 {
8312 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
8313
8314 wlan_hdd_tdls_timer_restart(pAdapter,
8315 &pTdlsPeer->initiatorWaitTimeoutTimer,
8316 WAIT_TIME_TDLS_INITIATOR);
8317 /* suspend initiator TX until it receives direct packet from the
8318 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
8319 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8320 &staId, NULL);
8321 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008322 wlan_hdd_tdls_increment_peer_count(pAdapter);
8323 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008324 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308325
8326 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308327 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
8328 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308329 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308330 int ac;
8331 uint8 ucAc[4] = { WLANTL_AC_VO,
8332 WLANTL_AC_VI,
8333 WLANTL_AC_BK,
8334 WLANTL_AC_BE };
8335 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
8336 for(ac=0; ac < 4; ac++)
8337 {
8338 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8339 pTdlsPeer->staId, ucAc[ac],
8340 tlTid[ac], tlTid[ac], 0, 0,
8341 WLANTL_BI_DIR );
8342 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308343 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008344 }
8345
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008346 }
8347 break;
8348 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08008349 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008350 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008351 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008352 long status;
8353
8354 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
8355
Lee Hoonkic1262f22013-01-24 21:59:00 -08008356 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
8357 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008358
8359 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
8360 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
8361 if (status <= 0)
8362 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008363 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8365 "%s: Del station failed status %ld",
8366 __func__, status);
8367 return -EPERM;
8368 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008369 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008370 }
8371 else
8372 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008373 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8374 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008375 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008376 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008377 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008378 case NL80211_TDLS_TEARDOWN:
8379 case NL80211_TDLS_SETUP:
8380 case NL80211_TDLS_DISCOVERY_REQ:
8381 /* We don't support in-driver setup/teardown/discovery */
8382 return -ENOTSUPP;
8383 default:
8384 return -ENOTSUPP;
8385 }
8386 return 0;
8387}
Chilam NG571c65a2013-01-19 12:27:36 +05308388
8389int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
8390 struct net_device *dev, u8 *peer)
8391{
8392 hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x",
8393 peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]);
8394
8395 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
8396 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
8397}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008398#endif
8399
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308400#ifdef WLAN_FEATURE_GTK_OFFLOAD
8401/*
8402 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
8403 * Callback rountine called upon receiving response for
8404 * get offload info
8405 */
8406void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
8407 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
8408{
8409
8410 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308411 tANI_U8 tempReplayCounter[8];
8412 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308413
8414 ENTER();
8415
8416 if (NULL == pAdapter)
8417 {
8418 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8419 "%s: HDD adapter is Null", __func__);
8420 return ;
8421 }
8422
8423 if (NULL == pGtkOffloadGetInfoRsp)
8424 {
8425 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8426 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
8427 return ;
8428 }
8429
8430 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
8431 {
8432 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8433 "%s: wlan Failed to get replay counter value",
8434 __func__);
8435 return ;
8436 }
8437
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308438 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8439 /* Update replay counter */
8440 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
8441 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8442
8443 {
8444 /* changing from little to big endian since supplicant
8445 * works on big endian format
8446 */
8447 int i;
8448 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8449
8450 for (i = 0; i < 8; i++)
8451 {
8452 tempReplayCounter[7-i] = (tANI_U8)p[i];
8453 }
8454 }
8455
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308456 /* Update replay counter to NL */
8457 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308458 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308459}
8460
8461/*
8462 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
8463 * This function is used to offload GTK rekeying job to the firmware.
8464 */
8465int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
8466 struct cfg80211_gtk_rekey_data *data)
8467{
8468 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8469 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8470 hdd_station_ctx_t *pHddStaCtx;
8471 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308472 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308473 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308474 eHalStatus status = eHAL_STATUS_FAILURE;
8475
8476 ENTER();
8477
8478 if (NULL == pAdapter)
8479 {
8480 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8481 "%s: HDD adapter is Null", __func__);
8482 return -ENODEV;
8483 }
8484
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308485 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308486
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308487 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308488 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308489 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8490 "%s: HDD context is not valid", __func__);
8491 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308492 }
8493
8494 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8495 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8496 if (NULL == hHal)
8497 {
8498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8499 "%s: HAL context is Null!!!", __func__);
8500 return -EAGAIN;
8501 }
8502
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308503 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8504 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8505 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8506 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308507 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308508 {
8509 /* changing from big to little endian since driver
8510 * works on little endian format
8511 */
8512 tANI_U8 *p =
8513 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8514 int i;
8515
8516 for (i = 0; i < 8; i++)
8517 {
8518 p[7-i] = data->replay_ctr[i];
8519 }
8520 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308521
8522 if (TRUE == pHddCtx->hdd_wlan_suspended)
8523 {
8524 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308525 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8526 sizeof (tSirGtkOffloadParams));
8527 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308528 pAdapter->sessionId);
8529
8530 if (eHAL_STATUS_SUCCESS != status)
8531 {
8532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8533 "%s: sme_SetGTKOffload failed, returned %d",
8534 __func__, status);
8535 return status;
8536 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8538 "%s: sme_SetGTKOffload successfull", __func__);
8539 }
8540 else
8541 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8543 "%s: wlan not suspended GTKOffload request is stored",
8544 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308545 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308546
8547 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308548}
8549#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8550
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308551/*
8552 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8553 * This function is used to set access control policy
8554 */
8555static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8556 struct net_device *dev, const struct cfg80211_acl_data *params)
8557{
8558 int i;
8559 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8560 hdd_hostapd_state_t *pHostapdState;
8561 tsap_Config_t *pConfig;
8562 v_CONTEXT_t pVosContext = NULL;
8563 hdd_context_t *pHddCtx;
8564 int status;
8565
8566 ENTER();
8567
8568 if (NULL == pAdapter)
8569 {
8570 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8571 "%s: HDD adapter is Null", __func__);
8572 return -ENODEV;
8573 }
8574
8575 if (NULL == params)
8576 {
8577 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8578 "%s: params is Null", __func__);
8579 return -EINVAL;
8580 }
8581
8582 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8583 status = wlan_hdd_validate_context(pHddCtx);
8584
8585 if (0 != status)
8586 {
8587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8588 "%s: HDD context is not valid", __func__);
8589 return status;
8590 }
8591
8592 pVosContext = pHddCtx->pvosContext;
8593 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8594
8595 if (NULL == pHostapdState)
8596 {
8597 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8598 "%s: pHostapdState is Null", __func__);
8599 return -EINVAL;
8600 }
8601
8602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8603 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8604
8605 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8606 {
8607 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8608
8609 /* default value */
8610 pConfig->num_accept_mac = 0;
8611 pConfig->num_deny_mac = 0;
8612
8613 /**
8614 * access control policy
8615 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8616 * listed in hostapd.deny file.
8617 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8618 * listed in hostapd.accept file.
8619 */
8620 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8621 {
8622 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8623 }
8624 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8625 {
8626 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8627 }
8628 else
8629 {
8630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8631 "%s:Acl Policy : %d is not supported",
8632 __func__, params->acl_policy);
8633 return -ENOTSUPP;
8634 }
8635
8636 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8637 {
8638 pConfig->num_accept_mac = params->n_acl_entries;
8639 for (i = 0; i < params->n_acl_entries; i++)
8640 {
8641 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8642 "** Add ACL MAC entry %i in WhiletList :"
8643 MAC_ADDRESS_STR, i,
8644 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8645
8646 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8647 sizeof(qcmacaddr));
8648 }
8649 }
8650 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8651 {
8652 pConfig->num_deny_mac = params->n_acl_entries;
8653 for (i = 0; i < params->n_acl_entries; i++)
8654 {
8655 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8656 "** Add ACL MAC entry %i in BlackList :"
8657 MAC_ADDRESS_STR, i,
8658 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8659
8660 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8661 sizeof(qcmacaddr));
8662 }
8663 }
8664
8665 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8666 {
8667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8668 "%s: SAP Set Mac Acl fail", __func__);
8669 return -EINVAL;
8670 }
8671 }
8672 else
8673 {
8674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8675 "%s: Invalid device_mode = %d",
8676 __func__, pAdapter->device_mode);
8677 return -EINVAL;
8678 }
8679
8680 return 0;
8681}
8682
Leo Chang9056f462013-08-01 19:21:11 -07008683#ifdef WLAN_NL80211_TESTMODE
8684#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07008685void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07008686(
8687 void *pAdapter,
8688 void *indCont
8689)
8690{
Leo Changd9df8aa2013-09-26 13:32:26 -07008691 tSirLPHBInd *lphbInd;
8692 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07008693
8694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008695 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07008696
8697 if (NULL == indCont)
8698 {
8699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008700 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07008701 return;
8702 }
8703
Leo Changd9df8aa2013-09-26 13:32:26 -07008704 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07008705 skb = cfg80211_testmode_alloc_event_skb(
8706 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07008707 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07008708 GFP_ATOMIC);
8709 if (!skb)
8710 {
8711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8712 "LPHB timeout, NL buffer alloc fail");
8713 return;
8714 }
8715
Leo Changd9df8aa2013-09-26 13:32:26 -07008716 if(!nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
8717 {
8718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8719 "WLAN_HDD_TM_ATTR_CMD put fail");
8720 goto nla_put_failure;
8721 }
8722 if(!nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
8723 {
8724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8725 "WLAN_HDD_TM_ATTR_TYPE put fail");
8726 goto nla_put_failure;
8727 }
8728 if(!nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
8729 sizeof(tSirLPHBInd), lphbInd))
8730 {
8731 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8732 "WLAN_HDD_TM_ATTR_DATA put fail");
8733 goto nla_put_failure;
8734 }
Leo Chang9056f462013-08-01 19:21:11 -07008735 cfg80211_testmode_event(skb, GFP_ATOMIC);
8736 return;
8737
8738nla_put_failure:
8739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8740 "NLA Put fail");
8741 kfree_skb(skb);
8742
8743 return;
8744}
8745#endif /* FEATURE_WLAN_LPHB */
8746
8747static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8748{
8749 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8750 int err = 0;
8751#ifdef FEATURE_WLAN_LPHB
8752 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07008753 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07008754#endif /* FEATURE_WLAN_LPHB */
8755
8756 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8757 if (err)
8758 {
8759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8760 "%s Testmode INV ATTR", __func__);
8761 return err;
8762 }
8763
8764 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8765 {
8766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8767 "%s Testmode INV CMD", __func__);
8768 return -EINVAL;
8769 }
8770
8771 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8772 {
8773#ifdef FEATURE_WLAN_LPHB
8774 /* Low Power Heartbeat configuration request */
8775 case WLAN_HDD_TM_CMD_WLAN_HB:
8776 {
8777 int buf_len;
8778 void *buf;
8779 tSirLPHBReq *hb_params = NULL;
8780
8781 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8782 {
8783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8784 "%s Testmode INV DATA", __func__);
8785 return -EINVAL;
8786 }
8787
8788 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8789 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8790 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8791 if (NULL == hb_params)
8792 {
8793 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8794 "%s Request Buffer Alloc Fail", __func__);
8795 return -EINVAL;
8796 }
8797
8798 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07008799 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8800 hb_params,
8801 wlan_hdd_cfg80211_lphb_ind_handler);
8802 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07008803 {
Leo Changd9df8aa2013-09-26 13:32:26 -07008804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8805 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07008806 vos_mem_free(hb_params);
8807 }
Leo Chang9056f462013-08-01 19:21:11 -07008808 return 0;
8809 }
8810#endif /* FEATURE_WLAN_LPHB */
8811 default:
8812 return -EOPNOTSUPP;
8813 }
8814
8815 return err;
8816}
8817#endif /* CONFIG_NL80211_TESTMODE */
8818
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308819static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8820 struct net_device *dev,
8821 int idx, struct survey_info *survey)
8822{
8823 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8824 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308825 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308826 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308827 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308828 v_S7_t snr,rssi;
8829 int status, i, j, filled = 0;
8830
8831 ENTER();
8832
8833
8834 if (NULL == pAdapter)
8835 {
8836 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8837 "%s: HDD adapter is Null", __func__);
8838 return -ENODEV;
8839 }
8840
8841 if (NULL == wiphy)
8842 {
8843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8844 "%s: wiphy is Null", __func__);
8845 return -ENODEV;
8846 }
8847
8848 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8849 status = wlan_hdd_validate_context(pHddCtx);
8850
8851 if (0 != status)
8852 {
8853 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8854 "%s: HDD context is not valid", __func__);
8855 return status;
8856 }
8857
Mihir Sheted9072e02013-08-21 17:02:29 +05308858 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8859
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308860 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308861 0 != pAdapter->survey_idx ||
8862 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308863 {
8864 /* The survey dump ops when implemented completely is expected to
8865 * return a survey of all channels and the ops is called by the
8866 * kernel with incremental values of the argument 'idx' till it
8867 * returns -ENONET. But we can only support the survey for the
8868 * operating channel for now. survey_idx is used to track
8869 * that the ops is called only once and then return -ENONET for
8870 * the next iteration
8871 */
8872 pAdapter->survey_idx = 0;
8873 return -ENONET;
8874 }
8875
8876 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8877
8878 wlan_hdd_get_snr(pAdapter, &snr);
8879 wlan_hdd_get_rssi(pAdapter, &rssi);
8880
8881 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
8882 hdd_wlan_get_freq(channel, &freq);
8883
8884
8885 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8886 {
8887 if (NULL == wiphy->bands[i])
8888 {
8889 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
8890 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
8891 continue;
8892 }
8893
8894 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8895 {
8896 struct ieee80211_supported_band *band = wiphy->bands[i];
8897
8898 if (band->channels[j].center_freq == (v_U16_t)freq)
8899 {
8900 survey->channel = &band->channels[j];
8901 /* The Rx BDs contain SNR values in dB for the received frames
8902 * while the supplicant expects noise. So we calculate and
8903 * return the value of noise (dBm)
8904 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
8905 */
8906 survey->noise = rssi - snr;
8907 survey->filled = SURVEY_INFO_NOISE_DBM;
8908 filled = 1;
8909 }
8910 }
8911 }
8912
8913 if (filled)
8914 pAdapter->survey_idx = 1;
8915 else
8916 {
8917 pAdapter->survey_idx = 0;
8918 return -ENONET;
8919 }
8920
8921 return 0;
8922}
8923
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308924/*
8925 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
8926 * this is called when cfg80211 driver resume
8927 * driver updates latest sched_scan scan result(if any) to cfg80211 database
8928 */
8929int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
8930{
8931 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8932 hdd_adapter_t *pAdapter;
8933 hdd_adapter_list_node_t *pAdapterNode, *pNext;
8934 VOS_STATUS status = VOS_STATUS_SUCCESS;
8935
8936 ENTER();
8937
8938 if ( NULL == pHddCtx )
8939 {
8940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8941 "%s: HddCtx validation failed", __func__);
8942 return 0;
8943 }
8944
8945 if (pHddCtx->isLogpInProgress)
8946 {
8947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8948 "%s: LOGP in Progress. Ignore!!!", __func__);
8949 return 0;
8950 }
8951
8952 if (pHddCtx->isLoadUnloadInProgress)
8953 {
8954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8955 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8956 return 0;
8957 }
8958
8959 spin_lock(&pHddCtx->schedScan_lock);
8960 pHddCtx->isWiphySuspended = FALSE;
8961 if (TRUE != pHddCtx->isSchedScanUpdatePending)
8962 {
8963 spin_unlock(&pHddCtx->schedScan_lock);
8964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8965 "%s: Return resume is not due to PNO indication", __func__);
8966 return 0;
8967 }
8968 // Reset flag to avoid updatating cfg80211 data old results again
8969 pHddCtx->isSchedScanUpdatePending = FALSE;
8970 spin_unlock(&pHddCtx->schedScan_lock);
8971
8972 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8973
8974 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8975 {
8976 pAdapter = pAdapterNode->pAdapter;
8977 if ( (NULL != pAdapter) &&
8978 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
8979 {
8980 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
8981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8982 "%s: NO SCAN result", __func__);
8983 else
8984 cfg80211_sched_scan_results(pHddCtx->wiphy);
8985
8986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8987 "%s : cfg80211 scan result database updated", __func__);
8988
8989 return 0;
8990
8991 }
8992 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8993 pAdapterNode = pNext;
8994 }
8995
8996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8997 "%s: Failed to find Adapter", __func__);
8998 return 0;
8999}
9000
9001/*
9002 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
9003 * this is called when cfg80211 driver suspends
9004 */
9005int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
9006 struct cfg80211_wowlan *wow)
9007{
9008 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9009
9010 ENTER();
9011 if (NULL == pHddCtx)
9012 {
9013 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9014 "%s: HddCtx validation failed", __func__);
9015 return 0;
9016 }
9017
9018 pHddCtx->isWiphySuspended = TRUE;
9019
9020 EXIT();
9021
9022 return 0;
9023}
9024
Jeff Johnson295189b2012-06-20 16:38:30 -07009025/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309026static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07009027{
9028 .add_virtual_intf = wlan_hdd_add_virtual_intf,
9029 .del_virtual_intf = wlan_hdd_del_virtual_intf,
9030 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
9031 .change_station = wlan_hdd_change_station,
9032#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9033 .add_beacon = wlan_hdd_cfg80211_add_beacon,
9034 .del_beacon = wlan_hdd_cfg80211_del_beacon,
9035 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009036#else
9037 .start_ap = wlan_hdd_cfg80211_start_ap,
9038 .change_beacon = wlan_hdd_cfg80211_change_beacon,
9039 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07009040#endif
9041 .change_bss = wlan_hdd_cfg80211_change_bss,
9042 .add_key = wlan_hdd_cfg80211_add_key,
9043 .get_key = wlan_hdd_cfg80211_get_key,
9044 .del_key = wlan_hdd_cfg80211_del_key,
9045 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009046#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009047 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009048#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009049 .scan = wlan_hdd_cfg80211_scan,
9050 .connect = wlan_hdd_cfg80211_connect,
9051 .disconnect = wlan_hdd_cfg80211_disconnect,
9052 .join_ibss = wlan_hdd_cfg80211_join_ibss,
9053 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
9054 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
9055 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
9056 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
9058 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
9059 .mgmt_tx = wlan_hdd_action,
9060#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9061 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
9062 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
9063 .set_txq_params = wlan_hdd_set_txq_params,
9064#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009065 .get_station = wlan_hdd_cfg80211_get_station,
9066 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
9067 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009068 .add_station = wlan_hdd_cfg80211_add_station,
9069#ifdef FEATURE_WLAN_LFR
9070 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
9071 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
9072 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
9073#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009074#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
9075 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
9076#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009077#ifdef FEATURE_WLAN_TDLS
9078 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
9079 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
9080#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309081#ifdef WLAN_FEATURE_GTK_OFFLOAD
9082 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
9083#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309084#ifdef FEATURE_WLAN_SCAN_PNO
9085 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
9086 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
9087#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309088 .resume = wlan_hdd_cfg80211_resume_wlan,
9089 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309090 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07009091#ifdef WLAN_NL80211_TESTMODE
9092 .testmode_cmd = wlan_hdd_cfg80211_testmode,
9093#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309094 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009095};
9096