blob: 1cd022553ecebf724c8d94e3d4e9025226475ac9 [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
Wilson Yang00256342013-10-10 23:13:38 -07006261 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006262 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6263 params->ie_len, DOT11F_EID_WPA);
6264 if ( NULL != ie )
6265 {
6266 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6267 // Unpack the WPA IE
6268 //Skip past the EID byte and length byte - and four byte WiFi OUI
6269 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6270 &ie[2+4],
6271 ie[1] - 4,
6272 &dot11WPAIE);
6273 /*Extract the multicast cipher, the encType for unicast
6274 cipher for wpa-none is none*/
6275 encryptionType =
6276 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006279
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6281
6282 if (0 > status)
6283 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306284 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 __func__);
6286 return status;
6287 }
6288 }
6289
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306290 pWextState->roamProfile.AuthType.authType[0] =
6291 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6293
6294 if (params->privacy)
6295 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306296 /* Security enabled IBSS, At this time there is no information available
6297 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006298 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306299 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306301 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 *enable privacy bit in beacons */
6303
6304 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6305 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006306 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6307 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6309 pWextState->roamProfile.EncryptionType.numEntries = 1;
6310 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 return status;
6312}
6313
6314/*
6315 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306316 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006317 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306318static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006319 struct net_device *dev,
6320 struct cfg80211_ibss_params *params
6321 )
6322{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306323 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6325 tCsrRoamProfile *pRoamProfile;
6326 int status;
6327 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306328 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006329
6330 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306331
6332 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6334
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306335 status = wlan_hdd_validate_context(pHddCtx);
6336
6337 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6340 "%s: HDD context is not valid", __func__);
6341 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 }
6343
6344 if (NULL == pWextState)
6345 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306346 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 __func__);
6348 return -EIO;
6349 }
6350
6351 pRoamProfile = &pWextState->roamProfile;
6352
6353 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6354 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306355 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 "%s Interface type is not set to IBSS \n", __func__);
6357 return -EINVAL;
6358 }
6359
6360 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006361 if (NULL !=
6362#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6363 params->chandef.chan)
6364#else
6365 params->channel)
6366#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 {
6368 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006369 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6370 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6371 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6372 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006373
6374 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306375 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006376 ieee80211_frequency_to_channel(
6377#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6378 params->chandef.chan->center_freq);
6379#else
6380 params->channel->center_freq);
6381#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006382
6383 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6384 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006386 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6387 __func__);
6388 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006390
6391 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006393 if (channelNum == validChan[indx])
6394 {
6395 break;
6396 }
6397 }
6398 if (indx >= numChans)
6399 {
6400 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 __func__, channelNum);
6402 return -EINVAL;
6403 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006404 /* Set the Operational Channel */
6405 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6406 channelNum);
6407 pRoamProfile->ChannelInfo.numOfChannels = 1;
6408 pHddStaCtx->conn_info.operationChannel = channelNum;
6409 pRoamProfile->ChannelInfo.ChannelList =
6410 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 }
6412
6413 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306414 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006415 if (status < 0)
6416 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306417 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006418 __func__);
6419 return status;
6420 }
6421
6422 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306423 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006424 params->ssid_len, params->bssid,
6425 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006426
6427 if (0 > status)
6428 {
6429 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6430 return status;
6431 }
6432
6433 return 0;
6434}
6435
6436/*
6437 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306438 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306440static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 struct net_device *dev
6442 )
6443{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306444 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6446 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306447 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6448 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006449
6450 ENTER();
6451
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306452 status = wlan_hdd_validate_context(pHddCtx);
6453
6454 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006455 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306456 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6457 "%s: HDD context is not valid", __func__);
6458 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006459 }
6460
Jeff Johnson295189b2012-06-20 16:38:30 -07006461 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6462 if (NULL == pWextState)
6463 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306464 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 __func__);
6466 return -EIO;
6467 }
6468
6469 pRoamProfile = &pWextState->roamProfile;
6470
6471 /* Issue disconnect only if interface type is set to IBSS */
6472 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6473 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306474 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 __func__);
6476 return -EINVAL;
6477 }
6478
6479 /* Issue Disconnect request */
6480 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6481 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6482 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6483
6484 return 0;
6485}
6486
6487/*
6488 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6489 * This function is used to set the phy parameters
6490 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6491 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306492static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 u32 changed)
6494{
6495 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6496 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306497 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006498
6499 ENTER();
6500
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306501 status = wlan_hdd_validate_context(pHddCtx);
6502
6503 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006504 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306505 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6506 "%s: HDD context is not valid", __func__);
6507 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006508 }
6509
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6511 {
6512 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6513 WNI_CFG_RTS_THRESHOLD_STAMAX :
6514 wiphy->rts_threshold;
6515
6516 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306517 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306519 hddLog(VOS_TRACE_LEVEL_ERROR,
6520 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 __func__, rts_threshold);
6522 return -EINVAL;
6523 }
6524
6525 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6526 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306527 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006528 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306529 hddLog(VOS_TRACE_LEVEL_ERROR,
6530 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006531 __func__, rts_threshold);
6532 return -EIO;
6533 }
6534
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306535 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 rts_threshold);
6537 }
6538
6539 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6540 {
6541 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6542 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6543 wiphy->frag_threshold;
6544
6545 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306546 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006547 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306548 hddLog(VOS_TRACE_LEVEL_ERROR,
6549 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006550 frag_threshold);
6551 return -EINVAL;
6552 }
6553
6554 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6555 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306556 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006557 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306558 hddLog(VOS_TRACE_LEVEL_ERROR,
6559 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 __func__, frag_threshold);
6561 return -EIO;
6562 }
6563
6564 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6565 frag_threshold);
6566 }
6567
6568 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6569 || (changed & WIPHY_PARAM_RETRY_LONG))
6570 {
6571 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6572 wiphy->retry_short :
6573 wiphy->retry_long;
6574
6575 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6576 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6577 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306578 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 __func__, retry_value);
6580 return -EINVAL;
6581 }
6582
6583 if (changed & WIPHY_PARAM_RETRY_SHORT)
6584 {
6585 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6586 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306587 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306589 hddLog(VOS_TRACE_LEVEL_ERROR,
6590 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006591 __func__, retry_value);
6592 return -EIO;
6593 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306594 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 __func__, retry_value);
6596 }
6597 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6598 {
6599 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6600 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306601 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306603 hddLog(VOS_TRACE_LEVEL_ERROR,
6604 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 __func__, retry_value);
6606 return -EIO;
6607 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306608 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 __func__, retry_value);
6610 }
6611 }
6612
6613 return 0;
6614}
6615
6616/*
6617 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6618 * This function is used to set the txpower
6619 */
6620static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006621#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6622 struct wireless_dev *wdev,
6623#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006624#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306625 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006626#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306627 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006628#endif
6629 int dbm)
6630{
6631 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306632 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6634 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306635 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006636
6637 ENTER();
6638
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306639 status = wlan_hdd_validate_context(pHddCtx);
6640
6641 if (0 != status)
6642 {
6643 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6644 "%s: HDD context is not valid", __func__);
6645 return status;
6646 }
6647
6648 hHal = pHddCtx->hHal;
6649
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306650 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6651 dbm, ccmCfgSetCallback,
6652 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306654 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6656 return -EIO;
6657 }
6658
6659 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6660 dbm);
6661
6662 switch(type)
6663 {
6664 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6665 /* Fall through */
6666 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6667 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6668 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306669 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6670 __func__);
6671 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 }
6673 break;
6674 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306675 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 __func__);
6677 return -EOPNOTSUPP;
6678 break;
6679 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306680 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6681 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 return -EIO;
6683 }
6684
6685 return 0;
6686}
6687
6688/*
6689 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6690 * This function is used to read the txpower
6691 */
Yue Maf49ba872013-08-19 12:04:25 -07006692static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6693#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6694 struct wireless_dev *wdev,
6695#endif
6696 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006697{
6698
6699 hdd_adapter_t *pAdapter;
6700 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306701 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006702
Jeff Johnsone7245742012-09-05 17:12:55 -07006703 ENTER();
6704
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306705 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006706
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306707 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006708 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306709 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6710 "%s: HDD context is not valid", __func__);
6711 *dbm = 0;
6712 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006713 }
6714
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6716 if (NULL == pAdapter)
6717 {
6718 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6719 return -ENOENT;
6720 }
6721
6722 wlan_hdd_get_classAstats(pAdapter);
6723 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6724
Jeff Johnsone7245742012-09-05 17:12:55 -07006725 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 return 0;
6727}
6728
6729static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6730 u8* mac, struct station_info *sinfo)
6731{
6732 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6733 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6734 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6735 tANI_U8 rate_flags;
6736
6737 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6738 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006739
6740 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6741 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6742 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6743 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6744 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6745 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6746 tANI_U16 maxRate = 0;
6747 tANI_U16 myRate;
6748 tANI_U16 currentRate = 0;
6749 tANI_U8 maxSpeedMCS = 0;
6750 tANI_U8 maxMCSIdx = 0;
6751 tANI_U8 rateFlag = 1;
6752 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006753 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306754 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006755
Leo Chang6f8870f2013-03-26 18:11:36 -07006756#ifdef WLAN_FEATURE_11AC
6757 tANI_U32 vht_mcs_map;
6758 eDataRate11ACMaxMcs vhtMaxMcs;
6759#endif /* WLAN_FEATURE_11AC */
6760
Jeff Johnsone7245742012-09-05 17:12:55 -07006761 ENTER();
6762
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6764 (0 == ssidlen))
6765 {
6766 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6767 " Invalid ssidlen, %d", __func__, ssidlen);
6768 /*To keep GUI happy*/
6769 return 0;
6770 }
6771
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306772 status = wlan_hdd_validate_context(pHddCtx);
6773
6774 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006775 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306776 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6777 "%s: HDD context is not valid", __func__);
6778 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006779 }
6780
Jeff Johnson295189b2012-06-20 16:38:30 -07006781 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6782 sinfo->filled |= STATION_INFO_SIGNAL;
6783
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006784 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6786
6787 //convert to the UI units of 100kbps
6788 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6789
6790#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006791 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 -07006792 sinfo->signal,
6793 pCfg->reportMaxLinkSpeed,
6794 myRate,
6795 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006796 (int) pCfg->linkSpeedRssiMid,
6797 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006798 (int) rate_flags,
6799 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006800#endif //LINKSPEED_DEBUG_ENABLED
6801
6802 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6803 {
6804 // we do not want to necessarily report the current speed
6805 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6806 {
6807 // report the max possible speed
6808 rssidx = 0;
6809 }
6810 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6811 {
6812 // report the max possible speed with RSSI scaling
6813 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6814 {
6815 // report the max possible speed
6816 rssidx = 0;
6817 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006818 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006819 {
6820 // report middle speed
6821 rssidx = 1;
6822 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006823 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6824 {
6825 // report middle speed
6826 rssidx = 2;
6827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006828 else
6829 {
6830 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006831 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006832 }
6833 }
6834 else
6835 {
6836 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6837 hddLog(VOS_TRACE_LEVEL_ERROR,
6838 "%s: Invalid value for reportMaxLinkSpeed: %u",
6839 __func__, pCfg->reportMaxLinkSpeed);
6840 rssidx = 0;
6841 }
6842
6843 maxRate = 0;
6844
6845 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306846 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6847 OperationalRates, &ORLeng))
6848 {
6849 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6850 /*To keep GUI happy*/
6851 return 0;
6852 }
6853
Jeff Johnson295189b2012-06-20 16:38:30 -07006854 for (i = 0; i < ORLeng; i++)
6855 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006856 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006857 {
6858 /* Validate Rate Set */
6859 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6860 {
6861 currentRate = supported_data_rate[j].supported_rate[rssidx];
6862 break;
6863 }
6864 }
6865 /* Update MAX rate */
6866 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6867 }
6868
6869 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306870 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
6871 ExtendedRates, &ERLeng))
6872 {
6873 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6874 /*To keep GUI happy*/
6875 return 0;
6876 }
6877
Jeff Johnson295189b2012-06-20 16:38:30 -07006878 for (i = 0; i < ERLeng; i++)
6879 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006880 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006881 {
6882 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
6883 {
6884 currentRate = supported_data_rate[j].supported_rate[rssidx];
6885 break;
6886 }
6887 }
6888 /* Update MAX rate */
6889 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006891 /* Get MCS Rate Set -- but only if we are connected at MCS
6892 rates or if we are always reporting max speed or if we have
6893 good rssi */
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006894 if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -07006895 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306896 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
6897 MCSRates, &MCSLeng))
6898 {
6899 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6900 /*To keep GUI happy*/
6901 return 0;
6902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07006904#ifdef WLAN_FEATURE_11AC
6905 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306906 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07006907 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006908 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306909 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07006910 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07006911 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006912 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006914 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07006915 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006916 maxMCSIdx = 7;
6917 }
6918 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
6919 {
6920 maxMCSIdx = 8;
6921 }
6922 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
6923 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306924 //VHT20 is supporting 0~8
6925 if (rate_flags & eHAL_TX_RATE_VHT20)
6926 maxMCSIdx = 8;
6927 else
6928 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07006929 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306930
6931 if (rate_flags & eHAL_TX_RATE_VHT80)
6932 {
6933 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
6934 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
6935 }
6936 else if (rate_flags & eHAL_TX_RATE_VHT40)
6937 {
6938 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
6939 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
6940 }
6941 else if (rate_flags & eHAL_TX_RATE_VHT20)
6942 {
6943 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
6944 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
6945 }
6946
Leo Chang6f8870f2013-03-26 18:11:36 -07006947 maxSpeedMCS = 1;
6948 if (currentRate > maxRate)
6949 {
6950 maxRate = currentRate;
6951 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306952
Leo Chang6f8870f2013-03-26 18:11:36 -07006953 }
6954 else
6955#endif /* WLAN_FEATURE_11AC */
6956 {
6957 if (rate_flags & eHAL_TX_RATE_HT40)
6958 {
6959 rateFlag |= 1;
6960 }
6961 if (rate_flags & eHAL_TX_RATE_SGI)
6962 {
6963 rateFlag |= 2;
6964 }
6965
6966 for (i = 0; i < MCSLeng; i++)
6967 {
6968 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
6969 for (j = 0; j < temp; j++)
6970 {
6971 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
6972 {
6973 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
6974 break;
6975 }
6976 }
6977 if ((j < temp) && (currentRate > maxRate))
6978 {
6979 maxRate = currentRate;
6980 maxSpeedMCS = 1;
6981 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
6982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006983 }
6984 }
6985 }
6986
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306987 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
6988 {
6989 maxRate = myRate;
6990 maxSpeedMCS = 1;
6991 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6992 }
6993
Jeff Johnson295189b2012-06-20 16:38:30 -07006994 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006995 if (((maxRate < myRate) && (0 == rssidx)) ||
6996 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 {
6998 maxRate = myRate;
6999 if (rate_flags & eHAL_TX_RATE_LEGACY)
7000 {
7001 maxSpeedMCS = 0;
7002 }
7003 else
7004 {
7005 maxSpeedMCS = 1;
7006 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7007 }
7008 }
7009
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307010 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007011 {
7012 sinfo->txrate.legacy = maxRate;
7013#ifdef LINKSPEED_DEBUG_ENABLED
7014 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7015#endif //LINKSPEED_DEBUG_ENABLED
7016 }
7017 else
7018 {
7019 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007020#ifdef WLAN_FEATURE_11AC
7021 sinfo->txrate.nss = 1;
7022 if (rate_flags & eHAL_TX_RATE_VHT80)
7023 {
7024 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307025 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007026 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307027 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007028 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307029 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7030 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7031 }
7032 else if (rate_flags & eHAL_TX_RATE_VHT20)
7033 {
7034 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7035 }
7036#endif /* WLAN_FEATURE_11AC */
7037 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7038 {
7039 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7040 if (rate_flags & eHAL_TX_RATE_HT40)
7041 {
7042 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7043 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007045 if (rate_flags & eHAL_TX_RATE_SGI)
7046 {
7047 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7048 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307049
Jeff Johnson295189b2012-06-20 16:38:30 -07007050#ifdef LINKSPEED_DEBUG_ENABLED
7051 pr_info("Reporting MCS rate %d flags %x\n",
7052 sinfo->txrate.mcs,
7053 sinfo->txrate.flags );
7054#endif //LINKSPEED_DEBUG_ENABLED
7055 }
7056 }
7057 else
7058 {
7059 // report current rate instead of max rate
7060
7061 if (rate_flags & eHAL_TX_RATE_LEGACY)
7062 {
7063 //provide to the UI in units of 100kbps
7064 sinfo->txrate.legacy = myRate;
7065#ifdef LINKSPEED_DEBUG_ENABLED
7066 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7067#endif //LINKSPEED_DEBUG_ENABLED
7068 }
7069 else
7070 {
7071 //must be MCS
7072 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007073#ifdef WLAN_FEATURE_11AC
7074 sinfo->txrate.nss = 1;
7075 if (rate_flags & eHAL_TX_RATE_VHT80)
7076 {
7077 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7078 }
7079 else
7080#endif /* WLAN_FEATURE_11AC */
7081 {
7082 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7083 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007084 if (rate_flags & eHAL_TX_RATE_SGI)
7085 {
7086 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7087 }
7088 if (rate_flags & eHAL_TX_RATE_HT40)
7089 {
7090 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7091 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007092#ifdef WLAN_FEATURE_11AC
7093 else if (rate_flags & eHAL_TX_RATE_VHT80)
7094 {
7095 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7096 }
7097#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007098#ifdef LINKSPEED_DEBUG_ENABLED
7099 pr_info("Reporting actual MCS rate %d flags %x\n",
7100 sinfo->txrate.mcs,
7101 sinfo->txrate.flags );
7102#endif //LINKSPEED_DEBUG_ENABLED
7103 }
7104 }
7105 sinfo->filled |= STATION_INFO_TX_BITRATE;
7106
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007107 sinfo->tx_packets =
7108 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7109 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7110 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7111 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7112
7113 sinfo->tx_retries =
7114 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7115 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7116 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7117 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7118
7119 sinfo->tx_failed =
7120 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7121 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7122 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7123 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7124
7125 sinfo->filled |=
7126 STATION_INFO_TX_PACKETS |
7127 STATION_INFO_TX_RETRIES |
7128 STATION_INFO_TX_FAILED;
7129
7130 EXIT();
7131 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007132}
7133
7134static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007135 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007136{
7137 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307138 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007139 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307140 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007141
Jeff Johnsone7245742012-09-05 17:12:55 -07007142 ENTER();
7143
Jeff Johnson295189b2012-06-20 16:38:30 -07007144 if (NULL == pAdapter)
7145 {
7146 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7147 return -ENODEV;
7148 }
7149
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307150 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307151 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307152
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307153 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307154 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307155 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7156 "%s: HDD context is not valid", __func__);
7157 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307158 }
7159
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307160 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7161 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7162 (pHddCtx->cfg_ini->fhostArpOffload) &&
7163 (eConnectionState_Associated ==
7164 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7165 {
Amar Singhald53568e2013-09-26 11:03:45 -07007166
7167 hddLog(VOS_TRACE_LEVEL_INFO,
7168 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307169 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307170 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7171 {
7172 hddLog(VOS_TRACE_LEVEL_INFO,
7173 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
7174 __func__, vos_status);
7175 }
7176 }
7177
Jeff Johnson295189b2012-06-20 16:38:30 -07007178 /**The get power cmd from the supplicant gets updated by the nl only
7179 *on successful execution of the function call
7180 *we are oppositely mapped w.r.t mode in the driver
7181 **/
7182 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7183
Jeff Johnsone7245742012-09-05 17:12:55 -07007184 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 if (VOS_STATUS_E_FAILURE == vos_status)
7186 {
7187 return -EINVAL;
7188 }
7189 return 0;
7190}
7191
7192
7193#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7194static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7195 struct net_device *netdev,
7196 u8 key_index)
7197{
Jeff Johnsone7245742012-09-05 17:12:55 -07007198 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007199 return 0;
7200}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307201#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007202
7203#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7204static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7205 struct net_device *dev,
7206 struct ieee80211_txq_params *params)
7207{
Jeff Johnsone7245742012-09-05 17:12:55 -07007208 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 return 0;
7210}
7211#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7212static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7213 struct ieee80211_txq_params *params)
7214{
Jeff Johnsone7245742012-09-05 17:12:55 -07007215 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 return 0;
7217}
7218#endif //LINUX_VERSION_CODE
7219
7220static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7221 struct net_device *dev, u8 *mac)
7222{
7223 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307224 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007225 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307226 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007227 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007228
Jeff Johnsone7245742012-09-05 17:12:55 -07007229 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307230 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007231 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307232 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007233 return -EINVAL;
7234 }
7235
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307236 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7237 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007238
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307239 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007240 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307241 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7242 "%s: HDD context is not valid", __func__);
7243 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007244 }
7245
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007248 )
7249 {
7250 if( NULL == mac )
7251 {
7252 v_U16_t i;
7253 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7254 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007255 if ((pAdapter->aStaInfo[i].isUsed) &&
7256 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007257 {
7258 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7259 hddLog(VOS_TRACE_LEVEL_INFO,
7260 "%s: Delete STA with MAC::"
7261 "%02x:%02x:%02x:%02x:%02x:%02x",
7262 __func__,
7263 macAddr[0], macAddr[1], macAddr[2],
7264 macAddr[3], macAddr[4], macAddr[5]);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007265 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7266 if (VOS_IS_STATUS_SUCCESS(vos_status))
7267 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 }
7269 }
7270 }
7271 else
7272 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007273
7274 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7275 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7276 {
7277 hddLog(VOS_TRACE_LEVEL_INFO,
7278 "%s: Skip this DEL STA as this is not used::"
7279 "%02x:%02x:%02x:%02x:%02x:%02x",
7280 __func__,
7281 mac[0], mac[1], mac[2],
7282 mac[3], mac[4], mac[5]);
7283 return -ENOENT;
7284 }
7285
7286 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7287 {
7288 hddLog(VOS_TRACE_LEVEL_INFO,
7289 "%s: Skip this DEL STA as deauth is in progress::"
7290 "%02x:%02x:%02x:%02x:%02x:%02x",
7291 __func__,
7292 mac[0], mac[1], mac[2],
7293 mac[3], mac[4], mac[5]);
7294 return -ENOENT;
7295 }
7296
7297 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7298
Jeff Johnson295189b2012-06-20 16:38:30 -07007299 hddLog(VOS_TRACE_LEVEL_INFO,
7300 "%s: Delete STA with MAC::"
7301 "%02x:%02x:%02x:%02x:%02x:%02x",
7302 __func__,
7303 mac[0], mac[1], mac[2],
7304 mac[3], mac[4], mac[5]);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007305
7306 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7307 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7308 {
7309 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7310 hddLog(VOS_TRACE_LEVEL_INFO,
7311 "%s: STA removal failed for ::"
7312 "%02x:%02x:%02x:%02x:%02x:%02x",
7313 __func__,
7314 mac[0], mac[1], mac[2],
7315 mac[3], mac[4], mac[5]);
7316 return -ENOENT;
7317 }
7318
Jeff Johnson295189b2012-06-20 16:38:30 -07007319 }
7320 }
7321
7322 EXIT();
7323
7324 return 0;
7325}
7326
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007327static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7328 struct net_device *dev, u8 *mac, struct station_parameters *params)
7329{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007330 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007331#ifdef FEATURE_WLAN_TDLS
7332 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007333 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007334 mask = params->sta_flags_mask;
7335
7336 set = params->sta_flags_set;
7337
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007338#ifdef WLAN_FEATURE_TDLS_DEBUG
7339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7340 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7341 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7342#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007343
7344 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7345 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007346 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007347 }
7348 }
7349#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007350 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007351}
7352
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007353
7354#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07007355#define MAX_PMKSAIDS_IN_CACHE 8
7356
7357static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
7358static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
7359
7360
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007361static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007362 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007363{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307364 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007365 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7366 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307367 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307368 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007369 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307370 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307371
Jeff Johnsone7245742012-09-05 17:12:55 -07007372 ENTER();
7373
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307374 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307375 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007376 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307377 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007378 return -EINVAL;
7379 }
7380
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307381 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7382 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007383
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307384 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007385 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307386 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7387 "%s: HDD context is not valid", __func__);
7388 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007389 }
7390
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307391 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007392 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7393
Wilson Yang6507c4e2013-10-01 20:11:19 -07007394 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007395 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307396 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007397 pmksa->bssid, WNI_CFG_BSSID_LEN))
7398 {
7399 /* BSSID matched previous entry. Overwrite it. */
7400 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307401 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007402 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307403 vos_mem_copy(PMKIDCache[j].PMKID,
7404 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007405 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307406 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007407 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007408 dump_bssid(pmksa->bssid);
7409 dump_pmkid(halHandle, pmksa->pmkid);
7410 break;
7411 }
7412 }
7413
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007414 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07007415 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007416
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007417 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307418 {
7419 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07007420 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307421 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007422 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307423 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007424 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307425 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007426 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007427 dump_bssid(pmksa->bssid);
7428 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307429 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007430 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07007431 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007432 }
7433
7434
7435 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307436 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007437 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307438 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007439 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007440 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307441 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7442 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007443 PMKIDCacheIndex);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007444 return 0;
7445}
7446
7447
Wilson Yang6507c4e2013-10-01 20:11:19 -07007448
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007449static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007450 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007451{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007452 tANI_U32 j=0;
7453 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7454 tHalHandle halHandle;
7455 int status;
7456 tANI_U8 BSSIDMatched = 0;
7457 tANI_U8 *pBSSId;
7458 hdd_context_t *pHddCtx;
7459 int result = 0;
7460
7461 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA with PMKSA_ID %d .",
7462 __func__,pmksa->pmkid);
7463
7464 /* Validate pAdapter */
7465 if (NULL == pAdapter)
7466 {
7467 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
7468 return -EINVAL;
7469 }
7470
7471 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7472 status = wlan_hdd_validate_context(pHddCtx);
7473
7474 if (0 != status)
7475 {
7476 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7477 "%s: HDD context is not valid", __func__);
7478 return status;
7479 }
7480
7481 /*Retrieve halHandle*/
7482 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7483
7484 /*in case index is 0,no entry to delete*/
7485 if (0 == PMKIDCacheIndex)
7486 {
7487 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7488 __func__);
7489 return -EINVAL;
7490 }
7491
7492 /*find the matching PMKSA entry from j=0 to (index-1),
7493 * and delete the matched one
7494 */
7495 for (j = 0; j<PMKIDCacheIndex; j++)
7496 {
7497 if (vos_mem_compare(PMKIDCache[j].BSSID,
7498 pmksa->bssid,
7499 WNI_CFG_BSSID_LEN))
7500 {
7501 /* BSSID matched entry */
7502 BSSIDMatched = 1;
7503
7504 if (j<PMKIDCacheIndex-1)
7505 {
7506 /*replace the matching entry with the last entry in HDD local cache*/
7507 vos_mem_copy(PMKIDCache[j].BSSID,
7508 PMKIDCache[PMKIDCacheIndex-1].BSSID,
7509 WNI_CFG_BSSID_LEN);
7510 vos_mem_copy(PMKIDCache[j].PMKID,
7511 PMKIDCache[PMKIDCacheIndex-1].PMKID,
7512 CSR_RSN_PMKID_SIZE);
7513 }
7514
7515 /*clear the last entry in HDD cache ---[index-1]*/
7516 pBSSId =(tANI_U8 *)(PMKIDCache[PMKIDCacheIndex-1].BSSID);
7517 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
7518 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
7519
7520 /*reduce the PMKID array index*/
7521 PMKIDCacheIndex--;
7522
7523 /*delete the last PMKID cache in CSR*/
7524 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7525 if (0 != result)
7526 {
7527 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
7528 __func__,PMKIDCacheIndex);
7529 }
7530
7531 dump_bssid(pmksa->bssid);
7532 dump_pmkid(halHandle,pmksa->pmkid);
7533
7534 break;
7535 }
7536 }
7537
7538 /* we compare all entries,but cannot find matching entry */
7539 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
7540 {
7541 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: No such PMKSA entry existed %d.",
7542 __func__,pmksa->bssid);
7543 dump_bssid(pmksa->bssid);
7544 dump_pmkid(halHandle, pmksa->pmkid);
7545 return -EINVAL;
7546 }
7547 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007548}
7549
Wilson Yang6507c4e2013-10-01 20:11:19 -07007550
7551
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007552static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7553{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007554 tANI_U32 j=0;
7555 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7556 tHalHandle halHandle;
7557 hdd_context_t *pHddCtx;
7558 tANI_U8 *pBSSId;
7559 int status;
7560 int result;
7561
7562 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
7563
7564 /* Validate pAdapter */
7565 if (NULL == pAdapter)
7566 {
7567 hddLog(VOS_TRACE_LEVEL_ERROR,
7568 "%s: Invalid Adapter" ,__func__);
7569 return -EINVAL;
7570 }
7571
7572 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7573 status = wlan_hdd_validate_context(pHddCtx);
7574
7575 if (0 != status)
7576 {
7577 hddLog(VOS_TRACE_LEVEL_ERROR,
7578 "%s: HDD context is not valid", __func__);
7579 return status;
7580 }
7581
7582 /*Retrieve halHandle*/
7583 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7584
7585 /*in case index is 0,no entry to delete*/
7586 if (0 == PMKIDCacheIndex)
7587 {
7588 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7589 __func__);
7590 return -EINVAL;
7591 }
7592
7593 /*delete all the PMKSA one by one */
7594 for (j = 0; j<PMKIDCacheIndex; j++)
7595 {
7596 /*clear the entry in HDD cache 0--index-1 */
7597 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
7598 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
7599 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
7600
7601 /*delete the PMKID in CSR*/
7602 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7603
7604 if (0!= result)
7605 {
7606 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
7607 __func__,j);
7608 }
7609 }
7610
7611 PMKIDCacheIndex = 0;
7612 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007613}
7614#endif
7615
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007616#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307617static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007618 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7619{
7620 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7621 hdd_station_ctx_t *pHddStaCtx;
7622
7623 if (NULL == pAdapter)
7624 {
7625 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7626 return -ENODEV;
7627 }
7628
7629 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7630
7631 // Added for debug on reception of Re-assoc Req.
7632 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7633 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307634 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007635 ftie->ie_len);
7636 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7637 }
7638
7639#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307640 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007641 ftie->ie_len);
7642#endif
7643
7644 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307645 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7646 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007647 ftie->ie_len);
7648 return 0;
7649}
7650#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007651
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307652#ifdef FEATURE_WLAN_SCAN_PNO
7653
7654void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7655 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7656{
7657 int ret;
7658 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7659 hdd_context_t *pHddCtx;
7660
7661 if (NULL == pAdapter)
7662 {
7663 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7664 "%s: HDD adapter is Null", __func__);
7665 return ;
7666 }
7667
7668 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7669 if (NULL == pHddCtx)
7670 {
7671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7672 "%s: HDD context is Null!!!", __func__);
7673 return ;
7674 }
7675
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307676 spin_lock(&pHddCtx->schedScan_lock);
7677 if (TRUE == pHddCtx->isWiphySuspended)
7678 {
7679 pHddCtx->isSchedScanUpdatePending = TRUE;
7680 spin_unlock(&pHddCtx->schedScan_lock);
7681 hddLog(VOS_TRACE_LEVEL_INFO,
7682 "%s: Update cfg80211 scan database after it resume", __func__);
7683 return ;
7684 }
7685 spin_unlock(&pHddCtx->schedScan_lock);
7686
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307687 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7688
7689 if (0 > ret)
7690 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7691
7692 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307693 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7694 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307695}
7696
7697/*
7698 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7699 * NL interface to enable PNO
7700 */
7701static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7702 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7703{
7704 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7705 tpSirPNOScanReq pPnoRequest = NULL;
7706 hdd_context_t *pHddCtx;
7707 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307708 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307709 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7710 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7711 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7712 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307713 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307714
7715 if (NULL == pAdapter)
7716 {
7717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7718 "%s: HDD adapter is Null", __func__);
7719 return -ENODEV;
7720 }
7721
7722 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307723 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307724
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307725 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307726 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307727 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7728 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307729 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307730 }
7731
7732 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7733 if (NULL == hHal)
7734 {
7735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7736 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307737 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307738 }
7739
7740 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7741 if (NULL == pPnoRequest)
7742 {
7743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7744 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307745 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307746 }
7747
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05307748 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307749 pPnoRequest->enable = 1; /*Enable PNO */
7750 pPnoRequest->ucNetworksCount = request->n_match_sets;
7751
7752 if (( !pPnoRequest->ucNetworksCount ) ||
7753 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7754 {
7755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7756 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307757 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307758 goto error;
7759 }
7760
7761 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7762 {
7763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7764 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307765 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307766 goto error;
7767 }
7768
7769 /* Framework provides one set of channels(all)
7770 * common for all saved profile */
7771 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7772 channels_allowed, &num_channels_allowed))
7773 {
7774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7775 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307776 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307777 goto error;
7778 }
7779 /* Checking each channel against allowed channel list */
7780 num_ch = 0;
7781 for (i = 0; i < request->n_channels; i++)
7782 {
7783 for (indx = 0; indx < num_channels_allowed; indx++)
7784 {
7785 if (request->channels[i]->hw_value == channels_allowed[indx])
7786 {
7787 valid_ch[num_ch++] = request->channels[i]->hw_value;
7788 break ;
7789 }
7790 }
7791 }
7792
7793 /* Filling per profile params */
7794 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7795 {
7796 pPnoRequest->aNetworks[i].ssId.length =
7797 request->match_sets[i].ssid.ssid_len;
7798
7799 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7800 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7801 {
7802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7803 "SSID Len %d is not correct for network %d",
7804 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307805 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307806 goto error;
7807 }
7808
7809 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7810 request->match_sets[i].ssid.ssid,
7811 request->match_sets[i].ssid.ssid_len);
7812 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7813 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7814 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7815
7816 /*Copying list of valid channel into request */
7817 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7818 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7819
7820 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7821 }
7822
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05307823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7824 "request->ie_len = %d", request->ie_len);
7825 if ((0 < request->ie_len) && (NULL != request->ie))
7826 {
7827 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
7828 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
7829 pPnoRequest->us24GProbeTemplateLen);
7830
7831 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
7832 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
7833 pPnoRequest->us5GProbeTemplateLen);
7834 }
7835
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307836 /* Driver gets only one time interval which is hardcoded in
7837 * supplicant for 10000ms. Taking power consumption into account 6 timers
7838 * will be used, Timervalue is increased exponentially i.e 10,20,40,
7839 * 80,160,320 secs. And number of scan cycle for each timer
7840 * is configurable through INI param gPNOScanTimerRepeatValue.
7841 * If it is set to 0 only one timer will be used and PNO scan cycle
7842 * will be repeated after each interval specified by supplicant
7843 * till PNO is disabled.
7844 */
7845 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
7846 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
7847 else
7848 pPnoRequest->scanTimers.ucScanTimersCount =
7849 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
7850
7851 tempInterval = (request->interval)/1000;
7852 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7853 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
7854 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
7855 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
7856 {
7857 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
7858 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
7859 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
7860 tempInterval *= 2;
7861 }
7862 //Repeat last timer until pno disabled.
7863 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
7864
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05307865 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307866
7867 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7868 pPnoRequest, pAdapter->sessionId,
7869 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7870 if (eHAL_STATUS_SUCCESS != status)
7871 {
7872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7873 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307874 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307875 goto error;
7876 }
7877
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7879 "PNO scanRequest offloaded");
7880
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307881error:
7882 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307883 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307884}
7885
7886/*
7887 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
7888 * NL interface to disable PNO
7889 */
7890static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
7891 struct net_device *dev)
7892{
7893 eHalStatus status = eHAL_STATUS_FAILURE;
7894 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7895 hdd_context_t *pHddCtx;
7896 tHalHandle hHal;
7897 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307898 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307899
7900 ENTER();
7901
7902 if (NULL == pAdapter)
7903 {
7904 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7905 "%s: HDD adapter is Null", __func__);
7906 return -ENODEV;
7907 }
7908
7909 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307910
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307911 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307912 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307913 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307914 "%s: HDD context is Null", __func__);
7915 return -ENODEV;
7916 }
7917
7918 /* The return 0 is intentional when isLogpInProgress and
7919 * isLoadUnloadInProgress. We did observe a crash due to a return of
7920 * failure in sched_scan_stop , especially for a case where the unload
7921 * of the happens at the same time. The function __cfg80211_stop_sched_scan
7922 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
7923 * success. If it returns a failure , then its next invocation due to the
7924 * clean up of the second interface will have the dev pointer corresponding
7925 * to the first one leading to a crash.
7926 */
7927 if (pHddCtx->isLogpInProgress)
7928 {
7929 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7930 "%s: LOGP in Progress. Ignore!!!", __func__);
7931 return ret;
7932 }
7933
7934 if (pHddCtx->isLoadUnloadInProgress)
7935 {
7936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7937 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
7938 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307939 }
7940
7941 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7942 if (NULL == hHal)
7943 {
7944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7945 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307946 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307947 }
7948
7949 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7950 if (NULL == pPnoRequest)
7951 {
7952 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7953 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307954 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307955 }
7956
7957 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
7958 pPnoRequest->enable = 0; /* Disable PNO */
7959 pPnoRequest->ucNetworksCount = 0;
7960
7961 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
7962 pAdapter->sessionId,
7963 NULL, pAdapter);
7964 if (eHAL_STATUS_SUCCESS != status)
7965 {
7966 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7967 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307968 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307969 }
7970
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307971 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7972 "%s: PNO scan disabled", __func__);
7973
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307974 vos_mem_free(pPnoRequest);
7975
7976 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307977 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307978}
7979
7980#endif /*FEATURE_WLAN_SCAN_PNO*/
7981
7982
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007983#ifdef FEATURE_WLAN_TDLS
7984static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
7985 u8 *peer, u8 action_code, u8 dialog_token,
7986 u16 status_code, const u8 *buf, size_t len)
7987{
7988
7989 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7990 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007991 u8 peerMac[6];
7992 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007993 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08007994 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007995 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007996
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007997 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007998 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307999 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008000 "Invalid arguments");
8001 return -EINVAL;
8002 }
8003
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008004 if (pHddCtx->isLogpInProgress)
8005 {
8006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8007 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008008 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008009 return -EBUSY;
8010 }
8011
Hoonki Lee27511902013-03-14 18:19:06 -07008012 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008013 {
Hoonki Lee27511902013-03-14 18:19:06 -07008014 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8015 "%s: TDLS mode is disabled OR not enabled in FW."
8016 MAC_ADDRESS_STR " action %d declined.",
8017 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008018 return -ENOTSUPP;
8019 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008020
Hoonki Lee27511902013-03-14 18:19:06 -07008021 /* other than teardown frame, other mgmt frames are not sent if disabled */
8022 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8023 {
8024 /* if tdls_mode is disabled to respond to peer's request */
8025 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8026 {
8027 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8028 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008029 " TDLS mode is disabled. action %d declined.",
8030 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008031
8032 return -ENOTSUPP;
8033 }
8034 }
8035
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008036 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8037 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308038 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008039 {
8040 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008041 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008042 " TDLS setup is ongoing. action %d declined.",
8043 __func__, MAC_ADDR_ARRAY(peer), action_code);
8044 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008045 }
8046 }
8047
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008048 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8049 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008050 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008051 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008052 {
8053 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
8054 we return error code at 'add_station()'. Hence we have this
8055 check again in addtion to add_station().
8056 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008057 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008058 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008059 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8060 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008061 " TDLS Max peer already connected. action %d declined.",
8062 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008063 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08008064 }
8065 else
8066 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008067 /* maximum reached. tweak to send error code to peer and return
8068 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008069 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008070 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8071 "%s: " MAC_ADDRESS_STR
8072 " TDLS Max peer already connected send response status %d",
8073 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008074 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008075 /* fall through to send setup resp with failure status
8076 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008077 }
8078 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008079 else
8080 {
8081 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308082 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008083 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008084 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008085 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008086 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
8087 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008088 return -EPERM;
8089 }
8090 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008091 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008092 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008093
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008094#ifdef WLAN_FEATURE_TDLS_DEBUG
8095 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008096 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
8097 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
8098 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008099#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008100
Hoonki Leea34dd892013-02-05 22:56:02 -08008101 /*Except teardown responder will not be used so just make 0*/
8102 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008103 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08008104 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008105
8106 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308107 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008108
8109 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
8110 responder = pTdlsPeer->is_responder;
8111 else
Hoonki Leea34dd892013-02-05 22:56:02 -08008112 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008113 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8114 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
8115 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
8116 dialog_token, status_code, len);
8117 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08008118 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008119 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008120
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308121 /* For explicit trigger of DIS_REQ come out of BMPS for
8122 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008123 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308124 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8125 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008126 {
8127 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8128 {
8129 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308130 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008131 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8132 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308133 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8134 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008135 }
8136
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008137 /* make sure doesn't call send_mgmt() while it is pending */
8138 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8139 {
8140 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8141 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
8142 __func__, MAC_ADDR_ARRAY(peer), action_code);
8143 return -EBUSY;
8144 }
8145
8146 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008147 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
8148
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008149 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08008150 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008151
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008152 if (VOS_STATUS_SUCCESS != status)
8153 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8155 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008156 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07008157 wlan_hdd_tdls_check_bmps(pAdapter);
8158 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008159 }
8160
Hoonki Leed37cbb32013-04-20 00:31:14 -07008161 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
8162 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
8163
8164 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008165 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07008166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8167 "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu",
8168 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008169 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008170 wlan_hdd_tdls_check_bmps(pAdapter);
8171 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008172 }
8173
Gopichand Nakkala05922802013-03-14 12:23:19 -07008174 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07008175 {
8176 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008177 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07008178 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008179
Hoonki Leea34dd892013-02-05 22:56:02 -08008180 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
8181 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008182 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008183 }
8184 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
8185 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008186 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008187 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008188
8189 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008190error:
8191 /* max_sta_failed ; we didn't set to CONNECTING for this case,
8192 because we already know that this transaction will be failed,
8193 but we weren't sure if supplicant call DISABLE_LINK or not. So,
8194 to be safe, do not change the state mahine.
8195 */
8196 if(max_sta_failed == 0 &&
8197 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
8198 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
8199 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008200}
8201
8202static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
8203 u8 *peer, enum nl80211_tdls_operation oper)
8204{
8205 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8206 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308207 int status;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008208#ifdef WLAN_FEATURE_TDLS_DEBUG
8209 const char *tdls_oper_str[]= {
8210 "NL80211_TDLS_DISCOVERY_REQ",
8211 "NL80211_TDLS_SETUP",
8212 "NL80211_TDLS_TEARDOWN",
8213 "NL80211_TDLS_ENABLE_LINK",
8214 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05308215 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008216#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008217 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008218
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308219 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008220 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008221 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008222 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008223 return -EINVAL;
8224 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008225
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308226 status = wlan_hdd_validate_context(pHddCtx);
8227
8228 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008229 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308230 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8231 "%s: HDD context is not valid", __func__);
8232 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008233 }
8234
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308235 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008236
8237 if ( NULL == pTdlsPeer ) {
8238 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
8239 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8240 return -EINVAL;
8241 }
8242
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008243#ifdef WLAN_FEATURE_TDLS_DEBUG
8244 if((int)oper > 4)
8245 oper = 5;
8246
8247 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008248 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8249 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008250 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008251#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008252
8253 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008254 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008255 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008256 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008257 "TDLS Disabled in INI OR not enabled in FW. "
8258 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008259 return -ENOTSUPP;
8260 }
8261
8262 switch (oper) {
8263 case NL80211_TDLS_ENABLE_LINK:
8264 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008265 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308266 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008267
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07008268 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
8269 {
8270 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
8271 MAC_ADDRESS_STR " failed",
8272 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
8273 return -EINVAL;
8274 }
8275
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008276 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008277 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308278 long ret;
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308279 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308280
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308281 if (0 != wlan_hdd_tdls_get_link_establish_params(
8282 pAdapter, peer,&tdlsLinkEstablishParams)) {
8283 return -EINVAL;
8284 }
8285 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308286
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308287 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
8288 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
8289 /* Send TDLS peer UAPSD capabilities to the firmware and
8290 * register with the TL on after the response for this operation
8291 * is received .
8292 */
8293 ret = wait_for_completion_interruptible_timeout(
8294 &pAdapter->tdls_link_establish_req_comp,
8295 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
8296 if (ret <= 0)
8297 {
8298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8299 "%s: Link Establish Request Faled Status %ld",
8300 __func__, ret);
8301 return -EINVAL;
8302 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308303 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008304 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05308305 /* Mark TDLS client Authenticated .*/
8306 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
8307 pTdlsPeer->staId,
8308 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008309 if (VOS_STATUS_SUCCESS == status)
8310 {
Hoonki Lee14621352013-04-16 17:51:19 -07008311 if (pTdlsPeer->is_responder == 0)
8312 {
8313 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
8314
8315 wlan_hdd_tdls_timer_restart(pAdapter,
8316 &pTdlsPeer->initiatorWaitTimeoutTimer,
8317 WAIT_TIME_TDLS_INITIATOR);
8318 /* suspend initiator TX until it receives direct packet from the
8319 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
8320 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8321 &staId, NULL);
8322 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008323 wlan_hdd_tdls_increment_peer_count(pAdapter);
8324 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008325 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308326
8327 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308328 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
8329 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308330 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308331 int ac;
8332 uint8 ucAc[4] = { WLANTL_AC_VO,
8333 WLANTL_AC_VI,
8334 WLANTL_AC_BK,
8335 WLANTL_AC_BE };
8336 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
8337 for(ac=0; ac < 4; ac++)
8338 {
8339 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8340 pTdlsPeer->staId, ucAc[ac],
8341 tlTid[ac], tlTid[ac], 0, 0,
8342 WLANTL_BI_DIR );
8343 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308344 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008345 }
8346
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008347 }
8348 break;
8349 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08008350 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008351 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008352 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008353 long status;
8354
8355 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
8356
Lee Hoonkic1262f22013-01-24 21:59:00 -08008357 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
8358 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008359
8360 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
8361 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
8362 if (status <= 0)
8363 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008364 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8366 "%s: Del station failed status %ld",
8367 __func__, status);
8368 return -EPERM;
8369 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008370 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008371 }
8372 else
8373 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008374 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8375 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008376 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008377 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008378 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008379 case NL80211_TDLS_TEARDOWN:
8380 case NL80211_TDLS_SETUP:
8381 case NL80211_TDLS_DISCOVERY_REQ:
8382 /* We don't support in-driver setup/teardown/discovery */
8383 return -ENOTSUPP;
8384 default:
8385 return -ENOTSUPP;
8386 }
8387 return 0;
8388}
Chilam NG571c65a2013-01-19 12:27:36 +05308389
8390int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
8391 struct net_device *dev, u8 *peer)
8392{
8393 hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x",
8394 peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]);
8395
8396 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
8397 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
8398}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008399#endif
8400
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308401#ifdef WLAN_FEATURE_GTK_OFFLOAD
8402/*
8403 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
8404 * Callback rountine called upon receiving response for
8405 * get offload info
8406 */
8407void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
8408 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
8409{
8410
8411 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308412 tANI_U8 tempReplayCounter[8];
8413 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308414
8415 ENTER();
8416
8417 if (NULL == pAdapter)
8418 {
8419 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8420 "%s: HDD adapter is Null", __func__);
8421 return ;
8422 }
8423
8424 if (NULL == pGtkOffloadGetInfoRsp)
8425 {
8426 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8427 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
8428 return ;
8429 }
8430
8431 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
8432 {
8433 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8434 "%s: wlan Failed to get replay counter value",
8435 __func__);
8436 return ;
8437 }
8438
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308439 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8440 /* Update replay counter */
8441 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
8442 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8443
8444 {
8445 /* changing from little to big endian since supplicant
8446 * works on big endian format
8447 */
8448 int i;
8449 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8450
8451 for (i = 0; i < 8; i++)
8452 {
8453 tempReplayCounter[7-i] = (tANI_U8)p[i];
8454 }
8455 }
8456
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308457 /* Update replay counter to NL */
8458 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308459 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308460}
8461
8462/*
8463 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
8464 * This function is used to offload GTK rekeying job to the firmware.
8465 */
8466int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
8467 struct cfg80211_gtk_rekey_data *data)
8468{
8469 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8470 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8471 hdd_station_ctx_t *pHddStaCtx;
8472 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308473 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308474 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308475 eHalStatus status = eHAL_STATUS_FAILURE;
8476
8477 ENTER();
8478
8479 if (NULL == pAdapter)
8480 {
8481 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8482 "%s: HDD adapter is Null", __func__);
8483 return -ENODEV;
8484 }
8485
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308486 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308487
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308488 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308489 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308490 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8491 "%s: HDD context is not valid", __func__);
8492 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308493 }
8494
8495 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8496 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8497 if (NULL == hHal)
8498 {
8499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8500 "%s: HAL context is Null!!!", __func__);
8501 return -EAGAIN;
8502 }
8503
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308504 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8505 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8506 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8507 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308508 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308509 {
8510 /* changing from big to little endian since driver
8511 * works on little endian format
8512 */
8513 tANI_U8 *p =
8514 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8515 int i;
8516
8517 for (i = 0; i < 8; i++)
8518 {
8519 p[7-i] = data->replay_ctr[i];
8520 }
8521 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308522
8523 if (TRUE == pHddCtx->hdd_wlan_suspended)
8524 {
8525 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308526 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8527 sizeof (tSirGtkOffloadParams));
8528 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308529 pAdapter->sessionId);
8530
8531 if (eHAL_STATUS_SUCCESS != status)
8532 {
8533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8534 "%s: sme_SetGTKOffload failed, returned %d",
8535 __func__, status);
8536 return status;
8537 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8539 "%s: sme_SetGTKOffload successfull", __func__);
8540 }
8541 else
8542 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8544 "%s: wlan not suspended GTKOffload request is stored",
8545 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308546 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308547
8548 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308549}
8550#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8551
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308552/*
8553 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8554 * This function is used to set access control policy
8555 */
8556static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8557 struct net_device *dev, const struct cfg80211_acl_data *params)
8558{
8559 int i;
8560 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8561 hdd_hostapd_state_t *pHostapdState;
8562 tsap_Config_t *pConfig;
8563 v_CONTEXT_t pVosContext = NULL;
8564 hdd_context_t *pHddCtx;
8565 int status;
8566
8567 ENTER();
8568
8569 if (NULL == pAdapter)
8570 {
8571 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8572 "%s: HDD adapter is Null", __func__);
8573 return -ENODEV;
8574 }
8575
8576 if (NULL == params)
8577 {
8578 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8579 "%s: params is Null", __func__);
8580 return -EINVAL;
8581 }
8582
8583 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8584 status = wlan_hdd_validate_context(pHddCtx);
8585
8586 if (0 != status)
8587 {
8588 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8589 "%s: HDD context is not valid", __func__);
8590 return status;
8591 }
8592
8593 pVosContext = pHddCtx->pvosContext;
8594 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8595
8596 if (NULL == pHostapdState)
8597 {
8598 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8599 "%s: pHostapdState is Null", __func__);
8600 return -EINVAL;
8601 }
8602
8603 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8604 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8605
8606 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8607 {
8608 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8609
8610 /* default value */
8611 pConfig->num_accept_mac = 0;
8612 pConfig->num_deny_mac = 0;
8613
8614 /**
8615 * access control policy
8616 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8617 * listed in hostapd.deny file.
8618 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8619 * listed in hostapd.accept file.
8620 */
8621 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8622 {
8623 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8624 }
8625 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8626 {
8627 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8628 }
8629 else
8630 {
8631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8632 "%s:Acl Policy : %d is not supported",
8633 __func__, params->acl_policy);
8634 return -ENOTSUPP;
8635 }
8636
8637 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8638 {
8639 pConfig->num_accept_mac = params->n_acl_entries;
8640 for (i = 0; i < params->n_acl_entries; i++)
8641 {
8642 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8643 "** Add ACL MAC entry %i in WhiletList :"
8644 MAC_ADDRESS_STR, i,
8645 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8646
8647 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8648 sizeof(qcmacaddr));
8649 }
8650 }
8651 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8652 {
8653 pConfig->num_deny_mac = params->n_acl_entries;
8654 for (i = 0; i < params->n_acl_entries; i++)
8655 {
8656 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8657 "** Add ACL MAC entry %i in BlackList :"
8658 MAC_ADDRESS_STR, i,
8659 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8660
8661 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8662 sizeof(qcmacaddr));
8663 }
8664 }
8665
8666 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8667 {
8668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8669 "%s: SAP Set Mac Acl fail", __func__);
8670 return -EINVAL;
8671 }
8672 }
8673 else
8674 {
8675 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8676 "%s: Invalid device_mode = %d",
8677 __func__, pAdapter->device_mode);
8678 return -EINVAL;
8679 }
8680
8681 return 0;
8682}
8683
Leo Chang9056f462013-08-01 19:21:11 -07008684#ifdef WLAN_NL80211_TESTMODE
8685#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07008686void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07008687(
8688 void *pAdapter,
8689 void *indCont
8690)
8691{
Leo Changd9df8aa2013-09-26 13:32:26 -07008692 tSirLPHBInd *lphbInd;
8693 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07008694
8695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008696 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07008697
8698 if (NULL == indCont)
8699 {
8700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008701 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07008702 return;
8703 }
8704
Leo Changd9df8aa2013-09-26 13:32:26 -07008705 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07008706 skb = cfg80211_testmode_alloc_event_skb(
8707 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07008708 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07008709 GFP_ATOMIC);
8710 if (!skb)
8711 {
8712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8713 "LPHB timeout, NL buffer alloc fail");
8714 return;
8715 }
8716
Leo Changd9df8aa2013-09-26 13:32:26 -07008717 if(!nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
8718 {
8719 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8720 "WLAN_HDD_TM_ATTR_CMD put fail");
8721 goto nla_put_failure;
8722 }
8723 if(!nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
8724 {
8725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8726 "WLAN_HDD_TM_ATTR_TYPE put fail");
8727 goto nla_put_failure;
8728 }
8729 if(!nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
8730 sizeof(tSirLPHBInd), lphbInd))
8731 {
8732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8733 "WLAN_HDD_TM_ATTR_DATA put fail");
8734 goto nla_put_failure;
8735 }
Leo Chang9056f462013-08-01 19:21:11 -07008736 cfg80211_testmode_event(skb, GFP_ATOMIC);
8737 return;
8738
8739nla_put_failure:
8740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8741 "NLA Put fail");
8742 kfree_skb(skb);
8743
8744 return;
8745}
8746#endif /* FEATURE_WLAN_LPHB */
8747
8748static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8749{
8750 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8751 int err = 0;
8752#ifdef FEATURE_WLAN_LPHB
8753 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07008754 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07008755#endif /* FEATURE_WLAN_LPHB */
8756
8757 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8758 if (err)
8759 {
8760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8761 "%s Testmode INV ATTR", __func__);
8762 return err;
8763 }
8764
8765 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8766 {
8767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8768 "%s Testmode INV CMD", __func__);
8769 return -EINVAL;
8770 }
8771
8772 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8773 {
8774#ifdef FEATURE_WLAN_LPHB
8775 /* Low Power Heartbeat configuration request */
8776 case WLAN_HDD_TM_CMD_WLAN_HB:
8777 {
8778 int buf_len;
8779 void *buf;
8780 tSirLPHBReq *hb_params = NULL;
8781
8782 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8783 {
8784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8785 "%s Testmode INV DATA", __func__);
8786 return -EINVAL;
8787 }
8788
8789 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8790 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8791 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8792 if (NULL == hb_params)
8793 {
8794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8795 "%s Request Buffer Alloc Fail", __func__);
8796 return -EINVAL;
8797 }
8798
8799 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07008800 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8801 hb_params,
8802 wlan_hdd_cfg80211_lphb_ind_handler);
8803 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07008804 {
Leo Changd9df8aa2013-09-26 13:32:26 -07008805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8806 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07008807 vos_mem_free(hb_params);
8808 }
Leo Chang9056f462013-08-01 19:21:11 -07008809 return 0;
8810 }
8811#endif /* FEATURE_WLAN_LPHB */
8812 default:
8813 return -EOPNOTSUPP;
8814 }
8815
8816 return err;
8817}
8818#endif /* CONFIG_NL80211_TESTMODE */
8819
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308820static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8821 struct net_device *dev,
8822 int idx, struct survey_info *survey)
8823{
8824 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8825 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308826 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308827 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308828 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308829 v_S7_t snr,rssi;
8830 int status, i, j, filled = 0;
8831
8832 ENTER();
8833
8834
8835 if (NULL == pAdapter)
8836 {
8837 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8838 "%s: HDD adapter is Null", __func__);
8839 return -ENODEV;
8840 }
8841
8842 if (NULL == wiphy)
8843 {
8844 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8845 "%s: wiphy is Null", __func__);
8846 return -ENODEV;
8847 }
8848
8849 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8850 status = wlan_hdd_validate_context(pHddCtx);
8851
8852 if (0 != status)
8853 {
8854 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8855 "%s: HDD context is not valid", __func__);
8856 return status;
8857 }
8858
Mihir Sheted9072e02013-08-21 17:02:29 +05308859 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8860
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308861 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308862 0 != pAdapter->survey_idx ||
8863 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308864 {
8865 /* The survey dump ops when implemented completely is expected to
8866 * return a survey of all channels and the ops is called by the
8867 * kernel with incremental values of the argument 'idx' till it
8868 * returns -ENONET. But we can only support the survey for the
8869 * operating channel for now. survey_idx is used to track
8870 * that the ops is called only once and then return -ENONET for
8871 * the next iteration
8872 */
8873 pAdapter->survey_idx = 0;
8874 return -ENONET;
8875 }
8876
8877 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8878
8879 wlan_hdd_get_snr(pAdapter, &snr);
8880 wlan_hdd_get_rssi(pAdapter, &rssi);
8881
8882 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
8883 hdd_wlan_get_freq(channel, &freq);
8884
8885
8886 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8887 {
8888 if (NULL == wiphy->bands[i])
8889 {
8890 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
8891 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
8892 continue;
8893 }
8894
8895 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8896 {
8897 struct ieee80211_supported_band *band = wiphy->bands[i];
8898
8899 if (band->channels[j].center_freq == (v_U16_t)freq)
8900 {
8901 survey->channel = &band->channels[j];
8902 /* The Rx BDs contain SNR values in dB for the received frames
8903 * while the supplicant expects noise. So we calculate and
8904 * return the value of noise (dBm)
8905 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
8906 */
8907 survey->noise = rssi - snr;
8908 survey->filled = SURVEY_INFO_NOISE_DBM;
8909 filled = 1;
8910 }
8911 }
8912 }
8913
8914 if (filled)
8915 pAdapter->survey_idx = 1;
8916 else
8917 {
8918 pAdapter->survey_idx = 0;
8919 return -ENONET;
8920 }
8921
8922 return 0;
8923}
8924
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308925/*
8926 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
8927 * this is called when cfg80211 driver resume
8928 * driver updates latest sched_scan scan result(if any) to cfg80211 database
8929 */
8930int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
8931{
8932 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8933 hdd_adapter_t *pAdapter;
8934 hdd_adapter_list_node_t *pAdapterNode, *pNext;
8935 VOS_STATUS status = VOS_STATUS_SUCCESS;
8936
8937 ENTER();
8938
8939 if ( NULL == pHddCtx )
8940 {
8941 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8942 "%s: HddCtx validation failed", __func__);
8943 return 0;
8944 }
8945
8946 if (pHddCtx->isLogpInProgress)
8947 {
8948 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8949 "%s: LOGP in Progress. Ignore!!!", __func__);
8950 return 0;
8951 }
8952
8953 if (pHddCtx->isLoadUnloadInProgress)
8954 {
8955 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8956 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8957 return 0;
8958 }
8959
8960 spin_lock(&pHddCtx->schedScan_lock);
8961 pHddCtx->isWiphySuspended = FALSE;
8962 if (TRUE != pHddCtx->isSchedScanUpdatePending)
8963 {
8964 spin_unlock(&pHddCtx->schedScan_lock);
8965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8966 "%s: Return resume is not due to PNO indication", __func__);
8967 return 0;
8968 }
8969 // Reset flag to avoid updatating cfg80211 data old results again
8970 pHddCtx->isSchedScanUpdatePending = FALSE;
8971 spin_unlock(&pHddCtx->schedScan_lock);
8972
8973 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8974
8975 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8976 {
8977 pAdapter = pAdapterNode->pAdapter;
8978 if ( (NULL != pAdapter) &&
8979 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
8980 {
8981 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
8982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8983 "%s: NO SCAN result", __func__);
8984 else
8985 cfg80211_sched_scan_results(pHddCtx->wiphy);
8986
8987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8988 "%s : cfg80211 scan result database updated", __func__);
8989
8990 return 0;
8991
8992 }
8993 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8994 pAdapterNode = pNext;
8995 }
8996
8997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8998 "%s: Failed to find Adapter", __func__);
8999 return 0;
9000}
9001
9002/*
9003 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
9004 * this is called when cfg80211 driver suspends
9005 */
9006int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
9007 struct cfg80211_wowlan *wow)
9008{
9009 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9010
9011 ENTER();
9012 if (NULL == pHddCtx)
9013 {
9014 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9015 "%s: HddCtx validation failed", __func__);
9016 return 0;
9017 }
9018
9019 pHddCtx->isWiphySuspended = TRUE;
9020
9021 EXIT();
9022
9023 return 0;
9024}
9025
Jeff Johnson295189b2012-06-20 16:38:30 -07009026/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309027static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07009028{
9029 .add_virtual_intf = wlan_hdd_add_virtual_intf,
9030 .del_virtual_intf = wlan_hdd_del_virtual_intf,
9031 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
9032 .change_station = wlan_hdd_change_station,
9033#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9034 .add_beacon = wlan_hdd_cfg80211_add_beacon,
9035 .del_beacon = wlan_hdd_cfg80211_del_beacon,
9036 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009037#else
9038 .start_ap = wlan_hdd_cfg80211_start_ap,
9039 .change_beacon = wlan_hdd_cfg80211_change_beacon,
9040 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07009041#endif
9042 .change_bss = wlan_hdd_cfg80211_change_bss,
9043 .add_key = wlan_hdd_cfg80211_add_key,
9044 .get_key = wlan_hdd_cfg80211_get_key,
9045 .del_key = wlan_hdd_cfg80211_del_key,
9046 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009047#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009048 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009049#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009050 .scan = wlan_hdd_cfg80211_scan,
9051 .connect = wlan_hdd_cfg80211_connect,
9052 .disconnect = wlan_hdd_cfg80211_disconnect,
9053 .join_ibss = wlan_hdd_cfg80211_join_ibss,
9054 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
9055 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
9056 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
9057 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07009058 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
9059 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
9060 .mgmt_tx = wlan_hdd_action,
9061#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9062 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
9063 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
9064 .set_txq_params = wlan_hdd_set_txq_params,
9065#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009066 .get_station = wlan_hdd_cfg80211_get_station,
9067 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
9068 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009069 .add_station = wlan_hdd_cfg80211_add_station,
9070#ifdef FEATURE_WLAN_LFR
9071 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
9072 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
9073 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
9074#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009075#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
9076 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
9077#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009078#ifdef FEATURE_WLAN_TDLS
9079 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
9080 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
9081#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309082#ifdef WLAN_FEATURE_GTK_OFFLOAD
9083 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
9084#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309085#ifdef FEATURE_WLAN_SCAN_PNO
9086 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
9087 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
9088#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309089 .resume = wlan_hdd_cfg80211_resume_wlan,
9090 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309091 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07009092#ifdef WLAN_NL80211_TESTMODE
9093 .testmode_cmd = wlan_hdd_cfg80211_testmode,
9094#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309095 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009096};
9097