blob: 3abd4447742d636291174076ed5972fca3e77d67 [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
642 /* This will disable updating of NL channels from passive to
643 * active if a beacon is received on passive channel. */
644 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -0700645
Amar Singhalfddc28c2013-09-05 13:03:40 -0700646
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700647#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700648 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
649 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
650 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700651 | WIPHY_FLAG_OFFCHAN_TX;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700652#endif
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700653#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
654 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800655#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700656 || pCfg->isFastRoamIniFeatureEnabled
657#endif
658#ifdef FEATURE_WLAN_CCX
659 || pCfg->isCcxIniFeatureEnabled
660#endif
661 )
662 {
663 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
664 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800665#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800666#ifdef FEATURE_WLAN_TDLS
667 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
668 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
669#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530670#ifdef FEATURE_WLAN_SCAN_PNO
671 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
Madan Mohan Koyyalamudi75de0102013-09-17 14:56:29 +0530672 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530673 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +0530674 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530675#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800676
Amar Singhalfddc28c2013-09-05 13:03:40 -0700677#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700678 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
679 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -0700680 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700681 driver need to determine what to do with both
682 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -0700683
684 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
685#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700686
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530687 wiphy->max_scan_ssids = MAX_SCAN_SSID;
688
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530689 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700690
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530691 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
692
Jeff Johnson295189b2012-06-20 16:38:30 -0700693 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530694 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700695 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 | BIT(NL80211_IFTYPE_P2P_CLIENT)
697 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 | BIT(NL80211_IFTYPE_AP);
699
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800700#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800701 if( pCfg->enableMCC )
702 {
703 /* Currently, supports up to two channels */
704 wlan_hdd_iface_combination.num_different_channels = 2;
705
706 if( !pCfg->allowMCCGODiffBI )
707 wlan_hdd_iface_combination.beacon_int_infra_match = true;
708
709 }
710 wiphy->iface_combinations = &wlan_hdd_iface_combination;
711 wiphy->n_iface_combinations = 1;
712#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800713
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 /* Before registering we need to update the ht capabilitied based
715 * on ini values*/
716 if( !pCfg->ShortGI20MhzEnable )
717 {
718 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
719 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
720 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
721 }
722
723 if( !pCfg->ShortGI40MhzEnable )
724 {
725 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
726 }
727
728 if( !pCfg->nChannelBondingMode5GHz )
729 {
730 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
731 }
732
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530733 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
734 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
735
736 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
737 {
738
739 if (NULL == wiphy->bands[i])
740 {
741 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
742 __func__, i);
743 continue;
744 }
745
746 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
747 {
748 struct ieee80211_supported_band *band = wiphy->bands[i];
749
750 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
751 {
752 // Enable social channels for P2P
753 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
754 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
755 else
756 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
757 continue;
758 }
759 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
760 {
761 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
762 continue;
763 }
764 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 }
766 /*Initialise the supported cipher suite details*/
767 wiphy->cipher_suites = hdd_cipher_suites;
768 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
769
770 /*signal strength in mBm (100*dBm) */
771 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
772
773#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 wiphy->max_remain_on_channel_duration = 1000;
775#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700776
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530777 EXIT();
778 return 0;
779}
780
781/* In this function we are registering wiphy. */
782int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
783{
784 ENTER();
785 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 if (0 > wiphy_register(wiphy))
787 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530788 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
790 return -EIO;
791 }
792
793 EXIT();
794 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530795}
Jeff Johnson295189b2012-06-20 16:38:30 -0700796
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530797/* In this function we are updating channel list when,
798 regulatory domain is FCC and country code is US.
799 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
800 As per FCC smart phone is not a indoor device.
801 GO should not opeate on indoor channels */
802void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
803{
804 int j;
805 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
806 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
807 //Default counrtycode from NV at the time of wiphy initialization.
808 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
809 &defaultCountryCode[0]))
810 {
811 hddLog(LOGE, FL("%s Failed to get default country code from NV"));
812 }
813 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
814 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530815 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
816 {
817 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
818 return;
819 }
820 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
821 {
822 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
823 // Mark UNII -1 band channel as passive
824 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
825 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
826 }
827 }
828}
829
Jeff Johnson295189b2012-06-20 16:38:30 -0700830/* In this function we will do all post VOS start initialization.
831 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530832 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700833*/
834void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
835{
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
837 /* Register for all P2P action, public action etc frames */
838 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
839
Jeff Johnsone7245742012-09-05 17:12:55 -0700840 ENTER();
841
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 /* Right now we are registering these frame when driver is getting
843 initialized. Once we will move to 2.6.37 kernel, in which we have
844 frame register ops, we will move this code as a part of that */
845 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530846 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
848
849 /* GAS Initial Response */
850 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
851 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530852
Jeff Johnson295189b2012-06-20 16:38:30 -0700853 /* GAS Comeback Request */
854 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
855 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
856
857 /* GAS Comeback Response */
858 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
859 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
860
861 /* P2P Public Action */
862 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530863 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 P2P_PUBLIC_ACTION_FRAME_SIZE );
865
866 /* P2P Action */
867 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
868 (v_U8_t*)P2P_ACTION_FRAME,
869 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700870
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530871 /* WNM BSS Transition Request frame */
872 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
873 (v_U8_t*)WNM_BSS_ACTION_FRAME,
874 WNM_BSS_ACTION_FRAME_SIZE );
875
Chet Lanctot186b5732013-03-18 10:26:30 -0700876#ifdef WLAN_FEATURE_11W
877 /* SA Query Response Action Frame */
878 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
879 (v_U8_t*)SA_QUERY_FRAME_RSP,
880 SA_QUERY_FRAME_RSP_SIZE );
881#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700882}
883
884void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
885{
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
887 /* Register for all P2P action, public action etc frames */
888 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
889
Jeff Johnsone7245742012-09-05 17:12:55 -0700890 ENTER();
891
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 /* Right now we are registering these frame when driver is getting
893 initialized. Once we will move to 2.6.37 kernel, in which we have
894 frame register ops, we will move this code as a part of that */
895 /* GAS Initial Request */
896
897 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
898 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
899
900 /* GAS Initial Response */
901 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
902 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530903
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 /* GAS Comeback Request */
905 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
906 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
907
908 /* GAS Comeback Response */
909 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
910 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
911
912 /* P2P Public Action */
913 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530914 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 P2P_PUBLIC_ACTION_FRAME_SIZE );
916
917 /* P2P Action */
918 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
919 (v_U8_t*)P2P_ACTION_FRAME,
920 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700921
922#ifdef WLAN_FEATURE_11W
923 /* SA Query Response Action Frame */
924 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
925 (v_U8_t*)SA_QUERY_FRAME_RSP,
926 SA_QUERY_FRAME_RSP_SIZE );
927#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700928}
929
930#ifdef FEATURE_WLAN_WAPI
931void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
932 const u8 *mac_addr, u8 *key , int key_Len)
933{
934 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
935 tCsrRoamSetKey setKey;
936 v_BOOL_t isConnected = TRUE;
937 int status = 0;
938 v_U32_t roamId= 0xFF;
939 tANI_U8 *pKeyPtr = NULL;
940 int n = 0;
941
942 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
943 __func__,pAdapter->device_mode);
944
Gopichand Nakkalae7480202013-02-11 15:24:22 +0530945 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 setKey.keyId = key_index; // Store Key ID
947 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
948 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
949 setKey.paeRole = 0 ; // the PAE role
950 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
951 {
952 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
953 }
954 else
955 {
956 isConnected = hdd_connIsConnected(pHddStaCtx);
957 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
958 }
959 setKey.keyLength = key_Len;
960 pKeyPtr = setKey.Key;
961 memcpy( pKeyPtr, key, key_Len);
962
963 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
964 __func__, key_Len);
965 for (n = 0 ; n < key_Len; n++)
966 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
967 __func__,n,setKey.Key[n]);
968
969 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
970 if ( isConnected )
971 {
972 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
973 pAdapter->sessionId, &setKey, &roamId );
974 }
975 if ( status != 0 )
976 {
977 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
978 "[%4d] sme_RoamSetKey returned ERROR status= %d",
979 __LINE__, status );
980 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
981 }
982}
983#endif /* FEATURE_WLAN_WAPI*/
984
985#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530986int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 beacon_data_t **ppBeacon,
988 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700989#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530990int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700991 beacon_data_t **ppBeacon,
992 struct cfg80211_beacon_data *params,
993 int dtim_period)
994#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530995{
Jeff Johnson295189b2012-06-20 16:38:30 -0700996 int size;
997 beacon_data_t *beacon = NULL;
998 beacon_data_t *old = NULL;
999 int head_len,tail_len;
1000
Jeff Johnsone7245742012-09-05 17:12:55 -07001001 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001002 if (params->head && !params->head_len)
1003 return -EINVAL;
1004
1005 old = pAdapter->sessionCtx.ap.beacon;
1006
1007 if (!params->head && !old)
1008 return -EINVAL;
1009
1010 if (params->tail && !params->tail_len)
1011 return -EINVAL;
1012
1013#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1014 /* Kernel 3.0 is not updating dtim_period for set beacon */
1015 if (!params->dtim_period)
1016 return -EINVAL;
1017#endif
1018
1019 if(params->head)
1020 head_len = params->head_len;
1021 else
1022 head_len = old->head_len;
1023
1024 if(params->tail || !old)
1025 tail_len = params->tail_len;
1026 else
1027 tail_len = old->tail_len;
1028
1029 size = sizeof(beacon_data_t) + head_len + tail_len;
1030
1031 beacon = kzalloc(size, GFP_KERNEL);
1032
1033 if( beacon == NULL )
1034 return -ENOMEM;
1035
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001036#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 if(params->dtim_period || !old )
1038 beacon->dtim_period = params->dtim_period;
1039 else
1040 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001041#else
1042 if(dtim_period || !old )
1043 beacon->dtim_period = dtim_period;
1044 else
1045 beacon->dtim_period = old->dtim_period;
1046#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301047
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1049 beacon->tail = beacon->head + head_len;
1050 beacon->head_len = head_len;
1051 beacon->tail_len = tail_len;
1052
1053 if(params->head) {
1054 memcpy (beacon->head,params->head,beacon->head_len);
1055 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301056 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 if(old)
1058 memcpy (beacon->head,old->head,beacon->head_len);
1059 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301060
Jeff Johnson295189b2012-06-20 16:38:30 -07001061 if(params->tail) {
1062 memcpy (beacon->tail,params->tail,beacon->tail_len);
1063 }
1064 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301065 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 memcpy (beacon->tail,old->tail,beacon->tail_len);
1067 }
1068
1069 *ppBeacon = beacon;
1070
1071 kfree(old);
1072
1073 return 0;
1074
1075}
Jeff Johnson295189b2012-06-20 16:38:30 -07001076
1077v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1078{
1079 int left = length;
1080 v_U8_t *ptr = pIes;
1081 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301082
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301084 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 elem_id = ptr[0];
1086 elem_len = ptr[1];
1087 left -= 2;
1088 if(elem_len > left)
1089 {
1090 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001091 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 eid,elem_len,left);
1093 return NULL;
1094 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301095 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001096 {
1097 return ptr;
1098 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301099
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 left -= elem_len;
1101 ptr += (elem_len + 2);
1102 }
1103 return NULL;
1104}
1105
Jeff Johnson295189b2012-06-20 16:38:30 -07001106/* Check if rate is 11g rate or not */
1107static int wlan_hdd_rate_is_11g(u8 rate)
1108{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001109 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 u8 i;
1111 for (i = 0; i < 8; i++)
1112 {
1113 if(rate == gRateArray[i])
1114 return TRUE;
1115 }
1116 return FALSE;
1117}
1118
1119/* Check for 11g rate and set proper 11g only mode */
1120static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1121 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1122{
1123 u8 i, num_rates = pIe[0];
1124
1125 pIe += 1;
1126 for ( i = 0; i < num_rates; i++)
1127 {
1128 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1129 {
1130 /* If rate set have 11g rate than change the mode to 11G */
1131 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1132 if (pIe[i] & BASIC_RATE_MASK)
1133 {
1134 /* If we have 11g rate as basic rate, it means mode
1135 is 11g only mode.
1136 */
1137 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1138 *pCheckRatesfor11g = FALSE;
1139 }
1140 }
1141 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1142 {
1143 *require_ht = TRUE;
1144 }
1145 }
1146 return;
1147}
1148
1149static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1150{
1151 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1152 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1153 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1154 u8 checkRatesfor11g = TRUE;
1155 u8 require_ht = FALSE;
1156 u8 *pIe=NULL;
1157
1158 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1159
1160 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1161 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1162 if (pIe != NULL)
1163 {
1164 pIe += 1;
1165 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1166 &pConfig->SapHw_mode);
1167 }
1168
1169 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1170 WLAN_EID_EXT_SUPP_RATES);
1171 if (pIe != NULL)
1172 {
1173
1174 pIe += 1;
1175 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1176 &pConfig->SapHw_mode);
1177 }
1178
1179 if( pConfig->channel > 14 )
1180 {
1181 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1182 }
1183
1184 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1185 WLAN_EID_HT_CAPABILITY);
1186
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301187 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 {
1189 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1190 if(require_ht)
1191 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1192 }
1193}
1194
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301195static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1196 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1197{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001198 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301199 v_U8_t *pIe = NULL;
1200 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1201
1202 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1203 pBeacon->tail, pBeacon->tail_len);
1204
1205 if (pIe)
1206 {
1207 ielen = pIe[1] + 2;
1208 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1209 {
1210 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1211 }
1212 else
1213 {
1214 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1215 return -EINVAL;
1216 }
1217 *total_ielen += ielen;
1218 }
1219 return 0;
1220}
1221
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001222static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
1223 v_U8_t *genie, v_U8_t *total_ielen)
1224{
1225 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1226 int left = pBeacon->tail_len;
1227 v_U8_t *ptr = pBeacon->tail;
1228 v_U8_t elem_id, elem_len;
1229 v_U16_t ielen = 0;
1230
1231 if ( NULL == ptr || 0 == left )
1232 return;
1233
1234 while (left >= 2)
1235 {
1236 elem_id = ptr[0];
1237 elem_len = ptr[1];
1238 left -= 2;
1239 if (elem_len > left)
1240 {
1241 hddLog( VOS_TRACE_LEVEL_ERROR,
1242 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
1243 elem_id, elem_len, left);
1244 return;
1245 }
1246 if (IE_EID_VENDOR == elem_id)
1247 {
1248 /* skipping the VSIE's which we don't want to include or
1249 * it will be included by existing code
1250 */
1251 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
1252#ifdef WLAN_FEATURE_WFD
1253 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
1254#endif
1255 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1256 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1257 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
1258 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1259 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
1260 {
1261 ielen = ptr[1] + 2;
1262 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1263 {
1264 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
1265 *total_ielen += ielen;
1266 }
1267 else
1268 {
1269 hddLog( VOS_TRACE_LEVEL_ERROR,
1270 "IE Length is too big "
1271 "IEs eid=%d elem_len=%d total_ie_lent=%d",
1272 elem_id, elem_len, *total_ielen);
1273 }
1274 }
1275 }
1276
1277 left -= elem_len;
1278 ptr += (elem_len + 2);
1279 }
1280 return;
1281}
1282
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001283#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001284static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1285 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001286#else
1287static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1288 struct cfg80211_beacon_data *params)
1289#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001290{
1291 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301292 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001294 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001295
1296 genie = vos_mem_malloc(MAX_GENIE_LEN);
1297
1298 if(genie == NULL) {
1299
1300 return -ENOMEM;
1301 }
1302
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301303 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1304 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301306 ret = -EINVAL;
1307 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 }
1309
1310#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301311 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1312 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1313 {
1314 ret = -EINVAL;
1315 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 }
1317#endif
1318
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301319 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1320 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301322 ret = -EINVAL;
1323 goto done;
1324 }
1325
1326 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1327 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001328 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001330
1331 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1332 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1333 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1334 {
1335 hddLog(LOGE,
1336 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001337 ret = -EINVAL;
1338 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 }
1340
1341 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1342 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1343 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1344 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1345 ==eHAL_STATUS_FAILURE)
1346 {
1347 hddLog(LOGE,
1348 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001349 ret = -EINVAL;
1350 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 }
1352
1353 // Added for ProResp IE
1354 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1355 {
1356 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1357 u8 probe_rsp_ie_len[3] = {0};
1358 u8 counter = 0;
1359 /* Check Probe Resp Length if it is greater then 255 then Store
1360 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1361 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1362 Store More then 255 bytes into One Variable.
1363 */
1364 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1365 {
1366 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1367 {
1368 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1369 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1370 }
1371 else
1372 {
1373 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1374 rem_probe_resp_ie_len = 0;
1375 }
1376 }
1377
1378 rem_probe_resp_ie_len = 0;
1379
1380 if (probe_rsp_ie_len[0] > 0)
1381 {
1382 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1383 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1384 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1385 probe_rsp_ie_len[0], NULL,
1386 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1387 {
1388 hddLog(LOGE,
1389 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001390 ret = -EINVAL;
1391 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 }
1393 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1394 }
1395
1396 if (probe_rsp_ie_len[1] > 0)
1397 {
1398 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1399 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1400 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1401 probe_rsp_ie_len[1], NULL,
1402 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1403 {
1404 hddLog(LOGE,
1405 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001406 ret = -EINVAL;
1407 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001408 }
1409 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1410 }
1411
1412 if (probe_rsp_ie_len[2] > 0)
1413 {
1414 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1415 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1416 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1417 probe_rsp_ie_len[2], NULL,
1418 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1419 {
1420 hddLog(LOGE,
1421 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001422 ret = -EINVAL;
1423 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 }
1425 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1426 }
1427
1428 if (probe_rsp_ie_len[1] == 0 )
1429 {
1430 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1431 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1432 eANI_BOOLEAN_FALSE) )
1433 {
1434 hddLog(LOGE,
1435 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1436 }
1437 }
1438
1439 if (probe_rsp_ie_len[2] == 0 )
1440 {
1441 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1442 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1443 eANI_BOOLEAN_FALSE) )
1444 {
1445 hddLog(LOGE,
1446 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1447 }
1448 }
1449
1450 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1451 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1452 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1453 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1454 == eHAL_STATUS_FAILURE)
1455 {
1456 hddLog(LOGE,
1457 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001458 ret = -EINVAL;
1459 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 }
1461 }
1462 else
1463 {
1464 // Reset WNI_CFG_PROBE_RSP Flags
1465 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1466
1467 hddLog(VOS_TRACE_LEVEL_INFO,
1468 "%s: No Probe Response IE received in set beacon",
1469 __func__);
1470 }
1471
1472 // Added for AssocResp IE
1473 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1474 {
1475 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1476 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1477 params->assocresp_ies_len, NULL,
1478 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1479 {
1480 hddLog(LOGE,
1481 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001482 ret = -EINVAL;
1483 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 }
1485
1486 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1487 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1488 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1489 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1490 == eHAL_STATUS_FAILURE)
1491 {
1492 hddLog(LOGE,
1493 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001494 ret = -EINVAL;
1495 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 }
1497 }
1498 else
1499 {
1500 hddLog(VOS_TRACE_LEVEL_INFO,
1501 "%s: No Assoc Response IE received in set beacon",
1502 __func__);
1503
1504 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1505 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1506 eANI_BOOLEAN_FALSE) )
1507 {
1508 hddLog(LOGE,
1509 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1510 }
1511 }
1512
Jeff Johnsone7245742012-09-05 17:12:55 -07001513done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001514 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301515 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001516}
Jeff Johnson295189b2012-06-20 16:38:30 -07001517
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301518/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001519 * FUNCTION: wlan_hdd_validate_operation_channel
1520 * called by wlan_hdd_cfg80211_start_bss() and
1521 * wlan_hdd_cfg80211_set_channel()
1522 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301523 * channel list.
1524 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001525VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001526{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301527
Jeff Johnson295189b2012-06-20 16:38:30 -07001528 v_U32_t num_ch = 0;
1529 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1530 u32 indx = 0;
1531 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301532 v_U8_t fValidChannel = FALSE, count = 0;
1533 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301534
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1536
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301537 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001538 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301539 /* Validate the channel */
1540 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001541 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301542 if ( channel == rfChannels[count].channelNum )
1543 {
1544 fValidChannel = TRUE;
1545 break;
1546 }
1547 }
1548 if (fValidChannel != TRUE)
1549 {
1550 hddLog(VOS_TRACE_LEVEL_ERROR,
1551 "%s: Invalid Channel [%d]", __func__, channel);
1552 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 }
1554 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301555 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001556 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301557 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1558 valid_ch, &num_ch))
1559 {
1560 hddLog(VOS_TRACE_LEVEL_ERROR,
1561 "%s: failed to get valid channel list", __func__);
1562 return VOS_STATUS_E_FAILURE;
1563 }
1564 for (indx = 0; indx < num_ch; indx++)
1565 {
1566 if (channel == valid_ch[indx])
1567 {
1568 break;
1569 }
1570 }
1571
1572 if (indx >= num_ch)
1573 {
1574 hddLog(VOS_TRACE_LEVEL_ERROR,
1575 "%s: Invalid Channel [%d]", __func__, channel);
1576 return VOS_STATUS_E_FAILURE;
1577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 }
1579 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301580
Jeff Johnson295189b2012-06-20 16:38:30 -07001581}
1582
Viral Modi3a32cc52013-02-08 11:14:52 -08001583/**
1584 * FUNCTION: wlan_hdd_cfg80211_set_channel
1585 * This function is used to set the channel number
1586 */
1587static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1588 struct ieee80211_channel *chan,
1589 enum nl80211_channel_type channel_type
1590 )
1591{
1592 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001593 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001594 hdd_adapter_t *pAdapter = NULL;
1595 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301596 hdd_context_t *pHddCtx;
1597 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001598
1599 ENTER();
1600
1601 if( NULL == dev )
1602 {
1603 hddLog(VOS_TRACE_LEVEL_ERROR,
1604 "%s: Called with dev = NULL.\n", __func__);
1605 return -ENODEV;
1606 }
1607 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1608
1609 hddLog(VOS_TRACE_LEVEL_INFO,
1610 "%s: device_mode = %d freq = %d \n",__func__,
1611 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301612
1613 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1614 status = wlan_hdd_validate_context(pHddCtx);
1615
1616 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001617 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301618 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1619 "%s: HDD context is not valid", __func__);
1620 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001621 }
1622
1623 /*
1624 * Do freq to chan conversion
1625 * TODO: for 11a
1626 */
1627
1628 channel = ieee80211_frequency_to_channel(freq);
1629
1630 /* Check freq range */
1631 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1632 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1633 {
1634 hddLog(VOS_TRACE_LEVEL_ERROR,
1635 "%s: Channel [%d] is outside valid range from %d to %d\n",
1636 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1637 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1638 return -EINVAL;
1639 }
1640
1641 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1642
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301643 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1644 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001645 {
1646 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1647 {
1648 hddLog(VOS_TRACE_LEVEL_ERROR,
1649 "%s: Invalid Channel [%d] \n", __func__, channel);
1650 return -EINVAL;
1651 }
1652 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1653 "%s: set channel to [%d] for device mode =%d",
1654 __func__, channel,pAdapter->device_mode);
1655 }
1656 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001657 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001658 )
1659 {
1660 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1661 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1662 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1663
1664 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1665 {
1666 /* Link is up then return cant set channel*/
1667 hddLog( VOS_TRACE_LEVEL_ERROR,
1668 "%s: IBSS Associated, can't set the channel\n", __func__);
1669 return -EINVAL;
1670 }
1671
1672 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1673 pHddStaCtx->conn_info.operationChannel = channel;
1674 pRoamProfile->ChannelInfo.ChannelList =
1675 &pHddStaCtx->conn_info.operationChannel;
1676 }
1677 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001678 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001679 )
1680 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301681 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1682 {
1683 if(VOS_STATUS_SUCCESS !=
1684 wlan_hdd_validate_operation_channel(pAdapter,channel))
1685 {
1686 hddLog(VOS_TRACE_LEVEL_ERROR,
1687 "%s: Invalid Channel [%d] \n", __func__, channel);
1688 return -EINVAL;
1689 }
1690 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1691 }
1692 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001693 {
1694 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1695
1696 /* If auto channel selection is configured as enable/ 1 then ignore
1697 channel set by supplicant
1698 */
1699 if ( cfg_param->apAutoChannelSelection )
1700 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301701 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1702 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001703 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1704 "%s: set channel to auto channel (0) for device mode =%d",
1705 __func__, pAdapter->device_mode);
1706 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301707 else
1708 {
1709 if(VOS_STATUS_SUCCESS !=
1710 wlan_hdd_validate_operation_channel(pAdapter,channel))
1711 {
1712 hddLog(VOS_TRACE_LEVEL_ERROR,
1713 "%s: Invalid Channel [%d] \n", __func__, channel);
1714 return -EINVAL;
1715 }
1716 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1717 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001718 }
1719 }
1720 else
1721 {
1722 hddLog(VOS_TRACE_LEVEL_FATAL,
1723 "%s: Invalid device mode failed to set valid channel", __func__);
1724 return -EINVAL;
1725 }
1726 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301727 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001728}
1729
Jeff Johnson295189b2012-06-20 16:38:30 -07001730#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1731static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1732 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001733#else
1734static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1735 struct cfg80211_beacon_data *params,
1736 const u8 *ssid, size_t ssid_len,
1737 enum nl80211_hidden_ssid hidden_ssid)
1738#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001739{
1740 tsap_Config_t *pConfig;
1741 beacon_data_t *pBeacon = NULL;
1742 struct ieee80211_mgmt *pMgmt_frame;
1743 v_U8_t *pIe=NULL;
1744 v_U16_t capab_info;
1745 eCsrAuthType RSNAuthType;
1746 eCsrEncryptionType RSNEncryptType;
1747 eCsrEncryptionType mcRSNEncryptType;
1748 int status = VOS_STATUS_SUCCESS;
1749 tpWLAN_SAPEventCB pSapEventCallback;
1750 hdd_hostapd_state_t *pHostapdState;
1751 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1752 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301753 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 struct qc_mac_acl_entry *acl_entry = NULL;
1755 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001756 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001757
1758 ENTER();
1759
1760 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1761
1762 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1763
1764 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1765
1766 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1767
1768 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1769
1770 //channel is already set in the set_channel Call back
1771 //pConfig->channel = pCommitConfig->channel;
1772
1773 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301774 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001775 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1776
1777 pConfig->dtim_period = pBeacon->dtim_period;
1778
1779 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1780 pConfig->dtim_period);
1781
1782
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001783 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001784 {
1785 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 WLAN_EID_COUNTRY);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001787 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001789 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001790 pConfig->ieee80211d = 1;
1791 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1792 sme_setRegInfo(hHal, pConfig->countryCode);
1793 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001795 else
1796 {
1797 pConfig->ieee80211d = 0;
1798 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301799 /*
1800 * If auto channel is configured i.e. channel is 0,
1801 * so skip channel validation.
1802 */
1803 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1804 {
1805 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1806 {
1807 hddLog(VOS_TRACE_LEVEL_ERROR,
1808 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1809 return -EINVAL;
1810 }
1811 }
1812 else
1813 {
1814 if(1 != pHddCtx->is_dynamic_channel_range_set)
1815 {
1816 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1817 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1818 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1819 }
1820 pHddCtx->is_dynamic_channel_range_set = 0;
1821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001822 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001823 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001824 {
1825 pConfig->ieee80211d = 0;
1826 }
1827 pConfig->authType = eSAP_AUTO_SWITCH;
1828
1829 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301830
1831 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1833
1834 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1835
1836 /*Set wps station to configured*/
1837 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1838
1839 if(pIe)
1840 {
1841 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1842 {
1843 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1844 return -EINVAL;
1845 }
1846 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1847 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001848 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 /* Check 15 bit of WPS IE as it contain information for wps state
1850 * WPS state
1851 */
1852 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1853 {
1854 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1855 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1856 {
1857 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1858 }
1859 }
1860 }
1861 else
1862 {
1863 pConfig->wps_state = SAP_WPS_DISABLED;
1864 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301865 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001866
1867 pConfig->RSNWPAReqIELength = 0;
1868 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301869 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 WLAN_EID_RSN);
1871 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301872 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001873 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1874 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1875 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301876 /* The actual processing may eventually be more extensive than
1877 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 * by the app.
1879 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301880 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1882 &RSNEncryptType,
1883 &mcRSNEncryptType,
1884 &RSNAuthType,
1885 pConfig->pRSNWPAReqIE[1]+2,
1886 pConfig->pRSNWPAReqIE );
1887
1888 if( VOS_STATUS_SUCCESS == status )
1889 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301890 /* Now copy over all the security attributes you have
1891 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 * */
1893 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1894 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1895 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1896 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301897 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 "EncryptionType = %d mcEncryptionType = %d\n"),
1899 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1900 }
1901 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301902
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1904 pBeacon->tail, pBeacon->tail_len);
1905
1906 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1907 {
1908 if (pConfig->pRSNWPAReqIE)
1909 {
1910 /*Mixed mode WPA/WPA2*/
1911 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1912 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1913 }
1914 else
1915 {
1916 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1917 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1918 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301919 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1921 &RSNEncryptType,
1922 &mcRSNEncryptType,
1923 &RSNAuthType,
1924 pConfig->pRSNWPAReqIE[1]+2,
1925 pConfig->pRSNWPAReqIE );
1926
1927 if( VOS_STATUS_SUCCESS == status )
1928 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301929 /* Now copy over all the security attributes you have
1930 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 * */
1932 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1933 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1934 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1935 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301936 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 "EncryptionType = %d mcEncryptionType = %d\n"),
1938 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1939 }
1940 }
1941 }
1942
Jeff Johnson4416a782013-03-25 14:17:50 -07001943 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1944 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1945 return -EINVAL;
1946 }
1947
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1949
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001950#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 if (params->ssid != NULL)
1952 {
1953 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1954 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1955 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1956 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1957 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001958#else
1959 if (ssid != NULL)
1960 {
1961 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1962 pConfig->SSIDinfo.ssid.length = ssid_len;
1963 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1964 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1965 }
1966#endif
1967
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301968 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301970
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 /* default value */
1972 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1973 pConfig->num_accept_mac = 0;
1974 pConfig->num_deny_mac = 0;
1975
1976 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1977 pBeacon->tail, pBeacon->tail_len);
1978
1979 /* pIe for black list is following form:
1980 type : 1 byte
1981 length : 1 byte
1982 OUI : 4 bytes
1983 acl type : 1 byte
1984 no of mac addr in black list: 1 byte
1985 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301986 */
1987 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001988 {
1989 pConfig->SapMacaddr_acl = pIe[6];
1990 pConfig->num_deny_mac = pIe[7];
1991 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
1992 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05301993 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
1994 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001995 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
1996 for (i = 0; i < pConfig->num_deny_mac; i++)
1997 {
1998 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
1999 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 }
2002 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2003 pBeacon->tail, pBeacon->tail_len);
2004
2005 /* pIe for white list is following form:
2006 type : 1 byte
2007 length : 1 byte
2008 OUI : 4 bytes
2009 acl type : 1 byte
2010 no of mac addr in white list: 1 byte
2011 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302012 */
2013 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 {
2015 pConfig->SapMacaddr_acl = pIe[6];
2016 pConfig->num_accept_mac = pIe[7];
2017 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
2018 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302019 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2020 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2022 for (i = 0; i < pConfig->num_accept_mac; i++)
2023 {
2024 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2025 acl_entry++;
2026 }
2027 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302028
Jeff Johnson295189b2012-06-20 16:38:30 -07002029 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2030
Jeff Johnsone7245742012-09-05 17:12:55 -07002031#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002032 /* Overwrite the hostapd setting for HW mode only for 11ac.
2033 * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini .
2034 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */
2035 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2036 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302037 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002038 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
2039 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002040 {
2041 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002042
2043 /* Disable VHT support in 2.4 GHz band */
2044 if (pConfig->channel <= 14 &&
2045 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2046 {
2047 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2048 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002049 }
2050#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302051
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002052 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2053 {
2054 sme_SelectCBMode(hHal,
2055 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2056 pConfig->channel);
2057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 // ht_capab is not what the name conveys,this is used for protection bitmap
2059 pConfig->ht_capab =
2060 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2061
2062 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2063 {
2064 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2065 return -EINVAL;
2066 }
2067
2068 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302069 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2071 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302072 pConfig->obssProtEnabled =
2073 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002074
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302075 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302077 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
2079 (int)pConfig->channel);
2080 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302081 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
2082 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302084 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
2086 pConfig->protEnabled, pConfig->obssProtEnabled);
2087
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302088 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 {
2090 //Bss already started. just return.
2091 //TODO Probably it should update some beacon params.
2092 hddLog( LOGE, "Bss Already started...Ignore the request");
2093 EXIT();
2094 return 0;
2095 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302096
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 pConfig->persona = pHostapdAdapter->device_mode;
2098
2099 pSapEventCallback = hdd_hostapd_SAPEventCB;
2100 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2101 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2102 {
2103 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2104 return -EINVAL;
2105 }
2106
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302107 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2109
2110 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302111
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302113 {
2114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002115 ("ERROR: HDD vos wait for single_event failed!!\n"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002116 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 VOS_ASSERT(0);
2118 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302119
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 //Succesfully started Bss update the state bit.
2121 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2122
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002123#ifdef WLAN_FEATURE_P2P_DEBUG
2124 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2125 {
2126 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2127 {
2128 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2129 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002130 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002131 }
2132 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2133 {
2134 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2135 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002136 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002137 }
2138 }
2139#endif
2140
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 pHostapdState->bCommit = TRUE;
2142 EXIT();
2143
2144 return 0;
2145}
2146
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002147#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302148static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2149 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 struct beacon_parameters *params)
2151{
2152 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302153 hdd_context_t *pHddCtx;
2154 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002155
2156 ENTER();
2157
2158 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
2159
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302160 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2161 status = wlan_hdd_validate_context(pHddCtx);
2162
2163 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002164 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302165 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2166 "%s: HDD context is not valid", __func__);
2167 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002168 }
2169
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302170 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 )
2173 {
2174 beacon_data_t *old,*new;
2175
2176 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302177
Jeff Johnson295189b2012-06-20 16:38:30 -07002178 if (old)
2179 return -EALREADY;
2180
2181 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2182
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302183 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 {
2185 hddLog(VOS_TRACE_LEVEL_FATAL,
2186 "%s:Error!!! Allocating the new beacon\n",__func__);
2187 return -EINVAL;
2188 }
2189
2190 pAdapter->sessionCtx.ap.beacon = new;
2191
2192 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2193 }
2194
2195 EXIT();
2196 return status;
2197}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302198
2199static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 struct net_device *dev,
2201 struct beacon_parameters *params)
2202{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302203 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302204 hdd_context_t *pHddCtx;
2205 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002206
2207 ENTER();
2208
2209 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2210 __func__,pAdapter->device_mode);
2211
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302212 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2213 status = wlan_hdd_validate_context(pHddCtx);
2214
2215 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002216 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302217 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2218 "%s: HDD context is not valid", __func__);
2219 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002220 }
2221
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302222 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302224 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 {
2226 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302227
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302229
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 if (!old)
2231 return -ENOENT;
2232
2233 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2234
2235 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302236 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 "%s: Error!!! Allocating the new beacon\n",__func__);
2238 return -EINVAL;
2239 }
2240
2241 pAdapter->sessionCtx.ap.beacon = new;
2242
2243 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2244 }
2245
2246 EXIT();
2247 return status;
2248}
2249
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002250#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2251
2252#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002253static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2254 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002255#else
2256static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2257 struct net_device *dev)
2258#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002259{
2260 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002261 hdd_context_t *pHddCtx = NULL;
2262 hdd_scaninfo_t *pScanInfo = NULL;
2263 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302264 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002265
2266 ENTER();
2267
2268 if (NULL == pAdapter)
2269 {
2270 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002271 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 return -ENODEV;
2273 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002274
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302275 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2276 status = wlan_hdd_validate_context(pHddCtx);
2277
2278 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002279 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302280 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2281 "%s: HDD context is not valid", __func__);
2282 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002283 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002284
2285 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2286 if (NULL == staAdapter)
2287 {
2288 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2289 if (NULL == staAdapter)
2290 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302291 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002292 "%s: HDD adapter context is Null", __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002293 return -ENODEV;
2294 }
2295 }
2296
2297 pScanInfo = &pHddCtx->scan_info;
2298
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2300 __func__,pAdapter->device_mode);
2301
Jeff Johnsone7245742012-09-05 17:12:55 -07002302 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
2303 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002304 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05302305 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002306 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002307 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002308 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2309 if (!status)
2310 {
2311 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson902c9832012-12-10 14:28:09 -08002312 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002313 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002314 VOS_ASSERT(pScanInfo->mScanPending);
2315 return 0;
2316 }
2317 }
2318
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002321 )
2322 {
2323 beacon_data_t *old;
2324
2325 old = pAdapter->sessionCtx.ap.beacon;
2326
2327 if (!old)
2328 return -ENOENT;
2329
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002331
2332 mutex_lock(&pHddCtx->sap_lock);
2333 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2334 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002335 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002336 {
2337 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2338
2339 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2340
2341 if (!VOS_IS_STATUS_SUCCESS(status))
2342 {
2343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2344 ("ERROR: HDD vos wait for single_event failed!!\n"));
2345 VOS_ASSERT(0);
2346 }
2347 }
2348 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2349 }
2350 mutex_unlock(&pHddCtx->sap_lock);
2351
2352 if(status != VOS_STATUS_SUCCESS)
2353 {
2354 hddLog(VOS_TRACE_LEVEL_FATAL,
2355 "%s:Error!!! Stopping the BSS\n",__func__);
2356 return -EINVAL;
2357 }
2358
Jeff Johnson4416a782013-03-25 14:17:50 -07002359 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2361 ==eHAL_STATUS_FAILURE)
2362 {
2363 hddLog(LOGE,
2364 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2365 }
2366
Jeff Johnson4416a782013-03-25 14:17:50 -07002367 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2369 eANI_BOOLEAN_FALSE) )
2370 {
2371 hddLog(LOGE,
2372 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2373 }
2374
2375 // Reset WNI_CFG_PROBE_RSP Flags
2376 wlan_hdd_reset_prob_rspies(pAdapter);
2377
2378 pAdapter->sessionCtx.ap.beacon = NULL;
2379 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002380#ifdef WLAN_FEATURE_P2P_DEBUG
2381 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2382 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2383 {
2384 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2385 "GO got removed");
2386 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2387 }
2388#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 }
2390 EXIT();
2391 return status;
2392}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002393
2394#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2395
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302396static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2397 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002398 struct cfg80211_ap_settings *params)
2399{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302400 hdd_adapter_t *pAdapter;
2401 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302402 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002403
2404 ENTER();
2405
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302406 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002407 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302408 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302409 "%s: Device is Null", __func__);
2410 return -ENODEV;
2411 }
2412
2413 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2414 if (NULL == pAdapter)
2415 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302416 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302417 "%s: HDD adapter is Null", __func__);
2418 return -ENODEV;
2419 }
2420
2421 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
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 magic is invalid", __func__);
2425 return -ENODEV;
2426 }
2427
2428 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302429 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302430
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302431 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302432 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302433 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2434 "%s: HDD context is not valid", __func__);
2435 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302436 }
2437
2438 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2439 __func__, pAdapter->device_mode);
2440
2441 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002442 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002443 )
2444 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302445 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002446
2447 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302448
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002449 if (old)
2450 return -EALREADY;
2451
2452 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2453
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302454 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002455 {
2456 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302457 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002458 return -EINVAL;
2459 }
2460 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002461#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002462 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2463#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2464 params->channel, params->channel_type);
2465#else
2466 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2467#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002468#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002469 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2470 params->ssid_len, params->hidden_ssid);
2471 }
2472
2473 EXIT();
2474 return status;
2475}
2476
2477
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302478static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002479 struct net_device *dev,
2480 struct cfg80211_beacon_data *params)
2481{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302482 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302483 hdd_context_t *pHddCtx;
2484 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002485
2486 ENTER();
2487
2488 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2489 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302490
2491 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2492 status = wlan_hdd_validate_context(pHddCtx);
2493
2494 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002495 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302496 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2497 "%s: HDD context is not valid", __func__);
2498 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002499 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002500
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302501 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002502 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302503 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002504 {
2505 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302506
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002507 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302508
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002509 if (!old)
2510 return -ENOENT;
2511
2512 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2513
2514 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302515 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002516 "%s: Error!!! Allocating the new beacon\n",__func__);
2517 return -EINVAL;
2518 }
2519
2520 pAdapter->sessionCtx.ap.beacon = new;
2521
2522 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2523 }
2524
2525 EXIT();
2526 return status;
2527}
2528
2529#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2530
Jeff Johnson295189b2012-06-20 16:38:30 -07002531
2532static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2533 struct net_device *dev,
2534 struct bss_parameters *params)
2535{
2536 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2537
2538 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302539
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2541 __func__,pAdapter->device_mode);
2542
2543 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302545 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 {
2547 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2548 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302549 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 {
2551 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002553 }
2554
2555 EXIT();
2556 return 0;
2557}
2558
2559/*
2560 * FUNCTION: wlan_hdd_cfg80211_change_iface
2561 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2562 */
2563int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2564 struct net_device *ndev,
2565 enum nl80211_iftype type,
2566 u32 *flags,
2567 struct vif_params *params
2568 )
2569{
2570 struct wireless_dev *wdev;
2571 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2572 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002573 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 tCsrRoamProfile *pRoamProfile = NULL;
2575 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302576 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 eMib_dot11DesiredBssType connectedBssType;
2578 VOS_STATUS status;
2579
2580 ENTER();
2581
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302582 status = wlan_hdd_validate_context(pHddCtx);
2583
2584 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302586 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2587 "%s: HDD context is not valid", __func__);
2588 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 }
2590
2591 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2592 __func__, pAdapter->device_mode);
2593
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302594 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 wdev = ndev->ieee80211_ptr;
2596
2597#ifdef WLAN_BTAMP_FEATURE
2598 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2599 (NL80211_IFTYPE_ADHOC == type)||
2600 (NL80211_IFTYPE_AP == type)||
2601 (NL80211_IFTYPE_P2P_GO == type))
2602 {
2603 pHddCtx->isAmpAllowed = VOS_FALSE;
2604 // stop AMP traffic
2605 status = WLANBAP_StopAmp();
2606 if(VOS_STATUS_SUCCESS != status )
2607 {
2608 pHddCtx->isAmpAllowed = VOS_TRUE;
2609 hddLog(VOS_TRACE_LEVEL_FATAL,
2610 "%s: Failed to stop AMP", __func__);
2611 return -EINVAL;
2612 }
2613 }
2614#endif //WLAN_BTAMP_FEATURE
2615 /* Reset the current device mode bit mask*/
2616 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2617
2618 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002620 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 )
2622 {
2623 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2624 pRoamProfile = &pWextState->roamProfile;
2625 LastBSSType = pRoamProfile->BSSType;
2626
2627 switch (type)
2628 {
2629 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 hddLog(VOS_TRACE_LEVEL_INFO,
2632 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2633 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002634#ifdef WLAN_FEATURE_11AC
2635 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2636 {
2637 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2638 }
2639#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302640 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002641 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002643 //Check for sub-string p2p to confirm its a p2p interface
2644 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302645 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002646 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2647 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2648 }
2649 else
2650 {
2651 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002653 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302654#ifdef FEATURE_WLAN_TDLS
2655 /* The open adapter for the p2p shall skip initializations in
2656 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2657 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2658 * tdls_init when the change_iface sets the device mode to
2659 * WLAN_HDD_P2P_CLIENT.
2660 */
2661
2662 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2663 {
2664 if (0 != wlan_hdd_tdls_init (pAdapter))
2665 {
2666 return -EINVAL;
2667 }
2668 }
2669#endif
2670
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 break;
2672 case NL80211_IFTYPE_ADHOC:
2673 hddLog(VOS_TRACE_LEVEL_INFO,
2674 "%s: setting interface Type to ADHOC", __func__);
2675 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2676 pRoamProfile->phyMode =
2677 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002678 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 wdev->iftype = type;
2680 break;
2681
2682 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 {
2685 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2686 "%s: setting interface Type to %s", __func__,
2687 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2688
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002689 //Cancel any remain on channel for GO mode
2690 if (NL80211_IFTYPE_P2P_GO == type)
2691 {
2692 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2693 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002694 if (NL80211_IFTYPE_AP == type)
2695 {
2696 /* As Loading WLAN Driver one interface being created for p2p device
2697 * address. This will take one HW STA and the max number of clients
2698 * that can connect to softAP will be reduced by one. so while changing
2699 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2700 * interface as it is not required in SoftAP mode.
2701 */
2702
2703 // Get P2P Adapter
2704 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2705
2706 if (pP2pAdapter)
2707 {
2708 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2709 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2710 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2711 }
2712 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302713#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07002714
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302715 /* A Mutex Lock is introduced while changing the mode to
2716 * protect the concurrent access for the Adapters by TDLS
2717 * module.
2718 */
2719 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2720 {
2721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2722 "%s: unable to lock list", __func__);
2723 return -EINVAL;
2724 }
2725#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 //De-init the adapter.
2727 hdd_stop_adapter( pHddCtx, pAdapter );
2728 hdd_deinit_adapter( pHddCtx, pAdapter );
2729 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2731 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302732#ifdef FEATURE_WLAN_TDLS
2733 mutex_unlock(&pHddCtx->tdls_lock);
2734#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002735
2736 //Disable BMPS and IMPS if enabled
2737 //before starting Go
2738 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2739 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302740 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002741 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2742 {
2743 //Fail to Exit BMPS
2744 VOS_ASSERT(0);
2745 }
2746 }
2747
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002748 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2749 (pConfig->apRandomBssidEnabled))
2750 {
2751 /* To meet Android requirements create a randomized
2752 MAC address of the form 02:1A:11:Fx:xx:xx */
2753 get_random_bytes(&ndev->dev_addr[3], 3);
2754 ndev->dev_addr[0] = 0x02;
2755 ndev->dev_addr[1] = 0x1A;
2756 ndev->dev_addr[2] = 0x11;
2757 ndev->dev_addr[3] |= 0xF0;
2758 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2759 VOS_MAC_ADDR_SIZE);
2760 pr_info("wlan: Generated HotSpot BSSID "
2761 "%02x:%02x:%02x:%02x:%02x:%02x\n",
2762 ndev->dev_addr[0],
2763 ndev->dev_addr[1],
2764 ndev->dev_addr[2],
2765 ndev->dev_addr[3],
2766 ndev->dev_addr[4],
2767 ndev->dev_addr[5]);
2768 }
2769
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 hdd_set_ap_ops( pAdapter->dev );
2771
2772 status = hdd_init_ap_mode(pAdapter);
2773 if(status != VOS_STATUS_SUCCESS)
2774 {
2775 hddLog(VOS_TRACE_LEVEL_FATAL,
2776 "%s: Error initializing the ap mode", __func__);
2777 return -EINVAL;
2778 }
2779 hdd_set_conparam(1);
2780
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 /*interface type changed update in wiphy structure*/
2782 if(wdev)
2783 {
2784 wdev->iftype = type;
2785 pHddCtx->change_iface = type;
2786 }
2787 else
2788 {
2789 hddLog(VOS_TRACE_LEVEL_ERROR,
2790 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2791 return -EINVAL;
2792 }
2793 goto done;
2794 }
2795
2796 default:
2797 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2798 __func__);
2799 return -EOPNOTSUPP;
2800 }
2801 }
2802 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 )
2805 {
2806 switch(type)
2807 {
2808 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302811#ifdef FEATURE_WLAN_TDLS
2812
2813 /* A Mutex Lock is introduced while changing the mode to
2814 * protect the concurrent access for the Adapters by TDLS
2815 * module.
2816 */
2817 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2818 {
2819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2820 "%s: unable to lock list", __func__);
2821 return -EINVAL;
2822 }
2823#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002824 hdd_stop_adapter( pHddCtx, pAdapter );
2825 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002827 //Check for sub-string p2p to confirm its a p2p interface
2828 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002829 {
2830 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2831 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2832 }
2833 else
2834 {
2835 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 hdd_set_conparam(0);
2839 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2841 hdd_set_station_ops( pAdapter->dev );
2842 status = hdd_init_station_mode( pAdapter );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302843#ifdef FEATURE_WLAN_TDLS
2844 mutex_unlock(&pHddCtx->tdls_lock);
2845#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 if( VOS_STATUS_SUCCESS != status )
2847 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002848 /* In case of JB, for P2P-GO, only change interface will be called,
2849 * This is the right place to enable back bmps_imps()
2850 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302851 if (pHddCtx->hdd_wlan_suspended)
2852 {
2853 hdd_set_pwrparams(pHddCtx);
2854 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002855 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 goto done;
2857 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2861 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 goto done;
2863 default:
2864 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2865 __func__);
2866 return -EOPNOTSUPP;
2867
2868 }
2869
2870 }
2871 else
2872 {
2873 return -EOPNOTSUPP;
2874 }
2875
2876
2877 if(pRoamProfile)
2878 {
2879 if ( LastBSSType != pRoamProfile->BSSType )
2880 {
2881 /*interface type changed update in wiphy structure*/
2882 wdev->iftype = type;
2883
2884 /*the BSS mode changed, We need to issue disconnect
2885 if connected or in IBSS disconnect state*/
2886 if ( hdd_connGetConnectedBssType(
2887 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2888 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2889 {
2890 /*need to issue a disconnect to CSR.*/
2891 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2892 if( eHAL_STATUS_SUCCESS ==
2893 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2894 pAdapter->sessionId,
2895 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2896 {
2897 wait_for_completion_interruptible_timeout(
2898 &pAdapter->disconnect_comp_var,
2899 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2900 }
2901 }
2902 }
2903 }
2904
2905done:
2906 /*set bitmask based on updated value*/
2907 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002908
2909 /* Only STA mode support TM now
2910 * all other mode, TM feature should be disabled */
2911 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2912 (~VOS_STA & pHddCtx->concurrency_mode) )
2913 {
2914 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2915 }
2916
Jeff Johnson295189b2012-06-20 16:38:30 -07002917#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302918 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2920 {
2921 //we are ok to do AMP
2922 pHddCtx->isAmpAllowed = VOS_TRUE;
2923 }
2924#endif //WLAN_BTAMP_FEATURE
2925 EXIT();
2926 return 0;
2927}
2928
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002929#ifdef FEATURE_WLAN_TDLS
2930static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2931 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2932{
2933 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2934 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2935 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002936 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002937
2938 ENTER();
2939
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302940 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002941 {
2942 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2943 "Invalid arguments");
2944 return -EINVAL;
2945 }
Hoonki Lee27511902013-03-14 18:19:06 -07002946
2947 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
2948 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
2949 {
2950 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2951 "%s: TDLS mode is disabled OR not enabled in FW."
2952 MAC_ADDRESS_STR " Request declined.",
2953 __func__, MAC_ADDR_ARRAY(mac));
2954 return -ENOTSUPP;
2955 }
2956
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002957 if (pHddCtx->isLogpInProgress)
2958 {
2959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2960 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07002961 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002962 return -EBUSY;
2963 }
2964
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302965 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002966
2967 if ( NULL == pTdlsPeer ) {
2968 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2969 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
2970 __func__, MAC_ADDR_ARRAY(mac), update);
2971 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002972 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002973
2974 /* in add station, we accept existing valid staId if there is */
2975 if ((0 == update) &&
2976 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
2977 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002978 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002979 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002980 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002981 " link_status %d. staId %d. add station ignored.",
2982 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
2983 return 0;
2984 }
2985 /* in change station, we accept only when staId is valid */
2986 if ((1 == update) &&
2987 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
2988 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
2989 {
2990 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2991 "%s: " MAC_ADDRESS_STR
2992 " link status %d. staId %d. change station %s.",
2993 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
2994 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
2995 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002996 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002997
2998 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302999 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003000 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003001 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3002 "%s: " MAC_ADDRESS_STR
3003 " TDLS setup is ongoing. Request declined.",
3004 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003005 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003006 }
3007
3008 /* first to check if we reached to maximum supported TDLS peer.
3009 TODO: for now, return -EPERM looks working fine,
3010 but need to check if any other errno fit into this category.*/
3011 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
3012 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003013 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3014 "%s: " MAC_ADDRESS_STR
3015 " TDLS Max peer already connected. Request declined.",
3016 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003017 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003018 }
3019 else
3020 {
3021 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303022 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003023 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003024 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003025 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3026 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3027 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003028 return -EPERM;
3029 }
3030 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003031 if (0 == update)
3032 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003033
Jeff Johnsond75fe012013-04-06 10:53:06 -07003034 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303035 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003036 {
3037 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3038 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003039 if(StaParams->htcap_present)
3040 {
3041 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3042 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3043 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3044 "ht_capa->extended_capabilities: %0x",
3045 StaParams->HTCap.extendedHtCapInfo);
3046 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003047 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3048 "params->capability: %0x",StaParams->capability);
3049 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3050 "params->ext_capab_len: %0x",StaParams->extn_capability);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003051 if(StaParams->vhtcap_present)
3052 {
3053 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3054 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3055 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3056 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3057 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003058 {
3059 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003060 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003061 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3062 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3063 "[%d]: %x ", i, StaParams->supported_rates[i]);
3064 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003065 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303066 else if ((1 == update) && (NULL == StaParams))
3067 {
3068 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3069 "%s : update is true, but staParams is NULL. Error!", __func__);
3070 return -EPERM;
3071 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003072
3073 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3074
3075 if (!update)
3076 {
3077 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3078 pAdapter->sessionId, mac);
3079 }
3080 else
3081 {
3082 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3083 pAdapter->sessionId, mac, StaParams);
3084 }
3085
3086 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
3087 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3088
3089 if (!status)
3090 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003092 "%s: timeout waiting for tdls add station indication",
3093 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003094 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003095 }
3096 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
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: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003100 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003101 }
3102
3103 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003104
3105error:
3106 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3107 return -EPERM;
3108
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003109}
3110#endif
3111
Jeff Johnson295189b2012-06-20 16:38:30 -07003112static int wlan_hdd_change_station(struct wiphy *wiphy,
3113 struct net_device *dev,
3114 u8 *mac,
3115 struct station_parameters *params)
3116{
3117 VOS_STATUS status = VOS_STATUS_SUCCESS;
3118 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303119 hdd_context_t *pHddCtx;
3120 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003122#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003123 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003124 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003125#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003126 ENTER();
3127
Gopichand Nakkala29149562013-05-10 21:43:41 +05303128 if ((NULL == pAdapter))
3129 {
3130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3131 "invalid adapter ");
3132 return -EINVAL;
3133 }
3134
3135 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3136 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3137
3138 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3139 {
3140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3141 "invalid HDD state or HDD station context");
3142 return -EINVAL;
3143 }
3144
3145 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003146 {
3147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3148 "%s:LOGP in Progress. Ignore!!!", __func__);
3149 return -EAGAIN;
3150 }
3151
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3153
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003154 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3155 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003157 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303159 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 WLANTL_STA_AUTHENTICATED);
3161
Gopichand Nakkala29149562013-05-10 21:43:41 +05303162 if (status != VOS_STATUS_SUCCESS)
3163 {
3164 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3165 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3166 return -EINVAL;
3167 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 }
3169 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003170 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3171 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303172#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003173 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3174 StaParams.capability = params->capability;
3175 StaParams.uapsd_queues = params->uapsd_queues;
3176 StaParams.max_sp = params->max_sp;
3177
3178 if (0 != params->ext_capab_len)
3179 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3180 sizeof(StaParams.extn_capability));
3181
3182 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003183 {
3184 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003185 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003186 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003187
3188 StaParams.supported_rates_len = params->supported_rates_len;
3189
3190 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3191 * The supported_rates array , for all the structures propogating till Add Sta
3192 * to the firmware has to be modified , if the supplicant (ieee80211) is
3193 * modified to send more rates.
3194 */
3195
3196 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3197 */
3198 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3199 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3200
3201 if (0 != StaParams.supported_rates_len) {
3202 int i = 0;
3203 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3204 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003205 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003206 "Supported Rates with Length %d", StaParams.supported_rates_len);
3207 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003208 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003209 "[%d]: %0x", i, StaParams.supported_rates[i]);
3210 }
3211
3212 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003213 {
3214 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003215 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003216 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003217
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003218 if (0 != params->ext_capab_len ) {
3219 /*Define A Macro : TODO Sunil*/
3220 if ((1<<4) & StaParams.extn_capability[3]) {
3221 isBufSta = 1;
3222 }
3223 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303224 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3225 params->max_sp, isBufSta);
3226 if (VOS_STATUS_SUCCESS != status) {
3227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3228 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3229 return -EINVAL;
3230 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003231 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3232
3233 if (VOS_STATUS_SUCCESS != status) {
3234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3235 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3236 return -EINVAL;
3237 }
3238 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003239#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303240 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003241 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 return status;
3243}
3244
3245/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 * FUNCTION: wlan_hdd_cfg80211_add_key
3247 * This function is used to initialize the key information
3248 */
3249#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003250static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 struct net_device *ndev,
3252 u8 key_index, bool pairwise,
3253 const u8 *mac_addr,
3254 struct key_params *params
3255 )
3256#else
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, const u8 *mac_addr,
3260 struct key_params *params
3261 )
3262#endif
3263{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003264 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 tCsrRoamSetKey setKey;
3266 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303267 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003268 v_U32_t roamId= 0xFF;
3269 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 hdd_hostapd_state_t *pHostapdState;
3271 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003272 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303273 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003274
3275 ENTER();
3276
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303277 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3278 status = wlan_hdd_validate_context(pHddCtx);
3279
3280 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003281 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303282 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3283 "%s: HDD context is not valid", __func__);
3284 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003285 }
3286
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003287 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3288 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003289
3290 if (CSR_MAX_NUM_KEY <= key_index)
3291 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003292 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 key_index);
3294
3295 return -EINVAL;
3296 }
3297
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003298 if (CSR_MAX_KEY_LEN < params->key_len)
3299 {
3300 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3301 params->key_len);
3302
3303 return -EINVAL;
3304 }
3305
3306 hddLog(VOS_TRACE_LEVEL_INFO,
3307 "%s: called with key index = %d & key length %d",
3308 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003309
3310 /*extract key idx, key len and key*/
3311 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3312 setKey.keyId = key_index;
3313 setKey.keyLength = params->key_len;
3314 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3315
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003316 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 {
3318 case WLAN_CIPHER_SUITE_WEP40:
3319 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3320 break;
3321
3322 case WLAN_CIPHER_SUITE_WEP104:
3323 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3324 break;
3325
3326 case WLAN_CIPHER_SUITE_TKIP:
3327 {
3328 u8 *pKey = &setKey.Key[0];
3329 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3330
3331 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3332
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003333 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003334
3335 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003336 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 |--------------|----------|----------|
3338 <---16bytes---><--8bytes--><--8bytes-->
3339
3340 */
3341 /*Sme expects the 32 bytes key to be in the below order
3342
3343 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003344 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 |--------------|----------|----------|
3346 <---16bytes---><--8bytes--><--8bytes-->
3347 */
3348 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003349 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003350
3351 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003352 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003353
3354 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003355 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003356
3357
3358 break;
3359 }
3360
3361 case WLAN_CIPHER_SUITE_CCMP:
3362 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3363 break;
3364
3365#ifdef FEATURE_WLAN_WAPI
3366 case WLAN_CIPHER_SUITE_SMS4:
3367 {
3368 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3369 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3370 params->key, params->key_len);
3371 return 0;
3372 }
3373#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003374
Jeff Johnson295189b2012-06-20 16:38:30 -07003375#ifdef FEATURE_WLAN_CCX
3376 case WLAN_CIPHER_SUITE_KRK:
3377 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3378 break;
3379#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003380
3381#ifdef WLAN_FEATURE_11W
3382 case WLAN_CIPHER_SUITE_AES_CMAC:
3383 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003384 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003385#endif
3386
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 default:
3388 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu",
3389 __func__, params->cipher);
3390 return -EOPNOTSUPP;
3391 }
3392
3393 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3394 __func__, setKey.encType);
3395
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003396 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003397#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3398 (!pairwise)
3399#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003400 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003401#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003402 )
3403 {
3404 /* set group key*/
3405 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3406 "%s- %d: setting Broadcast key",
3407 __func__, __LINE__);
3408 setKey.keyDirection = eSIR_RX_ONLY;
3409 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3410 }
3411 else
3412 {
3413 /* set pairwise key*/
3414 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3415 "%s- %d: setting pairwise key",
3416 __func__, __LINE__);
3417 setKey.keyDirection = eSIR_TX_RX;
3418 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3419 }
3420 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3421 {
3422 setKey.keyDirection = eSIR_TX_RX;
3423 /*Set the group key*/
3424 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3425 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003426
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003427 if ( 0 != status )
3428 {
3429 hddLog(VOS_TRACE_LEVEL_ERROR,
3430 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3431 return -EINVAL;
3432 }
3433 /*Save the keys here and call sme_RoamSetKey for setting
3434 the PTK after peer joins the IBSS network*/
3435 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3436 &setKey, sizeof(tCsrRoamSetKey));
3437 return status;
3438 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303439 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3440 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3441 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003443 if( pHostapdState->bssState == BSS_START )
3444 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3446
3447 if ( status != eHAL_STATUS_SUCCESS )
3448 {
3449 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3450 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3451 __LINE__, status );
3452 }
3453 }
3454
3455 /* Saving WEP keys */
3456 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3457 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3458 {
3459 //Save the wep key in ap context. Issue setkey after the BSS is started.
3460 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3461 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3462 }
3463 else
3464 {
3465 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003466 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3468 }
3469 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003470 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3471 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 {
3473 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3474 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3475
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303476#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3477 if (!pairwise)
3478#else
3479 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3480#endif
3481 {
3482 /* set group key*/
3483 if (pHddStaCtx->roam_info.deferKeyComplete)
3484 {
3485 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3486 "%s- %d: Perform Set key Complete",
3487 __func__, __LINE__);
3488 hdd_PerformRoamSetKeyComplete(pAdapter);
3489 }
3490 }
3491
Jeff Johnson295189b2012-06-20 16:38:30 -07003492 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3493
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003494 pWextState->roamProfile.Keys.defaultIndex = key_index;
3495
3496
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003497 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 params->key, params->key_len);
3499
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303500
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3502
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303503 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303505 __func__, setKey.peerMac[0], setKey.peerMac[1],
3506 setKey.peerMac[2], setKey.peerMac[3],
3507 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 setKey.keyDirection);
3509
3510 vos_status = wlan_hdd_check_ula_done(pAdapter);
3511
3512 if ( vos_status != VOS_STATUS_SUCCESS )
3513 {
3514 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3515 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3516 __LINE__, vos_status );
3517
3518 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3519
3520 return -EINVAL;
3521
3522 }
3523
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003524#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303525 /* The supplicant may attempt to set the PTK once pre-authentication
3526 is done. Save the key in the UMAC and include it in the ADD BSS
3527 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003528 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303529 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003530 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303531 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3532 "%s: Update PreAuth Key success", __func__);
3533 return 0;
3534 }
3535 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3536 {
3537 hddLog(VOS_TRACE_LEVEL_ERROR,
3538 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303539 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003540 }
3541#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003542
3543 /* issue set key request to SME*/
3544 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3545 pAdapter->sessionId, &setKey, &roamId );
3546
3547 if ( 0 != status )
3548 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303549 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3551 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3552 return -EINVAL;
3553 }
3554
3555
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303556 /* in case of IBSS as there was no information available about WEP keys during
3557 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303559 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3560 !( ( IW_AUTH_KEY_MGMT_802_1X
3561 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3563 )
3564 &&
3565 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3566 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3567 )
3568 )
3569 {
3570 setKey.keyDirection = eSIR_RX_ONLY;
3571 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3572
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303573 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303575 __func__, setKey.peerMac[0], setKey.peerMac[1],
3576 setKey.peerMac[2], setKey.peerMac[3],
3577 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 setKey.keyDirection);
3579
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303580 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 pAdapter->sessionId, &setKey, &roamId );
3582
3583 if ( 0 != status )
3584 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303585 hddLog(VOS_TRACE_LEVEL_ERROR,
3586 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 __func__, status);
3588 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3589 return -EINVAL;
3590 }
3591 }
3592 }
3593
3594 return 0;
3595}
3596
3597/*
3598 * FUNCTION: wlan_hdd_cfg80211_get_key
3599 * This function is used to get the key information
3600 */
3601#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303602static int wlan_hdd_cfg80211_get_key(
3603 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303605 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003606 const u8 *mac_addr, void *cookie,
3607 void (*callback)(void *cookie, struct key_params*)
3608 )
3609#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303610static int wlan_hdd_cfg80211_get_key(
3611 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 struct net_device *ndev,
3613 u8 key_index, const u8 *mac_addr, void *cookie,
3614 void (*callback)(void *cookie, struct key_params*)
3615 )
3616#endif
3617{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303618 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3620 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3621 struct key_params params;
3622
3623 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303624
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3626 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303627
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 memset(&params, 0, sizeof(params));
3629
3630 if (CSR_MAX_NUM_KEY <= key_index)
3631 {
3632 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303633 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003634
3635 switch(pRoamProfile->EncryptionType.encryptionType[0])
3636 {
3637 case eCSR_ENCRYPT_TYPE_NONE:
3638 params.cipher = IW_AUTH_CIPHER_NONE;
3639 break;
3640
3641 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3642 case eCSR_ENCRYPT_TYPE_WEP40:
3643 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3644 break;
3645
3646 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3647 case eCSR_ENCRYPT_TYPE_WEP104:
3648 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3649 break;
3650
3651 case eCSR_ENCRYPT_TYPE_TKIP:
3652 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3653 break;
3654
3655 case eCSR_ENCRYPT_TYPE_AES:
3656 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3657 break;
3658
3659 default:
3660 params.cipher = IW_AUTH_CIPHER_NONE;
3661 break;
3662 }
3663
3664 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3665 params.seq_len = 0;
3666 params.seq = NULL;
3667 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3668 callback(cookie, &params);
3669 return 0;
3670}
3671
3672/*
3673 * FUNCTION: wlan_hdd_cfg80211_del_key
3674 * This function is used to delete the key information
3675 */
3676#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303677static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303679 u8 key_index,
3680 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 const u8 *mac_addr
3682 )
3683#else
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,
3686 u8 key_index,
3687 const u8 *mac_addr
3688 )
3689#endif
3690{
3691 int status = 0;
3692
3693 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303694 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 //it is observed that this is invalidating peer
3696 //key index whenever re-key is done. This is affecting data link.
3697 //It should be ok to ignore del_key.
3698#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303699 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3700 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3702 tCsrRoamSetKey setKey;
3703 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303704
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 ENTER();
3706
3707 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3708 __func__,pAdapter->device_mode);
3709
3710 if (CSR_MAX_NUM_KEY <= key_index)
3711 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303712 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 key_index);
3714
3715 return -EINVAL;
3716 }
3717
3718 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3719 setKey.keyId = key_index;
3720
3721 if (mac_addr)
3722 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3723 else
3724 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3725
3726 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3727
3728 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303730 )
3731 {
3732
3733 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3735 if( pHostapdState->bssState == BSS_START)
3736 {
3737 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303738
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 if ( status != eHAL_STATUS_SUCCESS )
3740 {
3741 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3742 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3743 __LINE__, status );
3744 }
3745 }
3746 }
3747 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303748 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 )
3750 {
3751 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3752
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303753 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3754
3755 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303757 __func__, setKey.peerMac[0], setKey.peerMac[1],
3758 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303760 if(pAdapter->sessionCtx.station.conn_info.connState ==
3761 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303763 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303765
Jeff Johnson295189b2012-06-20 16:38:30 -07003766 if ( 0 != status )
3767 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303768 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 "%s: sme_RoamSetKey failure, returned %d",
3770 __func__, status);
3771 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3772 return -EINVAL;
3773 }
3774 }
3775 }
3776#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003777 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 return status;
3779}
3780
3781/*
3782 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3783 * This function is used to set the default tx key index
3784 */
3785#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3786static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3787 struct net_device *ndev,
3788 u8 key_index,
3789 bool unicast, bool multicast)
3790#else
3791static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3792 struct net_device *ndev,
3793 u8 key_index)
3794#endif
3795{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303796 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303797 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303798 hdd_wext_state_t *pWextState;
3799 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303800 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003801
3802 ENTER();
3803
Gopichand Nakkala29149562013-05-10 21:43:41 +05303804 if ((NULL == pAdapter))
3805 {
3806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3807 "invalid adapter");
3808 return -EINVAL;
3809 }
3810
3811 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3812 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3813
3814 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3815 {
3816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3817 "invalid Wext state or HDD context");
3818 return -EINVAL;
3819 }
3820
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3822 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303823
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 if (CSR_MAX_NUM_KEY <= key_index)
3825 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303826 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 key_index);
3828
3829 return -EINVAL;
3830 }
3831
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303832 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3833 status = wlan_hdd_validate_context(pHddCtx);
3834
3835 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003836 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303837 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3838 "%s: HDD context is not valid", __func__);
3839 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003840 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303841
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303844 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303846 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303848 (eCSR_ENCRYPT_TYPE_AES !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003849 pWextState->roamProfile.EncryptionType.encryptionType[0])
3850 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303851 {
3852 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303854
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 tCsrRoamSetKey setKey;
3856 v_U32_t roamId= 0xFF;
3857 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303858
3859 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303861
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 Keys->defaultIndex = (u8)key_index;
3863 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3864 setKey.keyId = key_index;
3865 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303866
3867 vos_mem_copy(&setKey.Key[0],
3868 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303870
Gopichand Nakkala29149562013-05-10 21:43:41 +05303871 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303872
3873 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 &pHddStaCtx->conn_info.bssId[0],
3875 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303876
Gopichand Nakkala29149562013-05-10 21:43:41 +05303877 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3878 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3879 eCSR_ENCRYPT_TYPE_WEP104)
3880 {
3881 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3882 even though ap is configured for WEP-40 encryption. In this canse the key length
3883 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3884 type(104) and switching encryption type to 40*/
3885 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3886 eCSR_ENCRYPT_TYPE_WEP40;
3887 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3888 eCSR_ENCRYPT_TYPE_WEP40;
3889 }
3890
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303891 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303893
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303895 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303897
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 if ( 0 != status )
3899 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303900 hddLog(VOS_TRACE_LEVEL_ERROR,
3901 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 status);
3903 return -EINVAL;
3904 }
3905 }
3906 }
3907
3908 /* In SoftAp mode setting key direction for default mode */
3909 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3910 {
3911 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3912 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3913 (eCSR_ENCRYPT_TYPE_AES !=
3914 pWextState->roamProfile.EncryptionType.encryptionType[0])
3915 )
3916 {
3917 /* Saving key direction for default key index to TX default */
3918 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3919 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3920 }
3921 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303922
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 return status;
3924}
3925
Jeff Johnson295189b2012-06-20 16:38:30 -07003926/*
3927 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3928 * This function is used to inform the BSS details to nl80211 interface.
3929 */
3930static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3931 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3932{
3933 struct net_device *dev = pAdapter->dev;
3934 struct wireless_dev *wdev = dev->ieee80211_ptr;
3935 struct wiphy *wiphy = wdev->wiphy;
3936 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3937 int chan_no;
3938 int ie_length;
3939 const char *ie;
3940 unsigned int freq;
3941 struct ieee80211_channel *chan;
3942 int rssi = 0;
3943 struct cfg80211_bss *bss = NULL;
3944
3945 ENTER();
3946
3947 if( NULL == pBssDesc )
3948 {
3949 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
3950 return bss;
3951 }
3952
3953 chan_no = pBssDesc->channelId;
3954 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
3955 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
3956
3957 if( NULL == ie )
3958 {
3959 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
3960 return bss;
3961 }
3962
3963#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
3964 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
3965 {
3966 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
3967 }
3968 else
3969 {
3970 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
3971 }
3972#else
3973 freq = ieee80211_channel_to_frequency(chan_no);
3974#endif
3975
3976 chan = __ieee80211_get_channel(wiphy, freq);
3977
3978 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
3979 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
3980 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
3981 if (bss == NULL)
3982 {
3983 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
3984
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303985 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
3986 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 pBssDesc->capabilityInfo,
3988 pBssDesc->beaconInterval, ie, ie_length,
3989 rssi, GFP_KERNEL ));
3990}
3991 else
3992 {
3993 return bss;
3994 }
3995}
3996
3997
3998
3999/*
4000 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4001 * This function is used to inform the BSS details to nl80211 interface.
4002 */
4003struct cfg80211_bss*
4004wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4005 tSirBssDescription *bss_desc
4006 )
4007{
4008 /*
4009 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4010 already exists in bss data base of cfg80211 for that particular BSS ID.
4011 Using cfg80211_inform_bss_frame to update the bss entry instead of
4012 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4013 now there is no possibility to get the mgmt(probe response) frame from PE,
4014 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4015 cfg80211_inform_bss_frame.
4016 */
4017 struct net_device *dev = pAdapter->dev;
4018 struct wireless_dev *wdev = dev->ieee80211_ptr;
4019 struct wiphy *wiphy = wdev->wiphy;
4020 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004021#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4022 qcom_ie_age *qie_age = NULL;
4023 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4024#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004026#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 const char *ie =
4028 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4029 unsigned int freq;
4030 struct ieee80211_channel *chan;
4031 struct ieee80211_mgmt *mgmt =
4032 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
4033 struct cfg80211_bss *bss_status = NULL;
4034 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4035 int rssi = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004036#ifdef WLAN_OPEN_SOURCE
4037 struct timespec ts;
4038#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004039
4040 ENTER();
4041
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004042 if (!mgmt)
4043 return NULL;
4044
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004046
4047#ifdef WLAN_OPEN_SOURCE
4048 /* Android does not want the timestamp from the frame.
4049 Instead it wants a monotonic increasing value */
4050 get_monotonic_boottime(&ts);
4051 mgmt->u.probe_resp.timestamp =
4052 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4053#else
4054 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4056 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004057
4058#endif
4059
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4061 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004062
4063#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4064 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4065 /* Assuming this is the last IE, copy at the end */
4066 ie_length -=sizeof(qcom_ie_age);
4067 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4068 qie_age->element_id = QCOM_VENDOR_IE_ID;
4069 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4070 qie_age->oui_1 = QCOM_OUI1;
4071 qie_age->oui_2 = QCOM_OUI2;
4072 qie_age->oui_3 = QCOM_OUI3;
4073 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4074 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4075#endif
4076
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304078 if (bss_desc->fProbeRsp)
4079 {
4080 mgmt->frame_control |=
4081 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4082 }
4083 else
4084 {
4085 mgmt->frame_control |=
4086 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004088
4089#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304090 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4092 {
4093 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4094 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304095 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4097
4098 {
4099 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4100 }
4101 else
4102 {
4103 kfree(mgmt);
4104 return NULL;
4105 }
4106#else
4107 freq = ieee80211_channel_to_frequency(chan_no);
4108#endif
4109 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004110 /*when the band is changed on the fly using the GUI, three things are done
4111 * 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)
4112 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4113 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4114 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4115 * and discards the channels correponding to previous band and calls back with zero bss results.
4116 * 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
4117 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4118 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4119 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4120 * So drop the bss and continue to next bss.
4121 */
4122 if(chan == NULL)
4123 {
4124 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004125 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004126 return NULL;
4127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304129 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 * */
4131 if (( eConnectionState_Associated ==
4132 pAdapter->sessionCtx.station.conn_info.connState ) &&
4133 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4134 pAdapter->sessionCtx.station.conn_info.bssId,
4135 WNI_CFG_BSSID_LEN)))
4136 {
4137 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4138 rssi = (pAdapter->rssi * 100);
4139 }
4140 else
4141 {
4142 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4143 }
4144
4145 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4146 frame_len, rssi, GFP_KERNEL);
4147 kfree(mgmt);
4148 return bss_status;
4149}
4150
4151/*
4152 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4153 * This function is used to update the BSS data base of CFG8011
4154 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304155struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 tCsrRoamInfo *pRoamInfo
4157 )
4158{
4159 tCsrRoamConnectedProfile roamProfile;
4160 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4161 struct cfg80211_bss *bss = NULL;
4162
4163 ENTER();
4164
4165 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4166 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4167
4168 if (NULL != roamProfile.pBssDesc)
4169 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304170 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 &roamProfile);
4172
4173 if (NULL == bss)
4174 {
4175 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4176 __func__);
4177 }
4178
4179 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4180 }
4181 else
4182 {
4183 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4184 __func__);
4185 }
4186 return bss;
4187}
4188
4189/*
4190 * FUNCTION: wlan_hdd_cfg80211_update_bss
4191 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304192static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4193 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304195{
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4197 tCsrScanResultInfo *pScanResult;
4198 eHalStatus status = 0;
4199 tScanResultHandle pResult;
4200 struct cfg80211_bss *bss_status = NULL;
4201
4202 ENTER();
4203
4204 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4205 {
4206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
4207 return -EAGAIN;
4208 }
4209
4210 /*
4211 * start getting scan results and populate cgf80211 BSS database
4212 */
4213 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4214
4215 /* no scan results */
4216 if (NULL == pResult)
4217 {
4218 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4219 return status;
4220 }
4221
4222 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4223
4224 while (pScanResult)
4225 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304226 /*
4227 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4228 * entry already exists in bss data base of cfg80211 for that
4229 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4230 * bss entry instead of cfg80211_inform_bss, But this call expects
4231 * mgmt packet as input. As of now there is no possibility to get
4232 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 * ieee80211_mgmt(probe response) and passing to c
4234 * fg80211_inform_bss_frame.
4235 * */
4236
4237 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4238 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304239
Jeff Johnson295189b2012-06-20 16:38:30 -07004240
4241 if (NULL == bss_status)
4242 {
4243 hddLog(VOS_TRACE_LEVEL_INFO,
4244 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4245 }
4246 else
4247 {
Yue Maf49ba872013-08-19 12:04:25 -07004248 cfg80211_put_bss(
4249#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4250 wiphy,
4251#endif
4252 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 }
4254
4255 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4256 }
4257
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304258 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004259
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304260 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004261}
4262
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004263void
4264hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4265{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304266 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004267 "%02X:%02X:%02X:%02X:%02X:%02X\n",
4268 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
4269 macAddr[5]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004270} /****** end hddPrintMacAddr() ******/
4271
4272void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004273hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004274{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304275 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004276 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4277 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4278 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4279 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004280} /****** end hddPrintPmkId() ******/
4281
4282//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4283//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4284
4285//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4286//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4287
4288#define dump_bssid(bssid) \
4289 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004290 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4291 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4292 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004293 }
4294
4295#define dump_pmkid(pMac, pmkid) \
4296 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004297 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4298 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4299 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004300 }
4301
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004302#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004303/*
4304 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4305 * This function is used to notify the supplicant of a new PMKSA candidate.
4306 */
4307int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304308 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004309 int index, bool preauth )
4310{
Jeff Johnsone7245742012-09-05 17:12:55 -07004311#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004312 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004313 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004314
4315 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004316 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004317
4318 if( NULL == pRoamInfo )
4319 {
4320 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4321 return -EINVAL;
4322 }
4323
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004324 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4325 {
4326 dump_bssid(pRoamInfo->bssid);
4327 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004328 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004329 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004330#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304331 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004332}
4333#endif //FEATURE_WLAN_LFR
4334
Jeff Johnson295189b2012-06-20 16:38:30 -07004335/*
4336 * FUNCTION: hdd_cfg80211_scan_done_callback
4337 * scanning callback function, called after finishing scan
4338 *
4339 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304340static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4342{
4343 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304344 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004346 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4347 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 struct cfg80211_scan_request *req = NULL;
4349 int ret = 0;
4350
4351 ENTER();
4352
4353 hddLog(VOS_TRACE_LEVEL_INFO,
4354 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304355 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 __func__, halHandle, pContext, (int) scanId, (int) status);
4357
4358 //Block on scan req completion variable. Can't wait forever though.
4359 ret = wait_for_completion_interruptible_timeout(
4360 &pScanInfo->scan_req_completion_event,
4361 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4362 if (!ret)
4363 {
4364 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004365 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 }
4367
4368 if(pScanInfo->mScanPending != VOS_TRUE)
4369 {
4370 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004371 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004372 }
4373
4374 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304375 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 {
4377 hddLog(VOS_TRACE_LEVEL_INFO,
4378 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304379 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 (int) scanId);
4381 }
4382
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304383 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 pAdapter);
4385
4386 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304387 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004388
4389
4390 /* If any client wait scan result through WEXT
4391 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004392 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 {
4394 /* The other scan request waiting for current scan finish
4395 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004396 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004398 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 }
4400 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004401 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004402 {
4403 struct net_device *dev = pAdapter->dev;
4404 union iwreq_data wrqu;
4405 int we_event;
4406 char *msg;
4407
4408 memset(&wrqu, '\0', sizeof(wrqu));
4409 we_event = SIOCGIWSCAN;
4410 msg = NULL;
4411 wireless_send_event(dev, we_event, &wrqu, msg);
4412 }
4413 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004414 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004415
4416 /* Get the Scan Req */
4417 req = pAdapter->request;
4418
4419 if (!req)
4420 {
4421 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004422 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004423 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004424 }
4425
4426 /*
4427 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304428 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 req->n_ssids = 0;
4430 req->n_channels = 0;
4431 req->ie = 0;
4432
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004434 /* Scan is no longer pending */
4435 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004436
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004437 /*
4438 * cfg80211_scan_done informing NL80211 about completion
4439 * of scanning
4440 */
4441 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004442 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004443
Jeff Johnsone7245742012-09-05 17:12:55 -07004444allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004445 /* release the wake lock at the end of the scan*/
4446 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004447
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004448 /* Acquire wakelock to handle the case where APP's tries to suspend
4449 * immediatly after the driver gets connect request(i.e after scan)
4450 * from supplicant, this result in app's is suspending and not able
4451 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004452 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004453
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004454#ifdef FEATURE_WLAN_TDLS
4455 wlan_hdd_tdls_scan_done_callback(pAdapter);
4456#endif
4457
Jeff Johnson295189b2012-06-20 16:38:30 -07004458 EXIT();
4459 return 0;
4460}
4461
4462/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004463 * FUNCTION: hdd_isScanAllowed
4464 * Go through each adapter and check if scan allowed
4465 *
4466 */
4467v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4468{
4469 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4470 hdd_station_ctx_t *pHddStaCtx = NULL;
4471 hdd_adapter_t *pAdapter = NULL;
4472 VOS_STATUS status = 0;
4473 v_U8_t staId = 0;
4474 v_U8_t *staMac = NULL;
4475
4476 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4477
4478 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4479 {
4480 pAdapter = pAdapterNode->pAdapter;
4481
4482 if( pAdapter )
4483 {
4484 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304485 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004486 __func__, pAdapter->device_mode);
4487 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4488 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4489 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4490 {
4491 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4492 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4493 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4494 {
4495 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4496 hddLog(VOS_TRACE_LEVEL_ERROR,
4497 "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304498 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004499 staMac[0], staMac[1], staMac[2],
4500 staMac[3], staMac[4], staMac[5]);
4501 return VOS_FALSE;
4502 }
4503 }
4504 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4505 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4506 {
4507 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4508 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304509 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004510 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4511 {
4512 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4513
4514 hddLog(VOS_TRACE_LEVEL_ERROR,
4515 "%s: client %02x:%02x:%02x:%02x:%02x:%02x of SoftAP/P2P-GO is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304516 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004517 staMac[0], staMac[1], staMac[2],
4518 staMac[3], staMac[4], staMac[5]);
4519 return VOS_FALSE;
4520 }
4521 }
4522 }
4523 }
4524 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4525 pAdapterNode = pNext;
4526 }
4527 hddLog(VOS_TRACE_LEVEL_INFO,
4528 "%s: Scan allowed", __func__);
4529 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304530}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004531
4532/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 * FUNCTION: wlan_hdd_cfg80211_scan
4534 * this scan respond to scan trigger and update cfg80211 scan database
4535 * later, scan dump command can be used to recieve scan results
4536 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004537int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4538#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4539 struct net_device *dev,
4540#endif
4541 struct cfg80211_scan_request *request)
4542{
4543#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4544 struct net_device *dev = request->wdev->netdev;
4545#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304546 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004547 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4548 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304549 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004550 tCsrScanRequest scanRequest;
4551 tANI_U8 *channelList = NULL, i;
4552 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304553 int status;
4554 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004556
4557 ENTER();
4558
4559 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4560 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004561
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304562 status = wlan_hdd_validate_context(pHddCtx);
4563
4564 if (0 != status)
4565 {
4566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4567 "%s: HDD context is not valid", __func__);
4568 return status;
4569 }
4570
4571 cfg_param = pHddCtx->cfg_ini;
4572 pScanInfo = &pHddCtx->scan_info;
4573
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004574 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004575 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004576 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004577 {
4578 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004579 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4580 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004581 return -EBUSY;
4582 }
4583
Jeff Johnson295189b2012-06-20 16:38:30 -07004584#ifdef WLAN_BTAMP_FEATURE
4585 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004586 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004588 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 "%s: No scanning when AMP is on", __func__);
4590 return -EOPNOTSUPP;
4591 }
4592#endif
4593 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004594 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004596 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 "%s: Not scanning on device_mode = %d",
4598 __func__, pAdapter->device_mode);
4599 return -EOPNOTSUPP;
4600 }
4601
4602 if (TRUE == pScanInfo->mScanPending)
4603 {
4604 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004605 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 }
4607
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304608 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004609 //Channel and action frame is pending
4610 //Otherwise Cancel Remain On Channel and allow Scan
4611 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004612 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004613 {
4614 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__);
4615 return -EBUSY;
4616 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004617#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004618 /* if tdls disagree scan right now, return immediately.
4619 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4620 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4621 */
4622 status = wlan_hdd_tdls_scan_callback (pAdapter,
4623 wiphy,
4624#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4625 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004626#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004627 request);
4628 if(status <= 0)
4629 {
4630 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4631 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004632 }
4633#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004634
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4636 {
4637 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004638 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4642 {
4643 hddLog(VOS_TRACE_LEVEL_WARN,
4644 "%s: MAX TM Level Scan not allowed", __func__);
4645 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304646 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 }
4648 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4649
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004650 /* Check if scan is allowed at this point of time.
4651 */
4652 if (!hdd_isScanAllowed(pHddCtx))
4653 {
4654 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4655 return -EBUSY;
4656 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304657
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4659
4660 if (NULL != request)
4661 {
4662 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304663 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004664
4665 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4666 * Becasue of this, driver is assuming that this is not wildcard scan and so
4667 * is not aging out the scan results.
4668 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004669 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004670 {
4671 request->n_ssids = 0;
4672 }
4673
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004674 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004675 {
4676 tCsrSSIDInfo *SsidInfo;
4677 int j;
4678 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4679 /* Allocate num_ssid tCsrSSIDInfo structure */
4680 SsidInfo = scanRequest.SSIDs.SSIDList =
4681 ( tCsrSSIDInfo *)vos_mem_malloc(
4682 request->n_ssids*sizeof(tCsrSSIDInfo));
4683
4684 if(NULL == scanRequest.SSIDs.SSIDList)
4685 {
4686 hddLog(VOS_TRACE_LEVEL_ERROR,
4687 "memory alloc failed SSIDInfo buffer");
4688 return -ENOMEM;
4689 }
4690
4691 /* copy all the ssid's and their length */
4692 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4693 {
4694 /* get the ssid length */
4695 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4696 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4697 SsidInfo->SSID.length);
4698 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4699 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4700 j, SsidInfo->SSID.ssId);
4701 }
4702 /* set the scan type to active */
4703 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4704 }
4705 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4706 {
4707 /* set the scan type to active */
4708 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4709 }
4710 else
4711 {
4712 /*Set the scan type to default type, in this case it is ACTIVE*/
4713 scanRequest.scanType = pScanInfo->scan_mode;
4714 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304715 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004716 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4717 }
4718 else
4719 {
4720 /* set the scan type to active */
4721 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4722 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4723
4724 /* set min and max channel time to zero */
4725 scanRequest.minChnTime = 0;
4726 scanRequest.maxChnTime = 0;
4727 }
4728
4729 /* set BSSType to default type */
4730 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4731
4732 /*TODO: scan the requested channels only*/
4733
4734 /*Right now scanning all the channels */
4735 if( request )
4736 {
4737 if( request->n_channels )
4738 {
4739 channelList = vos_mem_malloc( request->n_channels );
4740 if( NULL == channelList )
4741 {
4742 status = -ENOMEM;
4743 goto free_mem;
4744 }
4745
4746 for( i = 0 ; i < request->n_channels ; i++ )
4747 channelList[i] = request->channels[i]->hw_value;
4748 }
4749
4750 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4751 scanRequest.ChannelInfo.ChannelList = channelList;
4752
4753 /* set requestType to full scan */
4754 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304755
4756 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004757 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304758 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004759 */
4760
4761 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304762 * and in that case driver shoudnt flush scan results. If
4763 * driver flushes the scan results here and unfortunately if
4764 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004765 * fails which is not desired
4766 */
4767
4768 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4769 {
4770 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4771 pAdapter->sessionId );
4772 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004773
4774 if( request->ie_len )
4775 {
4776 /* save this for future association (join requires this) */
4777 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4778 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4779 pScanInfo->scanAddIE.length = request->ie_len;
4780
4781 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07004782 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4783 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 )
4785 {
4786 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
4787 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
4788 }
4789
4790 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
4791 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
4792
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
4794 request->ie_len);
4795 if (pP2pIe != NULL)
4796 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07004797#ifdef WLAN_FEATURE_P2P_DEBUG
4798 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
4799 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
4800 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4801 {
4802 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
4803 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4804 "Go nego completed to Connection is started");
4805 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4806 "for 8way Handshake");
4807 }
4808 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
4809 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4810 {
4811 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
4812 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4813 "Disconnected state to Connection is started");
4814 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4815 "for 4way Handshake");
4816 }
4817#endif
4818
Jeff Johnsone7245742012-09-05 17:12:55 -07004819 /* no_cck will be set during p2p find to disable 11b rates */
4820 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004822 hddLog(VOS_TRACE_LEVEL_INFO,
4823 "%s: This is a P2P Search", __func__);
4824 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07004825
Jeff Johnsone7245742012-09-05 17:12:55 -07004826 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
4827 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07004828 /* set requestType to P2P Discovery */
4829 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07004830 }
4831
4832 /*
4833 Skip Dfs Channel in case of P2P Search
4834 if it is set in ini file
4835 */
4836 if(cfg_param->skipDfsChnlInP2pSearch)
4837 {
4838 scanRequest.skipDfsChnlInP2pSearch = 1;
4839 }
4840 else
4841 {
4842 scanRequest.skipDfsChnlInP2pSearch = 0;
4843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004844
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 }
4846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 }
4848 }
4849
4850 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
4851
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004852 /* acquire the wakelock to avoid the apps suspend during the scan. To
4853 * address the following issues.
4854 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
4855 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
4856 * for long time, this result in apps running at full power for long time.
4857 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
4858 * be stuck in full power because of resume BMPS
4859 */
4860 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004861
4862 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 pAdapter->sessionId, &scanRequest, &scanId,
4864 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07004865
Jeff Johnson295189b2012-06-20 16:38:30 -07004866 if (eHAL_STATUS_SUCCESS != status)
4867 {
4868 hddLog(VOS_TRACE_LEVEL_ERROR,
4869 "%s: sme_ScanRequest returned error %d", __func__, status);
4870 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07004871 if(eHAL_STATUS_RESOURCES == status)
4872 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07004873 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 -07004874 status = -EBUSY;
4875 } else {
4876 status = -EIO;
4877 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004878 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 goto free_mem;
4880 }
4881
4882 pScanInfo->mScanPending = TRUE;
4883 pAdapter->request = request;
4884 pScanInfo->scanId = scanId;
4885
4886 complete(&pScanInfo->scan_req_completion_event);
4887
4888free_mem:
4889 if( scanRequest.SSIDs.SSIDList )
4890 {
4891 vos_mem_free(scanRequest.SSIDs.SSIDList);
4892 }
4893
4894 if( channelList )
4895 vos_mem_free( channelList );
4896
4897 EXIT();
4898
4899 return status;
4900}
4901
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004902
4903void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
4904{
4905 v_U8_t iniDot11Mode =
4906 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
4907 eHddDot11Mode hddDot11Mode = iniDot11Mode;
4908
4909 switch ( iniDot11Mode )
4910 {
4911 case eHDD_DOT11_MODE_AUTO:
4912 case eHDD_DOT11_MODE_11ac:
4913 case eHDD_DOT11_MODE_11ac_ONLY:
4914#ifdef WLAN_FEATURE_11AC
4915 hddDot11Mode = eHDD_DOT11_MODE_11ac;
4916#else
4917 hddDot11Mode = eHDD_DOT11_MODE_11n;
4918#endif
4919 break;
4920 case eHDD_DOT11_MODE_11n:
4921 case eHDD_DOT11_MODE_11n_ONLY:
4922 hddDot11Mode = eHDD_DOT11_MODE_11n;
4923 break;
4924 default:
4925 hddDot11Mode = iniDot11Mode;
4926 break;
4927 }
4928 /* This call decides required channel bonding mode */
4929 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
4930 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
4931 operationChannel);
4932}
4933
Jeff Johnson295189b2012-06-20 16:38:30 -07004934/*
4935 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304936 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304938int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004939 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07004940{
4941 int status = 0;
4942 hdd_wext_state_t *pWextState;
4943 v_U32_t roamId;
4944 tCsrRoamProfile *pRoamProfile;
4945 eMib_dot11DesiredBssType connectedBssType;
4946 eCsrAuthType RSNAuthType;
4947
4948 ENTER();
4949
4950 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304951
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
4953 {
4954 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
4955 return -EINVAL;
4956 }
4957
4958 pRoamProfile = &pWextState->roamProfile;
4959
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304960 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004962 int ret = 0;
4963 hdd_station_ctx_t *pHddStaCtx;
4964 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4965 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
4966
4967 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
4968 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
4969 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004970 {
4971 /* Issue disconnect to CSR */
4972 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304973 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
4975 pAdapter->sessionId,
4976 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
4977 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004978 ret = wait_for_completion_interruptible_timeout(
4979 &pAdapter->disconnect_comp_var,
4980 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4981 if (0 == ret)
4982 {
4983 VOS_ASSERT(0);
4984 }
4985 }
4986 }
4987 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
4988 {
4989 ret = wait_for_completion_interruptible_timeout(
4990 &pAdapter->disconnect_comp_var,
4991 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4992 if (0 == ret)
4993 {
4994 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 }
4996 }
4997
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304998 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5000 {
5001 /*QoS not enabled in cfg file*/
5002 pRoamProfile->uapsd_mask = 0;
5003 }
5004 else
5005 {
5006 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305007 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5009 }
5010
5011 pRoamProfile->SSIDs.numOfSSIDs = 1;
5012 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5013 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305014 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5016 ssid, ssid_len);
5017
5018 if (bssid)
5019 {
5020 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5021 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5022 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305023 /* Save BSSID in seperate variable as well, as RoamProfile
5024 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 case of join failure we should send valid BSSID to supplicant
5026 */
5027 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5028 WNI_CFG_BSSID_LEN);
5029 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005030 else
5031 {
5032 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005034
5035 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5036 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305037 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 /*set gen ie*/
5039 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5040 /*set auth*/
5041 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005043#ifdef FEATURE_WLAN_WAPI
5044 if (pAdapter->wapi_info.nWapiMode)
5045 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005046 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 switch (pAdapter->wapi_info.wapiAuthMode)
5048 {
5049 case WAPI_AUTH_MODE_PSK:
5050 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005051 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 pAdapter->wapi_info.wapiAuthMode);
5053 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5054 break;
5055 }
5056 case WAPI_AUTH_MODE_CERT:
5057 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005058 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005059 pAdapter->wapi_info.wapiAuthMode);
5060 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5061 break;
5062 }
5063 } // End of switch
5064 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5065 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5066 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005067 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 pRoamProfile->AuthType.numEntries = 1;
5069 pRoamProfile->EncryptionType.numEntries = 1;
5070 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5071 pRoamProfile->mcEncryptionType.numEntries = 1;
5072 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5073 }
5074 }
5075#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305076#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305077 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305078 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5079 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5080 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305081 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5082 sizeof (tSirGtkOffloadParams));
5083 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305084 }
5085#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 pRoamProfile->csrPersona = pAdapter->device_mode;
5087
Jeff Johnson32d95a32012-09-10 13:15:23 -07005088 if( operatingChannel )
5089 {
5090 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5091 pRoamProfile->ChannelInfo.numOfChannels = 1;
5092 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005093 else
5094 {
5095 pRoamProfile->ChannelInfo.ChannelList = NULL;
5096 pRoamProfile->ChannelInfo.numOfChannels = 0;
5097 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005098 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5099 {
5100 hdd_select_cbmode(pAdapter,operatingChannel);
5101 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005102 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5103 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305104 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005105 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005106 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5107 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305108 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5109 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005110 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5111 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305112
5113 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005114 pAdapter->sessionId, pRoamProfile, &roamId);
5115
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305116 if ((eHAL_STATUS_SUCCESS != status) &&
5117 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5118 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305119
5120 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005121 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5122 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5123 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305124 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005125 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305126 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005127
5128 pRoamProfile->ChannelInfo.ChannelList = NULL;
5129 pRoamProfile->ChannelInfo.numOfChannels = 0;
5130
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 }
5132 else
5133 {
5134 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5135 return -EINVAL;
5136 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005137 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005138 return status;
5139}
5140
5141/*
5142 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5143 * This function is used to set the authentication type (OPEN/SHARED).
5144 *
5145 */
5146static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5147 enum nl80211_auth_type auth_type)
5148{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305149 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005150 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5151
5152 ENTER();
5153
5154 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305155 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005156 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005157 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305158 hddLog(VOS_TRACE_LEVEL_INFO,
5159 "%s: set authentication type to AUTOSWITCH", __func__);
5160 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5161 break;
5162
5163 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005164#ifdef WLAN_FEATURE_VOWIFI_11R
5165 case NL80211_AUTHTYPE_FT:
5166#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305167 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005168 "%s: set authentication type to OPEN", __func__);
5169 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5170 break;
5171
5172 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305173 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005174 "%s: set authentication type to SHARED", __func__);
5175 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5176 break;
5177#ifdef FEATURE_WLAN_CCX
5178 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305179 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 "%s: set authentication type to CCKM WPA", __func__);
5181 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5182 break;
5183#endif
5184
5185
5186 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305187 hddLog(VOS_TRACE_LEVEL_ERROR,
5188 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005189 auth_type);
5190 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5191 return -EINVAL;
5192 }
5193
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305194 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005195 pHddStaCtx->conn_info.authType;
5196 return 0;
5197}
5198
5199/*
5200 * FUNCTION: wlan_hdd_set_akm_suite
5201 * This function is used to set the key mgmt type(PSK/8021x).
5202 *
5203 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305204static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 u32 key_mgmt
5206 )
5207{
5208 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5209 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305210
Jeff Johnson295189b2012-06-20 16:38:30 -07005211 /*set key mgmt type*/
5212 switch(key_mgmt)
5213 {
5214 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305215#ifdef WLAN_FEATURE_VOWIFI_11R
5216 case WLAN_AKM_SUITE_FT_PSK:
5217#endif
5218 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 __func__);
5220 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5221 break;
5222
5223 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305224#ifdef WLAN_FEATURE_VOWIFI_11R
5225 case WLAN_AKM_SUITE_FT_8021X:
5226#endif
5227 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005228 __func__);
5229 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5230 break;
5231#ifdef FEATURE_WLAN_CCX
5232#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5233#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5234 case WLAN_AKM_SUITE_CCKM:
5235 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5236 __func__);
5237 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5238 break;
5239#endif
5240
5241 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305242 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 __func__, key_mgmt);
5244 return -EINVAL;
5245
5246 }
5247 return 0;
5248}
5249
5250/*
5251 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305252 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005253 * (NONE/WEP40/WEP104/TKIP/CCMP).
5254 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305255static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5256 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 bool ucast
5258 )
5259{
5260 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305261 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005262 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5263
5264 ENTER();
5265
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305266 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305268 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 __func__, cipher);
5270 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5271 }
5272 else
5273 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305274
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305276 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 {
5278 case IW_AUTH_CIPHER_NONE:
5279 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5280 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305281
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305283 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305285
Jeff Johnson295189b2012-06-20 16:38:30 -07005286 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305287 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305289
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 case WLAN_CIPHER_SUITE_TKIP:
5291 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5292 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305293
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 case WLAN_CIPHER_SUITE_CCMP:
5295 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5296 break;
5297#ifdef FEATURE_WLAN_WAPI
5298 case WLAN_CIPHER_SUITE_SMS4:
5299 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5300 break;
5301#endif
5302
5303#ifdef FEATURE_WLAN_CCX
5304 case WLAN_CIPHER_SUITE_KRK:
5305 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5306 break;
5307#endif
5308 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305309 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005310 __func__, cipher);
5311 return -EOPNOTSUPP;
5312 }
5313 }
5314
5315 if (ucast)
5316 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305317 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005318 __func__, encryptionType);
5319 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5320 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305321 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005322 encryptionType;
5323 }
5324 else
5325 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305326 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 __func__, encryptionType);
5328 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5329 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5330 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5331 }
5332
5333 return 0;
5334}
5335
5336
5337/*
5338 * FUNCTION: wlan_hdd_cfg80211_set_ie
5339 * This function is used to parse WPA/RSN IE's.
5340 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305341int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5342 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005343 size_t ie_len
5344 )
5345{
5346 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5347 u8 *genie = ie;
5348 v_U16_t remLen = ie_len;
5349#ifdef FEATURE_WLAN_WAPI
5350 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5351 u16 *tmp;
5352 v_U16_t akmsuiteCount;
5353 int *akmlist;
5354#endif
5355 ENTER();
5356
5357 /* clear previous assocAddIE */
5358 pWextState->assocAddIE.length = 0;
5359 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5360
5361 while (remLen >= 2)
5362 {
5363 v_U16_t eLen = 0;
5364 v_U8_t elementId;
5365 elementId = *genie++;
5366 eLen = *genie++;
5367 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305368
5369 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305371
5372 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305374 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005375 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 -07005376 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305377 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 "%s: Invalid WPA IE", __func__);
5379 return -EINVAL;
5380 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305381 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 {
5383 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305384 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305386
Jeff Johnson295189b2012-06-20 16:38:30 -07005387 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5388 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005389 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5390 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 VOS_ASSERT(0);
5392 return -ENOMEM;
5393 }
5394 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5395 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5396 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305397
Jeff Johnson295189b2012-06-20 16:38:30 -07005398 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5399 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5400 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5401 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305402 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5403 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005404 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5405 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5406 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5407 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5408 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5409 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305410 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
5411 P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 /*Consider P2P IE, only for P2P Client */
5413 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5414 {
5415 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305416 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305418
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5420 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005421 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5422 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 VOS_ASSERT(0);
5424 return -ENOMEM;
5425 }
5426 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5427 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5428 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305429
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5431 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005433#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305434 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5435 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005436 /*Consider WFD IE, only for P2P Client */
5437 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5438 {
5439 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305440 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005441 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305442
Jeff Johnson295189b2012-06-20 16:38:30 -07005443 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5444 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005445 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5446 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 VOS_ASSERT(0);
5448 return -ENOMEM;
5449 }
5450 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5451 // WPS IE + P2P IE + WFD IE
5452 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5453 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305454
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5456 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5457 }
5458#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005459 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305460 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005461 HS20_OUI_TYPE_SIZE)) )
5462 {
5463 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305464 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005465 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005466
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005467 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5468 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005469 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5470 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005471 VOS_ASSERT(0);
5472 return -ENOMEM;
5473 }
5474 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5475 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005476
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005477 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5478 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5479 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005480
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07005481 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
5482
5483 /* populating as ADDIE in beacon frames */
5484 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5485 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
5486 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
5487 {
5488 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5489 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5490 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5491 {
5492 hddLog(LOGE,
5493 "Coldn't pass "
5494 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
5495 }
5496 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
5497 else
5498 hddLog(LOGE,
5499 "Could not pass on "
5500 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
5501
5502 /* IBSS mode doesn't contain params->proberesp_ies still
5503 beaconIE's need to be populated in probe response frames */
5504 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
5505 {
5506 u16 rem_probe_resp_ie_len = eLen + 2;
5507 u8 probe_rsp_ie_len[3] = {0};
5508 u8 counter = 0;
5509
5510 /* Check Probe Resp Length if it is greater then 255 then
5511 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
5512 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
5513 not able Store More then 255 bytes into One Variable */
5514
5515 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5516 {
5517 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5518 {
5519 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5520 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5521 }
5522 else
5523 {
5524 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5525 rem_probe_resp_ie_len = 0;
5526 }
5527 }
5528
5529 rem_probe_resp_ie_len = 0;
5530
5531 if (probe_rsp_ie_len[0] > 0)
5532 {
5533 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5534 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5535 (tANI_U8*)(genie - 2),
5536 probe_rsp_ie_len[0], NULL,
5537 eANI_BOOLEAN_FALSE)
5538 == eHAL_STATUS_FAILURE)
5539 {
5540 hddLog(LOGE,
5541 "Could not pass"
5542 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
5543 }
5544 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5545 }
5546
5547 if (probe_rsp_ie_len[1] > 0)
5548 {
5549 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5550 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5551 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5552 probe_rsp_ie_len[1], NULL,
5553 eANI_BOOLEAN_FALSE)
5554 == eHAL_STATUS_FAILURE)
5555 {
5556 hddLog(LOGE,
5557 "Could not pass"
5558 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
5559 }
5560 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5561 }
5562
5563 if (probe_rsp_ie_len[2] > 0)
5564 {
5565 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5566 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5567 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5568 probe_rsp_ie_len[2], NULL,
5569 eANI_BOOLEAN_FALSE)
5570 == eHAL_STATUS_FAILURE)
5571 {
5572 hddLog(LOGE,
5573 "Could not pass"
5574 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
5575 }
5576 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5577 }
5578
5579 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5580 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5581 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5582 {
5583 hddLog(LOGE,
5584 "Could not pass"
5585 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
5586 }
5587 }
5588 else
5589 {
5590 // Reset WNI_CFG_PROBE_RSP Flags
5591 wlan_hdd_reset_prob_rspies(pAdapter);
5592
5593 hddLog(VOS_TRACE_LEVEL_INFO,
5594 "%s: No Probe Response IE received in set beacon",
5595 __func__);
5596 }
5597 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 break;
5599 case DOT11F_EID_RSN:
5600 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5601 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5602 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5603 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5604 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5605 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005606 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5607 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305608 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005609 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305610 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005611 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305612
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005613 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5614 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005615 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5616 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005617 VOS_ASSERT(0);
5618 return -ENOMEM;
5619 }
5620 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5621 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305622
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005623 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5624 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5625 break;
5626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005627#ifdef FEATURE_WLAN_WAPI
5628 case WLAN_EID_WAPI:
5629 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
5630 hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n",
5631 pAdapter->wapi_info.nWapiMode);
5632 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305633 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 akmsuiteCount = WPA_GET_LE16(tmp);
5635 tmp = tmp + 1;
5636 akmlist = (int *)(tmp);
5637 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5638 {
5639 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5640 }
5641 else
5642 {
5643 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5644 VOS_ASSERT(0);
5645 return -EINVAL;
5646 }
5647
5648 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5649 {
5650 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005651 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305653 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305655 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005657 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5659 }
5660 break;
5661#endif
5662 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305663 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005665 /* when Unknown IE is received we should break and continue
5666 * to the next IE in the buffer instead we were returning
5667 * so changing this to break */
5668 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 }
5670 genie += eLen;
5671 remLen -= eLen;
5672 }
5673 EXIT();
5674 return 0;
5675}
5676
5677/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305678 * FUNCTION: hdd_isWPAIEPresent
5679 * Parse the received IE to find the WPA IE
5680 *
5681 */
5682static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5683{
5684 v_U8_t eLen = 0;
5685 v_U16_t remLen = ie_len;
5686 v_U8_t elementId = 0;
5687
5688 while (remLen >= 2)
5689 {
5690 elementId = *ie++;
5691 eLen = *ie++;
5692 remLen -= 2;
5693 if (eLen > remLen)
5694 {
5695 hddLog(VOS_TRACE_LEVEL_ERROR,
5696 "%s: IE length is wrong %d", __func__, eLen);
5697 return FALSE;
5698 }
5699 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5700 {
5701 /* OUI - 0x00 0X50 0XF2
5702 WPA Information Element - 0x01
5703 WPA version - 0x01*/
5704 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5705 return TRUE;
5706 }
5707 ie += eLen;
5708 remLen -= eLen;
5709 }
5710 return FALSE;
5711}
5712
5713/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305715 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 * parameters during connect operation.
5717 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305718int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 struct cfg80211_connect_params *req
5720 )
5721{
5722 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305723 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 ENTER();
5725
5726 /*set wpa version*/
5727 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5728
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305729 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305731 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 {
5733 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5734 }
5735 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5736 {
5737 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5738 }
5739 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305740
5741 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 pWextState->wpaVersion);
5743
5744 /*set authentication type*/
5745 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5746
5747 if (0 > status)
5748 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305749 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 "%s: failed to set authentication type ", __func__);
5751 return status;
5752 }
5753
5754 /*set key mgmt type*/
5755 if (req->crypto.n_akm_suites)
5756 {
5757 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5758 if (0 > status)
5759 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305760 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 __func__);
5762 return status;
5763 }
5764 }
5765
5766 /*set pairwise cipher type*/
5767 if (req->crypto.n_ciphers_pairwise)
5768 {
5769 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5770 req->crypto.ciphers_pairwise[0], true);
5771 if (0 > status)
5772 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305773 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 "%s: failed to set unicast cipher type", __func__);
5775 return status;
5776 }
5777 }
5778 else
5779 {
5780 /*Reset previous cipher suite to none*/
5781 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5782 if (0 > status)
5783 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305784 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 "%s: failed to set unicast cipher type", __func__);
5786 return status;
5787 }
5788 }
5789
5790 /*set group cipher type*/
5791 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
5792 false);
5793
5794 if (0 > status)
5795 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305796 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 __func__);
5798 return status;
5799 }
5800
Chet Lanctot186b5732013-03-18 10:26:30 -07005801#ifdef WLAN_FEATURE_11W
5802 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
5803#endif
5804
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
5806 if (req->ie_len)
5807 {
5808 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
5809 if ( 0 > status)
5810 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305811 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 __func__);
5813 return status;
5814 }
5815 }
5816
5817 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305818 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 {
5820 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
5821 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
5822 )
5823 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305824 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5826 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305827 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 __func__);
5829 return -EOPNOTSUPP;
5830 }
5831 else
5832 {
5833 u8 key_len = req->key_len;
5834 u8 key_idx = req->key_idx;
5835
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305836 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 && (CSR_MAX_NUM_KEY > key_idx)
5838 )
5839 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305840 hddLog(VOS_TRACE_LEVEL_INFO,
5841 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 __func__, key_idx, key_len);
5843 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305844 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305846 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 (u8)key_len;
5848 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
5849 }
5850 }
5851 }
5852 }
5853
5854 return status;
5855}
5856
5857/*
5858 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305859 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 * parameters during connect operation.
5861 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305862static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 struct net_device *ndev,
5864 struct cfg80211_connect_params *req
5865 )
5866{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305867 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305868 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
5870 hdd_context_t *pHddCtx = NULL;
5871
5872 ENTER();
5873
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305874 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
5876
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305877 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5878 status = wlan_hdd_validate_context(pHddCtx);
5879
5880 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305882 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5883 "%s: HDD context is not valid", __func__);
5884 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 }
5886
5887#ifdef WLAN_BTAMP_FEATURE
5888 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305889 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305891 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08005893 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07005894 }
5895#endif
5896 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305897 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07005898
5899 if ( 0 > status)
5900 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305901 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07005902 __func__);
5903 return status;
5904 }
5905
5906 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005907 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
5909 (vos_concurrent_sessions_running()))
5910 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305911 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 }
5913
Mohit Khanna765234a2012-09-11 15:08:35 -07005914 if ( req->channel )
5915 {
5916 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
5917 req->ssid_len, req->bssid,
5918 req->channel->hw_value);
5919 }
5920 else
5921 {
5922 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305923 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07005924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005925
5926 if (0 > status)
5927 {
5928 //ReEnable BMPS if disabled
5929 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
5930 (NULL != pHddCtx))
5931 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05305932 if (pHddCtx->hdd_wlan_suspended)
5933 {
5934 hdd_set_pwrparams(pHddCtx);
5935 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 //ReEnable Bmps and Imps back
5937 hdd_enable_bmps_imps(pHddCtx);
5938 }
5939
5940 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
5941 return status;
5942 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305943 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 EXIT();
5945 return status;
5946}
5947
5948
5949/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305950 * FUNCTION: wlan_hdd_disconnect
5951 * This function is used to issue a disconnect request to SME
5952 */
5953int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
5954{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305955 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305956 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305957 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5958
5959 status = wlan_hdd_validate_context(pHddCtx);
5960
5961 if (0 != status)
5962 {
5963 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5964 "%s: HDD context is not valid", __func__);
5965 return status;
5966 }
5967
5968 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305969 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305970 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305971
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305972 /*issue disconnect*/
5973 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5974 pAdapter->sessionId, reason);
5975
5976 if ( 0 != status )
5977 {
5978 hddLog(VOS_TRACE_LEVEL_ERROR,
5979 "%s csrRoamDisconnect failure, returned %d \n",
5980 __func__, (int)status );
5981 return -EINVAL;
5982 }
5983 wait_for_completion_interruptible_timeout(
5984 &pAdapter->disconnect_comp_var,
5985 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5986 /*stop tx queues*/
5987 netif_tx_disable(pAdapter->dev);
5988 netif_carrier_off(pAdapter->dev);
5989 return status;
5990}
5991
5992
5993/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 * FUNCTION: wlan_hdd_cfg80211_disconnect
5995 * This function is used to issue a disconnect request to SME
5996 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305997static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 struct net_device *dev,
5999 u16 reason
6000 )
6001{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306002 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6003 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306005 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006007 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306008#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006009 tANI_U8 staIdx;
6010#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306011
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306013
6014 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 __func__,pAdapter->device_mode);
6016
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306017 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6018 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006019
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306020 status = wlan_hdd_validate_context(pHddCtx);
6021
6022 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306024 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6025 "%s: HDD context is not valid", __func__);
6026 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306028
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 if (NULL != pRoamProfile)
6030 {
6031 /*issue disconnect request to SME, if station is in connected state*/
6032 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
6033 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306034 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306036 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 switch(reason)
6038 {
6039 case WLAN_REASON_MIC_FAILURE:
6040 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6041 break;
6042
6043 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6044 case WLAN_REASON_DISASSOC_AP_BUSY:
6045 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6046 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6047 break;
6048
6049 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6050 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6051 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6052 break;
6053
6054 case WLAN_REASON_DEAUTH_LEAVING:
6055 default:
6056 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6057 break;
6058 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306059 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6060 pScanInfo = &pHddCtx->scan_info;
6061 if (pScanInfo->mScanPending)
6062 {
6063 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
6064 "Aborting Scan");
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306065 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006067
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006068#ifdef FEATURE_WLAN_TDLS
6069 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006070 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006071 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006072 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6073 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006074 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006075 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006076 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006077 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006078 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006079 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006080 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006081 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006082 pAdapter->sessionId,
6083 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006084 }
6085 }
6086#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306087 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6088 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 {
6090 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306091 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 __func__, (int)status );
6093 return -EINVAL;
6094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 }
6096 }
6097 else
6098 {
6099 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6100 }
6101
6102 return status;
6103}
6104
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306105
Jeff Johnson295189b2012-06-20 16:38:30 -07006106/*
6107 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306108 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 * settings in IBSS mode.
6110 */
6111static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306112 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 struct cfg80211_ibss_params *params
6114 )
6115{
6116 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306117 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006118 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6119 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306120
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 ENTER();
6122
6123 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6124
6125 if (params->ie_len && ( NULL != params->ie) )
6126 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006127 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6128 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 {
6130 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6131 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6132 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006133 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006135 tDot11fIEWPA dot11WPAIE;
6136 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006137 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006138
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006139 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6140 params->ie_len, DOT11F_EID_WPA);
6141 if ( NULL != ie )
6142 {
6143 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6144 // Unpack the WPA IE
6145 //Skip past the EID byte and length byte - and four byte WiFi OUI
6146 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6147 &ie[2+4],
6148 ie[1] - 4,
6149 &dot11WPAIE);
6150 /*Extract the multicast cipher, the encType for unicast
6151 cipher for wpa-none is none*/
6152 encryptionType =
6153 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006156
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6158
6159 if (0 > status)
6160 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306161 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 __func__);
6163 return status;
6164 }
6165 }
6166
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306167 pWextState->roamProfile.AuthType.authType[0] =
6168 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006169 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6170
6171 if (params->privacy)
6172 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306173 /* Security enabled IBSS, At this time there is no information available
6174 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306176 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306178 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 *enable privacy bit in beacons */
6180
6181 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6182 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006183 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6184 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6186 pWextState->roamProfile.EncryptionType.numEntries = 1;
6187 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 return status;
6189}
6190
6191/*
6192 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306193 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306195static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 struct net_device *dev,
6197 struct cfg80211_ibss_params *params
6198 )
6199{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306200 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6202 tCsrRoamProfile *pRoamProfile;
6203 int status;
6204 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306205 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006206
6207 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306208
6209 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6211
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306212 status = wlan_hdd_validate_context(pHddCtx);
6213
6214 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006215 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306216 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6217 "%s: HDD context is not valid", __func__);
6218 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 }
6220
6221 if (NULL == pWextState)
6222 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306223 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 __func__);
6225 return -EIO;
6226 }
6227
6228 pRoamProfile = &pWextState->roamProfile;
6229
6230 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6231 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306232 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 "%s Interface type is not set to IBSS \n", __func__);
6234 return -EINVAL;
6235 }
6236
6237 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006238 if (NULL !=
6239#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6240 params->chandef.chan)
6241#else
6242 params->channel)
6243#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 {
6245 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006246 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6247 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6248 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6249 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006250
6251 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306252 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006253 ieee80211_frequency_to_channel(
6254#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6255 params->chandef.chan->center_freq);
6256#else
6257 params->channel->center_freq);
6258#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006259
6260 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6261 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006263 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6264 __func__);
6265 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006267
6268 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006270 if (channelNum == validChan[indx])
6271 {
6272 break;
6273 }
6274 }
6275 if (indx >= numChans)
6276 {
6277 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 __func__, channelNum);
6279 return -EINVAL;
6280 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006281 /* Set the Operational Channel */
6282 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6283 channelNum);
6284 pRoamProfile->ChannelInfo.numOfChannels = 1;
6285 pHddStaCtx->conn_info.operationChannel = channelNum;
6286 pRoamProfile->ChannelInfo.ChannelList =
6287 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006288 }
6289
6290 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306291 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 if (status < 0)
6293 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306294 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 __func__);
6296 return status;
6297 }
6298
6299 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306300 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006301 params->ssid_len, params->bssid,
6302 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006303
6304 if (0 > status)
6305 {
6306 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6307 return status;
6308 }
6309
6310 return 0;
6311}
6312
6313/*
6314 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306315 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306317static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 struct net_device *dev
6319 )
6320{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306321 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6323 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306324 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6325 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006326
6327 ENTER();
6328
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306329 status = wlan_hdd_validate_context(pHddCtx);
6330
6331 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006332 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306333 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6334 "%s: HDD context is not valid", __func__);
6335 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006336 }
6337
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6339 if (NULL == pWextState)
6340 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306341 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 __func__);
6343 return -EIO;
6344 }
6345
6346 pRoamProfile = &pWextState->roamProfile;
6347
6348 /* Issue disconnect only if interface type is set to IBSS */
6349 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6350 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306351 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 __func__);
6353 return -EINVAL;
6354 }
6355
6356 /* Issue Disconnect request */
6357 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6358 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6359 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6360
6361 return 0;
6362}
6363
6364/*
6365 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6366 * This function is used to set the phy parameters
6367 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6368 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306369static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 u32 changed)
6371{
6372 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6373 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306374 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006375
6376 ENTER();
6377
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306378 status = wlan_hdd_validate_context(pHddCtx);
6379
6380 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006381 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306382 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6383 "%s: HDD context is not valid", __func__);
6384 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006385 }
6386
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6388 {
6389 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6390 WNI_CFG_RTS_THRESHOLD_STAMAX :
6391 wiphy->rts_threshold;
6392
6393 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306394 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306396 hddLog(VOS_TRACE_LEVEL_ERROR,
6397 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 __func__, rts_threshold);
6399 return -EINVAL;
6400 }
6401
6402 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6403 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306404 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306406 hddLog(VOS_TRACE_LEVEL_ERROR,
6407 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 __func__, rts_threshold);
6409 return -EIO;
6410 }
6411
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306412 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 rts_threshold);
6414 }
6415
6416 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6417 {
6418 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6419 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6420 wiphy->frag_threshold;
6421
6422 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306423 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306425 hddLog(VOS_TRACE_LEVEL_ERROR,
6426 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006427 frag_threshold);
6428 return -EINVAL;
6429 }
6430
6431 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6432 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306433 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306435 hddLog(VOS_TRACE_LEVEL_ERROR,
6436 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 __func__, frag_threshold);
6438 return -EIO;
6439 }
6440
6441 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6442 frag_threshold);
6443 }
6444
6445 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6446 || (changed & WIPHY_PARAM_RETRY_LONG))
6447 {
6448 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6449 wiphy->retry_short :
6450 wiphy->retry_long;
6451
6452 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6453 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6454 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306455 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 __func__, retry_value);
6457 return -EINVAL;
6458 }
6459
6460 if (changed & WIPHY_PARAM_RETRY_SHORT)
6461 {
6462 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6463 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306464 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306466 hddLog(VOS_TRACE_LEVEL_ERROR,
6467 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006468 __func__, retry_value);
6469 return -EIO;
6470 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306471 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 __func__, retry_value);
6473 }
6474 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6475 {
6476 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6477 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306478 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306480 hddLog(VOS_TRACE_LEVEL_ERROR,
6481 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006482 __func__, retry_value);
6483 return -EIO;
6484 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306485 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 __func__, retry_value);
6487 }
6488 }
6489
6490 return 0;
6491}
6492
6493/*
6494 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6495 * This function is used to set the txpower
6496 */
6497static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006498#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6499 struct wireless_dev *wdev,
6500#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006501#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306502 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006503#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306504 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006505#endif
6506 int dbm)
6507{
6508 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306509 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6511 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306512 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006513
6514 ENTER();
6515
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306516 status = wlan_hdd_validate_context(pHddCtx);
6517
6518 if (0 != status)
6519 {
6520 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6521 "%s: HDD context is not valid", __func__);
6522 return status;
6523 }
6524
6525 hHal = pHddCtx->hHal;
6526
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306527 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6528 dbm, ccmCfgSetCallback,
6529 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006530 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306531 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6533 return -EIO;
6534 }
6535
6536 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6537 dbm);
6538
6539 switch(type)
6540 {
6541 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6542 /* Fall through */
6543 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6544 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6545 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306546 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6547 __func__);
6548 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 }
6550 break;
6551 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306552 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006553 __func__);
6554 return -EOPNOTSUPP;
6555 break;
6556 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306557 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6558 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 return -EIO;
6560 }
6561
6562 return 0;
6563}
6564
6565/*
6566 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6567 * This function is used to read the txpower
6568 */
Yue Maf49ba872013-08-19 12:04:25 -07006569static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6570#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6571 struct wireless_dev *wdev,
6572#endif
6573 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006574{
6575
6576 hdd_adapter_t *pAdapter;
6577 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306578 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006579
Jeff Johnsone7245742012-09-05 17:12:55 -07006580 ENTER();
6581
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306582 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006583
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306584 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006585 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306586 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6587 "%s: HDD context is not valid", __func__);
6588 *dbm = 0;
6589 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006590 }
6591
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6593 if (NULL == pAdapter)
6594 {
6595 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6596 return -ENOENT;
6597 }
6598
6599 wlan_hdd_get_classAstats(pAdapter);
6600 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6601
Jeff Johnsone7245742012-09-05 17:12:55 -07006602 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 return 0;
6604}
6605
6606static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6607 u8* mac, struct station_info *sinfo)
6608{
6609 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6610 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6611 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6612 tANI_U8 rate_flags;
6613
6614 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6615 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006616
6617 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6618 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6619 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6620 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6621 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6622 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6623 tANI_U16 maxRate = 0;
6624 tANI_U16 myRate;
6625 tANI_U16 currentRate = 0;
6626 tANI_U8 maxSpeedMCS = 0;
6627 tANI_U8 maxMCSIdx = 0;
6628 tANI_U8 rateFlag = 1;
6629 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006630 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306631 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006632
Leo Chang6f8870f2013-03-26 18:11:36 -07006633#ifdef WLAN_FEATURE_11AC
6634 tANI_U32 vht_mcs_map;
6635 eDataRate11ACMaxMcs vhtMaxMcs;
6636#endif /* WLAN_FEATURE_11AC */
6637
Jeff Johnsone7245742012-09-05 17:12:55 -07006638 ENTER();
6639
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6641 (0 == ssidlen))
6642 {
6643 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6644 " Invalid ssidlen, %d", __func__, ssidlen);
6645 /*To keep GUI happy*/
6646 return 0;
6647 }
6648
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306649 status = wlan_hdd_validate_context(pHddCtx);
6650
6651 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006652 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306653 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6654 "%s: HDD context is not valid", __func__);
6655 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006656 }
6657
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6659 sinfo->filled |= STATION_INFO_SIGNAL;
6660
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006661 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6663
6664 //convert to the UI units of 100kbps
6665 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6666
6667#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006668 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 -07006669 sinfo->signal,
6670 pCfg->reportMaxLinkSpeed,
6671 myRate,
6672 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006673 (int) pCfg->linkSpeedRssiMid,
6674 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006675 (int) rate_flags,
6676 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006677#endif //LINKSPEED_DEBUG_ENABLED
6678
6679 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6680 {
6681 // we do not want to necessarily report the current speed
6682 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6683 {
6684 // report the max possible speed
6685 rssidx = 0;
6686 }
6687 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6688 {
6689 // report the max possible speed with RSSI scaling
6690 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6691 {
6692 // report the max possible speed
6693 rssidx = 0;
6694 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006695 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006696 {
6697 // report middle speed
6698 rssidx = 1;
6699 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006700 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6701 {
6702 // report middle speed
6703 rssidx = 2;
6704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 else
6706 {
6707 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006708 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 }
6710 }
6711 else
6712 {
6713 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6714 hddLog(VOS_TRACE_LEVEL_ERROR,
6715 "%s: Invalid value for reportMaxLinkSpeed: %u",
6716 __func__, pCfg->reportMaxLinkSpeed);
6717 rssidx = 0;
6718 }
6719
6720 maxRate = 0;
6721
6722 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306723 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6724 OperationalRates, &ORLeng))
6725 {
6726 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6727 /*To keep GUI happy*/
6728 return 0;
6729 }
6730
Jeff Johnson295189b2012-06-20 16:38:30 -07006731 for (i = 0; i < ORLeng; i++)
6732 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006733 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 {
6735 /* Validate Rate Set */
6736 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6737 {
6738 currentRate = supported_data_rate[j].supported_rate[rssidx];
6739 break;
6740 }
6741 }
6742 /* Update MAX rate */
6743 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6744 }
6745
6746 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306747 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
6748 ExtendedRates, &ERLeng))
6749 {
6750 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6751 /*To keep GUI happy*/
6752 return 0;
6753 }
6754
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 for (i = 0; i < ERLeng; i++)
6756 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006757 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006758 {
6759 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
6760 {
6761 currentRate = supported_data_rate[j].supported_rate[rssidx];
6762 break;
6763 }
6764 }
6765 /* Update MAX rate */
6766 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 /* Get MCS Rate Set -- but only if we are connected at MCS
6769 rates or if we are always reporting max speed or if we have
6770 good rssi */
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006771 if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306773 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
6774 MCSRates, &MCSLeng))
6775 {
6776 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6777 /*To keep GUI happy*/
6778 return 0;
6779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07006781#ifdef WLAN_FEATURE_11AC
6782 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306783 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07006784 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006785 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306786 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07006787 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006789 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006791 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07006792 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006793 maxMCSIdx = 7;
6794 }
6795 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
6796 {
6797 maxMCSIdx = 8;
6798 }
6799 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
6800 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306801 //VHT20 is supporting 0~8
6802 if (rate_flags & eHAL_TX_RATE_VHT20)
6803 maxMCSIdx = 8;
6804 else
6805 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07006806 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306807
6808 if (rate_flags & eHAL_TX_RATE_VHT80)
6809 {
6810 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
6811 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
6812 }
6813 else if (rate_flags & eHAL_TX_RATE_VHT40)
6814 {
6815 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
6816 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
6817 }
6818 else if (rate_flags & eHAL_TX_RATE_VHT20)
6819 {
6820 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
6821 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
6822 }
6823
Leo Chang6f8870f2013-03-26 18:11:36 -07006824 maxSpeedMCS = 1;
6825 if (currentRate > maxRate)
6826 {
6827 maxRate = currentRate;
6828 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306829
Leo Chang6f8870f2013-03-26 18:11:36 -07006830 }
6831 else
6832#endif /* WLAN_FEATURE_11AC */
6833 {
6834 if (rate_flags & eHAL_TX_RATE_HT40)
6835 {
6836 rateFlag |= 1;
6837 }
6838 if (rate_flags & eHAL_TX_RATE_SGI)
6839 {
6840 rateFlag |= 2;
6841 }
6842
6843 for (i = 0; i < MCSLeng; i++)
6844 {
6845 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
6846 for (j = 0; j < temp; j++)
6847 {
6848 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
6849 {
6850 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
6851 break;
6852 }
6853 }
6854 if ((j < temp) && (currentRate > maxRate))
6855 {
6856 maxRate = currentRate;
6857 maxSpeedMCS = 1;
6858 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
6859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006860 }
6861 }
6862 }
6863
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306864 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
6865 {
6866 maxRate = myRate;
6867 maxSpeedMCS = 1;
6868 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6869 }
6870
Jeff Johnson295189b2012-06-20 16:38:30 -07006871 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006872 if (((maxRate < myRate) && (0 == rssidx)) ||
6873 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07006874 {
6875 maxRate = myRate;
6876 if (rate_flags & eHAL_TX_RATE_LEGACY)
6877 {
6878 maxSpeedMCS = 0;
6879 }
6880 else
6881 {
6882 maxSpeedMCS = 1;
6883 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6884 }
6885 }
6886
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306887 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 {
6889 sinfo->txrate.legacy = maxRate;
6890#ifdef LINKSPEED_DEBUG_ENABLED
6891 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
6892#endif //LINKSPEED_DEBUG_ENABLED
6893 }
6894 else
6895 {
6896 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07006897#ifdef WLAN_FEATURE_11AC
6898 sinfo->txrate.nss = 1;
6899 if (rate_flags & eHAL_TX_RATE_VHT80)
6900 {
6901 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306902 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07006903 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306904 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07006905 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306906 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6907 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6908 }
6909 else if (rate_flags & eHAL_TX_RATE_VHT20)
6910 {
6911 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6912 }
6913#endif /* WLAN_FEATURE_11AC */
6914 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
6915 {
6916 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
6917 if (rate_flags & eHAL_TX_RATE_HT40)
6918 {
6919 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6920 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 if (rate_flags & eHAL_TX_RATE_SGI)
6923 {
6924 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
6925 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306926
Jeff Johnson295189b2012-06-20 16:38:30 -07006927#ifdef LINKSPEED_DEBUG_ENABLED
6928 pr_info("Reporting MCS rate %d flags %x\n",
6929 sinfo->txrate.mcs,
6930 sinfo->txrate.flags );
6931#endif //LINKSPEED_DEBUG_ENABLED
6932 }
6933 }
6934 else
6935 {
6936 // report current rate instead of max rate
6937
6938 if (rate_flags & eHAL_TX_RATE_LEGACY)
6939 {
6940 //provide to the UI in units of 100kbps
6941 sinfo->txrate.legacy = myRate;
6942#ifdef LINKSPEED_DEBUG_ENABLED
6943 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
6944#endif //LINKSPEED_DEBUG_ENABLED
6945 }
6946 else
6947 {
6948 //must be MCS
6949 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07006950#ifdef WLAN_FEATURE_11AC
6951 sinfo->txrate.nss = 1;
6952 if (rate_flags & eHAL_TX_RATE_VHT80)
6953 {
6954 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6955 }
6956 else
6957#endif /* WLAN_FEATURE_11AC */
6958 {
6959 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
6960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006961 if (rate_flags & eHAL_TX_RATE_SGI)
6962 {
6963 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
6964 }
6965 if (rate_flags & eHAL_TX_RATE_HT40)
6966 {
6967 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6968 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006969#ifdef WLAN_FEATURE_11AC
6970 else if (rate_flags & eHAL_TX_RATE_VHT80)
6971 {
6972 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
6973 }
6974#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07006975#ifdef LINKSPEED_DEBUG_ENABLED
6976 pr_info("Reporting actual MCS rate %d flags %x\n",
6977 sinfo->txrate.mcs,
6978 sinfo->txrate.flags );
6979#endif //LINKSPEED_DEBUG_ENABLED
6980 }
6981 }
6982 sinfo->filled |= STATION_INFO_TX_BITRATE;
6983
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006984 sinfo->tx_packets =
6985 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
6986 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
6987 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
6988 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
6989
6990 sinfo->tx_retries =
6991 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
6992 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
6993 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
6994 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
6995
6996 sinfo->tx_failed =
6997 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
6998 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
6999 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7000 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7001
7002 sinfo->filled |=
7003 STATION_INFO_TX_PACKETS |
7004 STATION_INFO_TX_RETRIES |
7005 STATION_INFO_TX_FAILED;
7006
7007 EXIT();
7008 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007009}
7010
7011static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007012 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007013{
7014 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307015 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307017 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007018
Jeff Johnsone7245742012-09-05 17:12:55 -07007019 ENTER();
7020
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 if (NULL == pAdapter)
7022 {
7023 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7024 return -ENODEV;
7025 }
7026
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307027 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307028 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307029
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307030 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307031 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307032 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7033 "%s: HDD context is not valid", __func__);
7034 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307035 }
7036
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307037 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7038 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7039 (pHddCtx->cfg_ini->fhostArpOffload) &&
7040 (eConnectionState_Associated ==
7041 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7042 {
Amar Singhald53568e2013-09-26 11:03:45 -07007043
7044 hddLog(VOS_TRACE_LEVEL_INFO,
7045 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307046 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307047 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7048 {
7049 hddLog(VOS_TRACE_LEVEL_INFO,
7050 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
7051 __func__, vos_status);
7052 }
7053 }
7054
Jeff Johnson295189b2012-06-20 16:38:30 -07007055 /**The get power cmd from the supplicant gets updated by the nl only
7056 *on successful execution of the function call
7057 *we are oppositely mapped w.r.t mode in the driver
7058 **/
7059 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7060
Jeff Johnsone7245742012-09-05 17:12:55 -07007061 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007062 if (VOS_STATUS_E_FAILURE == vos_status)
7063 {
7064 return -EINVAL;
7065 }
7066 return 0;
7067}
7068
7069
7070#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7071static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7072 struct net_device *netdev,
7073 u8 key_index)
7074{
Jeff Johnsone7245742012-09-05 17:12:55 -07007075 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 return 0;
7077}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307078#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007079
7080#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7081static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7082 struct net_device *dev,
7083 struct ieee80211_txq_params *params)
7084{
Jeff Johnsone7245742012-09-05 17:12:55 -07007085 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007086 return 0;
7087}
7088#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7089static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7090 struct ieee80211_txq_params *params)
7091{
Jeff Johnsone7245742012-09-05 17:12:55 -07007092 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 return 0;
7094}
7095#endif //LINUX_VERSION_CODE
7096
7097static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7098 struct net_device *dev, u8 *mac)
7099{
7100 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307101 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007102 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307103 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007104 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007105
Jeff Johnsone7245742012-09-05 17:12:55 -07007106 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307107 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007108 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307109 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007110 return -EINVAL;
7111 }
7112
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307113 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7114 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007115
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307116 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007117 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307118 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7119 "%s: HDD context is not valid", __func__);
7120 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007121 }
7122
Jeff Johnson295189b2012-06-20 16:38:30 -07007123 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007125 )
7126 {
7127 if( NULL == mac )
7128 {
7129 v_U16_t i;
7130 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7131 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007132 if ((pAdapter->aStaInfo[i].isUsed) &&
7133 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 {
7135 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7136 hddLog(VOS_TRACE_LEVEL_INFO,
7137 "%s: Delete STA with MAC::"
7138 "%02x:%02x:%02x:%02x:%02x:%02x",
7139 __func__,
7140 macAddr[0], macAddr[1], macAddr[2],
7141 macAddr[3], macAddr[4], macAddr[5]);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007142 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7143 if (VOS_IS_STATUS_SUCCESS(vos_status))
7144 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007145 }
7146 }
7147 }
7148 else
7149 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007150
7151 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7152 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7153 {
7154 hddLog(VOS_TRACE_LEVEL_INFO,
7155 "%s: Skip this DEL STA as this is not used::"
7156 "%02x:%02x:%02x:%02x:%02x:%02x",
7157 __func__,
7158 mac[0], mac[1], mac[2],
7159 mac[3], mac[4], mac[5]);
7160 return -ENOENT;
7161 }
7162
7163 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7164 {
7165 hddLog(VOS_TRACE_LEVEL_INFO,
7166 "%s: Skip this DEL STA as deauth is in progress::"
7167 "%02x:%02x:%02x:%02x:%02x:%02x",
7168 __func__,
7169 mac[0], mac[1], mac[2],
7170 mac[3], mac[4], mac[5]);
7171 return -ENOENT;
7172 }
7173
7174 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7175
Jeff Johnson295189b2012-06-20 16:38:30 -07007176 hddLog(VOS_TRACE_LEVEL_INFO,
7177 "%s: Delete STA with MAC::"
7178 "%02x:%02x:%02x:%02x:%02x:%02x",
7179 __func__,
7180 mac[0], mac[1], mac[2],
7181 mac[3], mac[4], mac[5]);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007182
7183 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7184 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7185 {
7186 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7187 hddLog(VOS_TRACE_LEVEL_INFO,
7188 "%s: STA removal failed for ::"
7189 "%02x:%02x:%02x:%02x:%02x:%02x",
7190 __func__,
7191 mac[0], mac[1], mac[2],
7192 mac[3], mac[4], mac[5]);
7193 return -ENOENT;
7194 }
7195
Jeff Johnson295189b2012-06-20 16:38:30 -07007196 }
7197 }
7198
7199 EXIT();
7200
7201 return 0;
7202}
7203
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007204static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7205 struct net_device *dev, u8 *mac, struct station_parameters *params)
7206{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007207 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007208#ifdef FEATURE_WLAN_TDLS
7209 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007210 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007211 mask = params->sta_flags_mask;
7212
7213 set = params->sta_flags_set;
7214
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007215#ifdef WLAN_FEATURE_TDLS_DEBUG
7216 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7217 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7218 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7219#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007220
7221 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7222 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007223 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007224 }
7225 }
7226#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007227 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007228}
7229
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007230
7231#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07007232#define MAX_PMKSAIDS_IN_CACHE 8
7233
7234static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
7235static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
7236
7237
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007238static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007239 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007240{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307241 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007242 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7243 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307244 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307245 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007246 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307247 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307248
Jeff Johnsone7245742012-09-05 17:12:55 -07007249 ENTER();
7250
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307251 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307252 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007253 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307254 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007255 return -EINVAL;
7256 }
7257
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307258 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7259 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007260
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307261 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007262 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307263 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7264 "%s: HDD context is not valid", __func__);
7265 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007266 }
7267
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307268 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007269 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7270
Wilson Yang6507c4e2013-10-01 20:11:19 -07007271 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007272 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307273 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007274 pmksa->bssid, WNI_CFG_BSSID_LEN))
7275 {
7276 /* BSSID matched previous entry. Overwrite it. */
7277 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307278 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007279 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307280 vos_mem_copy(PMKIDCache[j].PMKID,
7281 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007282 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307283 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007284 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007285 dump_bssid(pmksa->bssid);
7286 dump_pmkid(halHandle, pmksa->pmkid);
7287 break;
7288 }
7289 }
7290
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007291 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07007292 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007293
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007294 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307295 {
7296 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07007297 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307298 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007299 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307300 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007301 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307302 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007303 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007304 dump_bssid(pmksa->bssid);
7305 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307306 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007307 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07007308 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007309 }
7310
7311
7312 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307313 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007314 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307315 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007316 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007317 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307318 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7319 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007320 PMKIDCacheIndex);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007321 return 0;
7322}
7323
7324
Wilson Yang6507c4e2013-10-01 20:11:19 -07007325
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007326static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007327 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007328{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007329 tANI_U32 j=0;
7330 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7331 tHalHandle halHandle;
7332 int status;
7333 tANI_U8 BSSIDMatched = 0;
7334 tANI_U8 *pBSSId;
7335 hdd_context_t *pHddCtx;
7336 int result = 0;
7337
7338 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA with PMKSA_ID %d .",
7339 __func__,pmksa->pmkid);
7340
7341 /* Validate pAdapter */
7342 if (NULL == pAdapter)
7343 {
7344 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
7345 return -EINVAL;
7346 }
7347
7348 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7349 status = wlan_hdd_validate_context(pHddCtx);
7350
7351 if (0 != status)
7352 {
7353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7354 "%s: HDD context is not valid", __func__);
7355 return status;
7356 }
7357
7358 /*Retrieve halHandle*/
7359 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7360
7361 /*in case index is 0,no entry to delete*/
7362 if (0 == PMKIDCacheIndex)
7363 {
7364 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7365 __func__);
7366 return -EINVAL;
7367 }
7368
7369 /*find the matching PMKSA entry from j=0 to (index-1),
7370 * and delete the matched one
7371 */
7372 for (j = 0; j<PMKIDCacheIndex; j++)
7373 {
7374 if (vos_mem_compare(PMKIDCache[j].BSSID,
7375 pmksa->bssid,
7376 WNI_CFG_BSSID_LEN))
7377 {
7378 /* BSSID matched entry */
7379 BSSIDMatched = 1;
7380
7381 if (j<PMKIDCacheIndex-1)
7382 {
7383 /*replace the matching entry with the last entry in HDD local cache*/
7384 vos_mem_copy(PMKIDCache[j].BSSID,
7385 PMKIDCache[PMKIDCacheIndex-1].BSSID,
7386 WNI_CFG_BSSID_LEN);
7387 vos_mem_copy(PMKIDCache[j].PMKID,
7388 PMKIDCache[PMKIDCacheIndex-1].PMKID,
7389 CSR_RSN_PMKID_SIZE);
7390 }
7391
7392 /*clear the last entry in HDD cache ---[index-1]*/
7393 pBSSId =(tANI_U8 *)(PMKIDCache[PMKIDCacheIndex-1].BSSID);
7394 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
7395 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
7396
7397 /*reduce the PMKID array index*/
7398 PMKIDCacheIndex--;
7399
7400 /*delete the last PMKID cache in CSR*/
7401 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7402 if (0 != result)
7403 {
7404 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
7405 __func__,PMKIDCacheIndex);
7406 }
7407
7408 dump_bssid(pmksa->bssid);
7409 dump_pmkid(halHandle,pmksa->pmkid);
7410
7411 break;
7412 }
7413 }
7414
7415 /* we compare all entries,but cannot find matching entry */
7416 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
7417 {
7418 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: No such PMKSA entry existed %d.",
7419 __func__,pmksa->bssid);
7420 dump_bssid(pmksa->bssid);
7421 dump_pmkid(halHandle, pmksa->pmkid);
7422 return -EINVAL;
7423 }
7424 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007425}
7426
Wilson Yang6507c4e2013-10-01 20:11:19 -07007427
7428
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007429static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7430{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007431 tANI_U32 j=0;
7432 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7433 tHalHandle halHandle;
7434 hdd_context_t *pHddCtx;
7435 tANI_U8 *pBSSId;
7436 int status;
7437 int result;
7438
7439 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
7440
7441 /* Validate pAdapter */
7442 if (NULL == pAdapter)
7443 {
7444 hddLog(VOS_TRACE_LEVEL_ERROR,
7445 "%s: Invalid Adapter" ,__func__);
7446 return -EINVAL;
7447 }
7448
7449 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7450 status = wlan_hdd_validate_context(pHddCtx);
7451
7452 if (0 != status)
7453 {
7454 hddLog(VOS_TRACE_LEVEL_ERROR,
7455 "%s: HDD context is not valid", __func__);
7456 return status;
7457 }
7458
7459 /*Retrieve halHandle*/
7460 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7461
7462 /*in case index is 0,no entry to delete*/
7463 if (0 == PMKIDCacheIndex)
7464 {
7465 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7466 __func__);
7467 return -EINVAL;
7468 }
7469
7470 /*delete all the PMKSA one by one */
7471 for (j = 0; j<PMKIDCacheIndex; j++)
7472 {
7473 /*clear the entry in HDD cache 0--index-1 */
7474 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
7475 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
7476 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
7477
7478 /*delete the PMKID in CSR*/
7479 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7480
7481 if (0!= result)
7482 {
7483 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
7484 __func__,j);
7485 }
7486 }
7487
7488 PMKIDCacheIndex = 0;
7489 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007490}
7491#endif
7492
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007493#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307494static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007495 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7496{
7497 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7498 hdd_station_ctx_t *pHddStaCtx;
7499
7500 if (NULL == pAdapter)
7501 {
7502 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7503 return -ENODEV;
7504 }
7505
7506 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7507
7508 // Added for debug on reception of Re-assoc Req.
7509 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7510 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307511 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007512 ftie->ie_len);
7513 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7514 }
7515
7516#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307517 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007518 ftie->ie_len);
7519#endif
7520
7521 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307522 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7523 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007524 ftie->ie_len);
7525 return 0;
7526}
7527#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007528
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307529#ifdef FEATURE_WLAN_SCAN_PNO
7530
7531void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7532 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7533{
7534 int ret;
7535 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7536 hdd_context_t *pHddCtx;
7537
7538 if (NULL == pAdapter)
7539 {
7540 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7541 "%s: HDD adapter is Null", __func__);
7542 return ;
7543 }
7544
7545 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7546 if (NULL == pHddCtx)
7547 {
7548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7549 "%s: HDD context is Null!!!", __func__);
7550 return ;
7551 }
7552
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307553 spin_lock(&pHddCtx->schedScan_lock);
7554 if (TRUE == pHddCtx->isWiphySuspended)
7555 {
7556 pHddCtx->isSchedScanUpdatePending = TRUE;
7557 spin_unlock(&pHddCtx->schedScan_lock);
7558 hddLog(VOS_TRACE_LEVEL_INFO,
7559 "%s: Update cfg80211 scan database after it resume", __func__);
7560 return ;
7561 }
7562 spin_unlock(&pHddCtx->schedScan_lock);
7563
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307564 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7565
7566 if (0 > ret)
7567 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7568
7569 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7571 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307572}
7573
7574/*
7575 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7576 * NL interface to enable PNO
7577 */
7578static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7579 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7580{
7581 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7582 tpSirPNOScanReq pPnoRequest = NULL;
7583 hdd_context_t *pHddCtx;
7584 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307585 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307586 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7587 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7588 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7589 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307590 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307591
7592 if (NULL == pAdapter)
7593 {
7594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7595 "%s: HDD adapter is Null", __func__);
7596 return -ENODEV;
7597 }
7598
7599 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307600 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307601
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307602 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307603 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7605 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307606 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307607 }
7608
7609 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7610 if (NULL == hHal)
7611 {
7612 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7613 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307614 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307615 }
7616
7617 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7618 if (NULL == pPnoRequest)
7619 {
7620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7621 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307622 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307623 }
7624
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05307625 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307626 pPnoRequest->enable = 1; /*Enable PNO */
7627 pPnoRequest->ucNetworksCount = request->n_match_sets;
7628
7629 if (( !pPnoRequest->ucNetworksCount ) ||
7630 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7631 {
7632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7633 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307634 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307635 goto error;
7636 }
7637
7638 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7639 {
7640 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7641 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307642 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307643 goto error;
7644 }
7645
7646 /* Framework provides one set of channels(all)
7647 * common for all saved profile */
7648 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7649 channels_allowed, &num_channels_allowed))
7650 {
7651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7652 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307653 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307654 goto error;
7655 }
7656 /* Checking each channel against allowed channel list */
7657 num_ch = 0;
7658 for (i = 0; i < request->n_channels; i++)
7659 {
7660 for (indx = 0; indx < num_channels_allowed; indx++)
7661 {
7662 if (request->channels[i]->hw_value == channels_allowed[indx])
7663 {
7664 valid_ch[num_ch++] = request->channels[i]->hw_value;
7665 break ;
7666 }
7667 }
7668 }
7669
7670 /* Filling per profile params */
7671 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7672 {
7673 pPnoRequest->aNetworks[i].ssId.length =
7674 request->match_sets[i].ssid.ssid_len;
7675
7676 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7677 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7678 {
7679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7680 "SSID Len %d is not correct for network %d",
7681 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307682 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307683 goto error;
7684 }
7685
7686 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7687 request->match_sets[i].ssid.ssid,
7688 request->match_sets[i].ssid.ssid_len);
7689 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7690 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7691 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7692
7693 /*Copying list of valid channel into request */
7694 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7695 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7696
7697 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7698 }
7699
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05307700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7701 "request->ie_len = %d", request->ie_len);
7702 if ((0 < request->ie_len) && (NULL != request->ie))
7703 {
7704 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
7705 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
7706 pPnoRequest->us24GProbeTemplateLen);
7707
7708 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
7709 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
7710 pPnoRequest->us5GProbeTemplateLen);
7711 }
7712
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307713 /* Driver gets only one time interval which is hardcoded in
7714 * supplicant for 10000ms. Taking power consumption into account 6 timers
7715 * will be used, Timervalue is increased exponentially i.e 10,20,40,
7716 * 80,160,320 secs. And number of scan cycle for each timer
7717 * is configurable through INI param gPNOScanTimerRepeatValue.
7718 * If it is set to 0 only one timer will be used and PNO scan cycle
7719 * will be repeated after each interval specified by supplicant
7720 * till PNO is disabled.
7721 */
7722 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
7723 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
7724 else
7725 pPnoRequest->scanTimers.ucScanTimersCount =
7726 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
7727
7728 tempInterval = (request->interval)/1000;
7729 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7730 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
7731 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
7732 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
7733 {
7734 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
7735 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
7736 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
7737 tempInterval *= 2;
7738 }
7739 //Repeat last timer until pno disabled.
7740 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
7741
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05307742 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307743
7744 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7745 pPnoRequest, pAdapter->sessionId,
7746 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7747 if (eHAL_STATUS_SUCCESS != status)
7748 {
7749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7750 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307751 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307752 goto error;
7753 }
7754
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7756 "PNO scanRequest offloaded");
7757
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307758error:
7759 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307760 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307761}
7762
7763/*
7764 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
7765 * NL interface to disable PNO
7766 */
7767static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
7768 struct net_device *dev)
7769{
7770 eHalStatus status = eHAL_STATUS_FAILURE;
7771 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7772 hdd_context_t *pHddCtx;
7773 tHalHandle hHal;
7774 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307775 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307776
7777 ENTER();
7778
7779 if (NULL == pAdapter)
7780 {
7781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7782 "%s: HDD adapter is Null", __func__);
7783 return -ENODEV;
7784 }
7785
7786 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307787
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307788 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307789 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307790 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307791 "%s: HDD context is Null", __func__);
7792 return -ENODEV;
7793 }
7794
7795 /* The return 0 is intentional when isLogpInProgress and
7796 * isLoadUnloadInProgress. We did observe a crash due to a return of
7797 * failure in sched_scan_stop , especially for a case where the unload
7798 * of the happens at the same time. The function __cfg80211_stop_sched_scan
7799 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
7800 * success. If it returns a failure , then its next invocation due to the
7801 * clean up of the second interface will have the dev pointer corresponding
7802 * to the first one leading to a crash.
7803 */
7804 if (pHddCtx->isLogpInProgress)
7805 {
7806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7807 "%s: LOGP in Progress. Ignore!!!", __func__);
7808 return ret;
7809 }
7810
7811 if (pHddCtx->isLoadUnloadInProgress)
7812 {
7813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7814 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
7815 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307816 }
7817
7818 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7819 if (NULL == hHal)
7820 {
7821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7822 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307823 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307824 }
7825
7826 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7827 if (NULL == pPnoRequest)
7828 {
7829 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7830 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307831 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307832 }
7833
7834 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
7835 pPnoRequest->enable = 0; /* Disable PNO */
7836 pPnoRequest->ucNetworksCount = 0;
7837
7838 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
7839 pAdapter->sessionId,
7840 NULL, pAdapter);
7841 if (eHAL_STATUS_SUCCESS != status)
7842 {
7843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7844 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307845 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307846 }
7847
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307848 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7849 "%s: PNO scan disabled", __func__);
7850
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307851 vos_mem_free(pPnoRequest);
7852
7853 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307854 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307855}
7856
7857#endif /*FEATURE_WLAN_SCAN_PNO*/
7858
7859
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007860#ifdef FEATURE_WLAN_TDLS
7861static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
7862 u8 *peer, u8 action_code, u8 dialog_token,
7863 u16 status_code, const u8 *buf, size_t len)
7864{
7865
7866 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7867 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007868 u8 peerMac[6];
7869 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007870 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08007871 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007872 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007873
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007874 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007875 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307876 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007877 "Invalid arguments");
7878 return -EINVAL;
7879 }
7880
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007881 if (pHddCtx->isLogpInProgress)
7882 {
7883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7884 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007885 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007886 return -EBUSY;
7887 }
7888
Hoonki Lee27511902013-03-14 18:19:06 -07007889 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007890 {
Hoonki Lee27511902013-03-14 18:19:06 -07007891 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7892 "%s: TDLS mode is disabled OR not enabled in FW."
7893 MAC_ADDRESS_STR " action %d declined.",
7894 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007895 return -ENOTSUPP;
7896 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08007897
Hoonki Lee27511902013-03-14 18:19:06 -07007898 /* other than teardown frame, other mgmt frames are not sent if disabled */
7899 if (SIR_MAC_TDLS_TEARDOWN != action_code)
7900 {
7901 /* if tdls_mode is disabled to respond to peer's request */
7902 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
7903 {
7904 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7905 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007906 " TDLS mode is disabled. action %d declined.",
7907 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07007908
7909 return -ENOTSUPP;
7910 }
7911 }
7912
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007913 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
7914 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307915 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007916 {
7917 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007918 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007919 " TDLS setup is ongoing. action %d declined.",
7920 __func__, MAC_ADDR_ARRAY(peer), action_code);
7921 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007922 }
7923 }
7924
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007925 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
7926 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08007927 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007928 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08007929 {
7930 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
7931 we return error code at 'add_station()'. Hence we have this
7932 check again in addtion to add_station().
7933 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007934 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08007935 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007936 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7937 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007938 " TDLS Max peer already connected. action %d declined.",
7939 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007940 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08007941 }
7942 else
7943 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007944 /* maximum reached. tweak to send error code to peer and return
7945 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08007946 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007947 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7948 "%s: " MAC_ADDRESS_STR
7949 " TDLS Max peer already connected send response status %d",
7950 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007951 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007952 /* fall through to send setup resp with failure status
7953 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08007954 }
7955 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007956 else
7957 {
7958 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307959 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007960 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007961 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007962 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007963 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
7964 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007965 return -EPERM;
7966 }
7967 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08007968 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007969 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007970
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007971#ifdef WLAN_FEATURE_TDLS_DEBUG
7972 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007973 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
7974 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
7975 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007976#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007977
Hoonki Leea34dd892013-02-05 22:56:02 -08007978 /*Except teardown responder will not be used so just make 0*/
7979 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007980 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08007981 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007982
7983 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05307984 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007985
7986 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
7987 responder = pTdlsPeer->is_responder;
7988 else
Hoonki Leea34dd892013-02-05 22:56:02 -08007989 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007990 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7991 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
7992 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
7993 dialog_token, status_code, len);
7994 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08007995 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007996 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007997
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307998 /* For explicit trigger of DIS_REQ come out of BMPS for
7999 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008000 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308001 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8002 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008003 {
8004 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8005 {
8006 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308007 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008008 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8009 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308010 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8011 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008012 }
8013
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008014 /* make sure doesn't call send_mgmt() while it is pending */
8015 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8016 {
8017 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8018 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
8019 __func__, MAC_ADDR_ARRAY(peer), action_code);
8020 return -EBUSY;
8021 }
8022
8023 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008024 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
8025
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008026 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08008027 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008028
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008029 if (VOS_STATUS_SUCCESS != status)
8030 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8032 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008033 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07008034 wlan_hdd_tdls_check_bmps(pAdapter);
8035 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008036 }
8037
Hoonki Leed37cbb32013-04-20 00:31:14 -07008038 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
8039 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
8040
8041 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008042 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07008043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8044 "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu",
8045 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008046 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008047 wlan_hdd_tdls_check_bmps(pAdapter);
8048 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008049 }
8050
Gopichand Nakkala05922802013-03-14 12:23:19 -07008051 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07008052 {
8053 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008054 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07008055 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008056
Hoonki Leea34dd892013-02-05 22:56:02 -08008057 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
8058 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008059 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008060 }
8061 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
8062 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008063 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008064 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008065
8066 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008067error:
8068 /* max_sta_failed ; we didn't set to CONNECTING for this case,
8069 because we already know that this transaction will be failed,
8070 but we weren't sure if supplicant call DISABLE_LINK or not. So,
8071 to be safe, do not change the state mahine.
8072 */
8073 if(max_sta_failed == 0 &&
8074 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
8075 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
8076 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008077}
8078
8079static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
8080 u8 *peer, enum nl80211_tdls_operation oper)
8081{
8082 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8083 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308084 int status;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008085#ifdef WLAN_FEATURE_TDLS_DEBUG
8086 const char *tdls_oper_str[]= {
8087 "NL80211_TDLS_DISCOVERY_REQ",
8088 "NL80211_TDLS_SETUP",
8089 "NL80211_TDLS_TEARDOWN",
8090 "NL80211_TDLS_ENABLE_LINK",
8091 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05308092 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008093#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008094 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008095
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308096 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008097 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008098 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008099 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008100 return -EINVAL;
8101 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008102
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308103 status = wlan_hdd_validate_context(pHddCtx);
8104
8105 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008106 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308107 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8108 "%s: HDD context is not valid", __func__);
8109 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008110 }
8111
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308112 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008113
8114 if ( NULL == pTdlsPeer ) {
8115 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
8116 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8117 return -EINVAL;
8118 }
8119
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008120#ifdef WLAN_FEATURE_TDLS_DEBUG
8121 if((int)oper > 4)
8122 oper = 5;
8123
8124 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008125 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8126 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008127 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008128#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008129
8130 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008131 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008132 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008133 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008134 "TDLS Disabled in INI OR not enabled in FW. "
8135 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008136 return -ENOTSUPP;
8137 }
8138
8139 switch (oper) {
8140 case NL80211_TDLS_ENABLE_LINK:
8141 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008142 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308143 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008144
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07008145 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
8146 {
8147 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
8148 MAC_ADDRESS_STR " failed",
8149 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
8150 return -EINVAL;
8151 }
8152
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008153 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008154 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308155 long ret;
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308156 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308157
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308158 if (0 != wlan_hdd_tdls_get_link_establish_params(
8159 pAdapter, peer,&tdlsLinkEstablishParams)) {
8160 return -EINVAL;
8161 }
8162 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308163
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308164 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
8165 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
8166 /* Send TDLS peer UAPSD capabilities to the firmware and
8167 * register with the TL on after the response for this operation
8168 * is received .
8169 */
8170 ret = wait_for_completion_interruptible_timeout(
8171 &pAdapter->tdls_link_establish_req_comp,
8172 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
8173 if (ret <= 0)
8174 {
8175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8176 "%s: Link Establish Request Faled Status %ld",
8177 __func__, ret);
8178 return -EINVAL;
8179 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308180 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008181 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05308182 /* Mark TDLS client Authenticated .*/
8183 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
8184 pTdlsPeer->staId,
8185 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008186 if (VOS_STATUS_SUCCESS == status)
8187 {
Hoonki Lee14621352013-04-16 17:51:19 -07008188 if (pTdlsPeer->is_responder == 0)
8189 {
8190 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
8191
8192 wlan_hdd_tdls_timer_restart(pAdapter,
8193 &pTdlsPeer->initiatorWaitTimeoutTimer,
8194 WAIT_TIME_TDLS_INITIATOR);
8195 /* suspend initiator TX until it receives direct packet from the
8196 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
8197 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8198 &staId, NULL);
8199 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008200 wlan_hdd_tdls_increment_peer_count(pAdapter);
8201 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008202 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308203
8204 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308205 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
8206 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308207 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308208 int ac;
8209 uint8 ucAc[4] = { WLANTL_AC_VO,
8210 WLANTL_AC_VI,
8211 WLANTL_AC_BK,
8212 WLANTL_AC_BE };
8213 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
8214 for(ac=0; ac < 4; ac++)
8215 {
8216 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8217 pTdlsPeer->staId, ucAc[ac],
8218 tlTid[ac], tlTid[ac], 0, 0,
8219 WLANTL_BI_DIR );
8220 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308221 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008222 }
8223
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008224 }
8225 break;
8226 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08008227 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008228 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008229 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008230 long status;
8231
8232 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
8233
Lee Hoonkic1262f22013-01-24 21:59:00 -08008234 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
8235 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008236
8237 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
8238 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
8239 if (status <= 0)
8240 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008241 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8243 "%s: Del station failed status %ld",
8244 __func__, status);
8245 return -EPERM;
8246 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008247 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008248 }
8249 else
8250 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8252 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008253 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008254 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008255 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008256 case NL80211_TDLS_TEARDOWN:
8257 case NL80211_TDLS_SETUP:
8258 case NL80211_TDLS_DISCOVERY_REQ:
8259 /* We don't support in-driver setup/teardown/discovery */
8260 return -ENOTSUPP;
8261 default:
8262 return -ENOTSUPP;
8263 }
8264 return 0;
8265}
Chilam NG571c65a2013-01-19 12:27:36 +05308266
8267int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
8268 struct net_device *dev, u8 *peer)
8269{
8270 hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x",
8271 peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]);
8272
8273 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
8274 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
8275}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008276#endif
8277
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308278#ifdef WLAN_FEATURE_GTK_OFFLOAD
8279/*
8280 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
8281 * Callback rountine called upon receiving response for
8282 * get offload info
8283 */
8284void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
8285 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
8286{
8287
8288 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308289 tANI_U8 tempReplayCounter[8];
8290 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308291
8292 ENTER();
8293
8294 if (NULL == pAdapter)
8295 {
8296 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8297 "%s: HDD adapter is Null", __func__);
8298 return ;
8299 }
8300
8301 if (NULL == pGtkOffloadGetInfoRsp)
8302 {
8303 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8304 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
8305 return ;
8306 }
8307
8308 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
8309 {
8310 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8311 "%s: wlan Failed to get replay counter value",
8312 __func__);
8313 return ;
8314 }
8315
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308316 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8317 /* Update replay counter */
8318 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
8319 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8320
8321 {
8322 /* changing from little to big endian since supplicant
8323 * works on big endian format
8324 */
8325 int i;
8326 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8327
8328 for (i = 0; i < 8; i++)
8329 {
8330 tempReplayCounter[7-i] = (tANI_U8)p[i];
8331 }
8332 }
8333
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308334 /* Update replay counter to NL */
8335 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308336 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308337}
8338
8339/*
8340 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
8341 * This function is used to offload GTK rekeying job to the firmware.
8342 */
8343int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
8344 struct cfg80211_gtk_rekey_data *data)
8345{
8346 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8347 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8348 hdd_station_ctx_t *pHddStaCtx;
8349 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308350 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308351 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308352 eHalStatus status = eHAL_STATUS_FAILURE;
8353
8354 ENTER();
8355
8356 if (NULL == pAdapter)
8357 {
8358 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8359 "%s: HDD adapter is Null", __func__);
8360 return -ENODEV;
8361 }
8362
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308363 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308364
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308365 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308366 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308367 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8368 "%s: HDD context is not valid", __func__);
8369 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308370 }
8371
8372 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8373 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8374 if (NULL == hHal)
8375 {
8376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8377 "%s: HAL context is Null!!!", __func__);
8378 return -EAGAIN;
8379 }
8380
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308381 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8382 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8383 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8384 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308385 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308386 {
8387 /* changing from big to little endian since driver
8388 * works on little endian format
8389 */
8390 tANI_U8 *p =
8391 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8392 int i;
8393
8394 for (i = 0; i < 8; i++)
8395 {
8396 p[7-i] = data->replay_ctr[i];
8397 }
8398 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308399
8400 if (TRUE == pHddCtx->hdd_wlan_suspended)
8401 {
8402 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308403 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8404 sizeof (tSirGtkOffloadParams));
8405 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308406 pAdapter->sessionId);
8407
8408 if (eHAL_STATUS_SUCCESS != status)
8409 {
8410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8411 "%s: sme_SetGTKOffload failed, returned %d",
8412 __func__, status);
8413 return status;
8414 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308415 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8416 "%s: sme_SetGTKOffload successfull", __func__);
8417 }
8418 else
8419 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308420 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8421 "%s: wlan not suspended GTKOffload request is stored",
8422 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308423 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308424
8425 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308426}
8427#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8428
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308429/*
8430 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8431 * This function is used to set access control policy
8432 */
8433static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8434 struct net_device *dev, const struct cfg80211_acl_data *params)
8435{
8436 int i;
8437 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8438 hdd_hostapd_state_t *pHostapdState;
8439 tsap_Config_t *pConfig;
8440 v_CONTEXT_t pVosContext = NULL;
8441 hdd_context_t *pHddCtx;
8442 int status;
8443
8444 ENTER();
8445
8446 if (NULL == pAdapter)
8447 {
8448 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8449 "%s: HDD adapter is Null", __func__);
8450 return -ENODEV;
8451 }
8452
8453 if (NULL == params)
8454 {
8455 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8456 "%s: params is Null", __func__);
8457 return -EINVAL;
8458 }
8459
8460 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8461 status = wlan_hdd_validate_context(pHddCtx);
8462
8463 if (0 != status)
8464 {
8465 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8466 "%s: HDD context is not valid", __func__);
8467 return status;
8468 }
8469
8470 pVosContext = pHddCtx->pvosContext;
8471 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8472
8473 if (NULL == pHostapdState)
8474 {
8475 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8476 "%s: pHostapdState is Null", __func__);
8477 return -EINVAL;
8478 }
8479
8480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8481 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8482
8483 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8484 {
8485 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8486
8487 /* default value */
8488 pConfig->num_accept_mac = 0;
8489 pConfig->num_deny_mac = 0;
8490
8491 /**
8492 * access control policy
8493 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8494 * listed in hostapd.deny file.
8495 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8496 * listed in hostapd.accept file.
8497 */
8498 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8499 {
8500 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8501 }
8502 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8503 {
8504 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8505 }
8506 else
8507 {
8508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8509 "%s:Acl Policy : %d is not supported",
8510 __func__, params->acl_policy);
8511 return -ENOTSUPP;
8512 }
8513
8514 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8515 {
8516 pConfig->num_accept_mac = params->n_acl_entries;
8517 for (i = 0; i < params->n_acl_entries; i++)
8518 {
8519 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8520 "** Add ACL MAC entry %i in WhiletList :"
8521 MAC_ADDRESS_STR, i,
8522 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8523
8524 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8525 sizeof(qcmacaddr));
8526 }
8527 }
8528 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8529 {
8530 pConfig->num_deny_mac = params->n_acl_entries;
8531 for (i = 0; i < params->n_acl_entries; i++)
8532 {
8533 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8534 "** Add ACL MAC entry %i in BlackList :"
8535 MAC_ADDRESS_STR, i,
8536 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8537
8538 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8539 sizeof(qcmacaddr));
8540 }
8541 }
8542
8543 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8544 {
8545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8546 "%s: SAP Set Mac Acl fail", __func__);
8547 return -EINVAL;
8548 }
8549 }
8550 else
8551 {
8552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8553 "%s: Invalid device_mode = %d",
8554 __func__, pAdapter->device_mode);
8555 return -EINVAL;
8556 }
8557
8558 return 0;
8559}
8560
Leo Chang9056f462013-08-01 19:21:11 -07008561#ifdef WLAN_NL80211_TESTMODE
8562#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07008563void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07008564(
8565 void *pAdapter,
8566 void *indCont
8567)
8568{
Leo Changd9df8aa2013-09-26 13:32:26 -07008569 tSirLPHBInd *lphbInd;
8570 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07008571
8572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008573 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07008574
8575 if (NULL == indCont)
8576 {
8577 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008578 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07008579 return;
8580 }
8581
Leo Changd9df8aa2013-09-26 13:32:26 -07008582 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07008583 skb = cfg80211_testmode_alloc_event_skb(
8584 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07008585 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07008586 GFP_ATOMIC);
8587 if (!skb)
8588 {
8589 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8590 "LPHB timeout, NL buffer alloc fail");
8591 return;
8592 }
8593
Leo Changd9df8aa2013-09-26 13:32:26 -07008594 if(!nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
8595 {
8596 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8597 "WLAN_HDD_TM_ATTR_CMD put fail");
8598 goto nla_put_failure;
8599 }
8600 if(!nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
8601 {
8602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8603 "WLAN_HDD_TM_ATTR_TYPE put fail");
8604 goto nla_put_failure;
8605 }
8606 if(!nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
8607 sizeof(tSirLPHBInd), lphbInd))
8608 {
8609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8610 "WLAN_HDD_TM_ATTR_DATA put fail");
8611 goto nla_put_failure;
8612 }
Leo Chang9056f462013-08-01 19:21:11 -07008613 cfg80211_testmode_event(skb, GFP_ATOMIC);
8614 return;
8615
8616nla_put_failure:
8617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8618 "NLA Put fail");
8619 kfree_skb(skb);
8620
8621 return;
8622}
8623#endif /* FEATURE_WLAN_LPHB */
8624
8625static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8626{
8627 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8628 int err = 0;
8629#ifdef FEATURE_WLAN_LPHB
8630 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07008631 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07008632#endif /* FEATURE_WLAN_LPHB */
8633
8634 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8635 if (err)
8636 {
8637 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8638 "%s Testmode INV ATTR", __func__);
8639 return err;
8640 }
8641
8642 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8643 {
8644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8645 "%s Testmode INV CMD", __func__);
8646 return -EINVAL;
8647 }
8648
8649 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8650 {
8651#ifdef FEATURE_WLAN_LPHB
8652 /* Low Power Heartbeat configuration request */
8653 case WLAN_HDD_TM_CMD_WLAN_HB:
8654 {
8655 int buf_len;
8656 void *buf;
8657 tSirLPHBReq *hb_params = NULL;
8658
8659 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8660 {
8661 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8662 "%s Testmode INV DATA", __func__);
8663 return -EINVAL;
8664 }
8665
8666 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8667 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8668 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8669 if (NULL == hb_params)
8670 {
8671 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8672 "%s Request Buffer Alloc Fail", __func__);
8673 return -EINVAL;
8674 }
8675
8676 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07008677 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8678 hb_params,
8679 wlan_hdd_cfg80211_lphb_ind_handler);
8680 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07008681 {
Leo Changd9df8aa2013-09-26 13:32:26 -07008682 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8683 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07008684 vos_mem_free(hb_params);
8685 }
Leo Chang9056f462013-08-01 19:21:11 -07008686 return 0;
8687 }
8688#endif /* FEATURE_WLAN_LPHB */
8689 default:
8690 return -EOPNOTSUPP;
8691 }
8692
8693 return err;
8694}
8695#endif /* CONFIG_NL80211_TESTMODE */
8696
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308697static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8698 struct net_device *dev,
8699 int idx, struct survey_info *survey)
8700{
8701 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8702 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308703 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308704 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308705 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308706 v_S7_t snr,rssi;
8707 int status, i, j, filled = 0;
8708
8709 ENTER();
8710
8711
8712 if (NULL == pAdapter)
8713 {
8714 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8715 "%s: HDD adapter is Null", __func__);
8716 return -ENODEV;
8717 }
8718
8719 if (NULL == wiphy)
8720 {
8721 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8722 "%s: wiphy is Null", __func__);
8723 return -ENODEV;
8724 }
8725
8726 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8727 status = wlan_hdd_validate_context(pHddCtx);
8728
8729 if (0 != status)
8730 {
8731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8732 "%s: HDD context is not valid", __func__);
8733 return status;
8734 }
8735
Mihir Sheted9072e02013-08-21 17:02:29 +05308736 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8737
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308738 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308739 0 != pAdapter->survey_idx ||
8740 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308741 {
8742 /* The survey dump ops when implemented completely is expected to
8743 * return a survey of all channels and the ops is called by the
8744 * kernel with incremental values of the argument 'idx' till it
8745 * returns -ENONET. But we can only support the survey for the
8746 * operating channel for now. survey_idx is used to track
8747 * that the ops is called only once and then return -ENONET for
8748 * the next iteration
8749 */
8750 pAdapter->survey_idx = 0;
8751 return -ENONET;
8752 }
8753
8754 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8755
8756 wlan_hdd_get_snr(pAdapter, &snr);
8757 wlan_hdd_get_rssi(pAdapter, &rssi);
8758
8759 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
8760 hdd_wlan_get_freq(channel, &freq);
8761
8762
8763 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8764 {
8765 if (NULL == wiphy->bands[i])
8766 {
8767 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
8768 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
8769 continue;
8770 }
8771
8772 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8773 {
8774 struct ieee80211_supported_band *band = wiphy->bands[i];
8775
8776 if (band->channels[j].center_freq == (v_U16_t)freq)
8777 {
8778 survey->channel = &band->channels[j];
8779 /* The Rx BDs contain SNR values in dB for the received frames
8780 * while the supplicant expects noise. So we calculate and
8781 * return the value of noise (dBm)
8782 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
8783 */
8784 survey->noise = rssi - snr;
8785 survey->filled = SURVEY_INFO_NOISE_DBM;
8786 filled = 1;
8787 }
8788 }
8789 }
8790
8791 if (filled)
8792 pAdapter->survey_idx = 1;
8793 else
8794 {
8795 pAdapter->survey_idx = 0;
8796 return -ENONET;
8797 }
8798
8799 return 0;
8800}
8801
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308802/*
8803 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
8804 * this is called when cfg80211 driver resume
8805 * driver updates latest sched_scan scan result(if any) to cfg80211 database
8806 */
8807int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
8808{
8809 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8810 hdd_adapter_t *pAdapter;
8811 hdd_adapter_list_node_t *pAdapterNode, *pNext;
8812 VOS_STATUS status = VOS_STATUS_SUCCESS;
8813
8814 ENTER();
8815
8816 if ( NULL == pHddCtx )
8817 {
8818 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8819 "%s: HddCtx validation failed", __func__);
8820 return 0;
8821 }
8822
8823 if (pHddCtx->isLogpInProgress)
8824 {
8825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8826 "%s: LOGP in Progress. Ignore!!!", __func__);
8827 return 0;
8828 }
8829
8830 if (pHddCtx->isLoadUnloadInProgress)
8831 {
8832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8833 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8834 return 0;
8835 }
8836
8837 spin_lock(&pHddCtx->schedScan_lock);
8838 pHddCtx->isWiphySuspended = FALSE;
8839 if (TRUE != pHddCtx->isSchedScanUpdatePending)
8840 {
8841 spin_unlock(&pHddCtx->schedScan_lock);
8842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8843 "%s: Return resume is not due to PNO indication", __func__);
8844 return 0;
8845 }
8846 // Reset flag to avoid updatating cfg80211 data old results again
8847 pHddCtx->isSchedScanUpdatePending = FALSE;
8848 spin_unlock(&pHddCtx->schedScan_lock);
8849
8850 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8851
8852 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8853 {
8854 pAdapter = pAdapterNode->pAdapter;
8855 if ( (NULL != pAdapter) &&
8856 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
8857 {
8858 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
8859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8860 "%s: NO SCAN result", __func__);
8861 else
8862 cfg80211_sched_scan_results(pHddCtx->wiphy);
8863
8864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8865 "%s : cfg80211 scan result database updated", __func__);
8866
8867 return 0;
8868
8869 }
8870 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8871 pAdapterNode = pNext;
8872 }
8873
8874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8875 "%s: Failed to find Adapter", __func__);
8876 return 0;
8877}
8878
8879/*
8880 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
8881 * this is called when cfg80211 driver suspends
8882 */
8883int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
8884 struct cfg80211_wowlan *wow)
8885{
8886 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8887
8888 ENTER();
8889 if (NULL == pHddCtx)
8890 {
8891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8892 "%s: HddCtx validation failed", __func__);
8893 return 0;
8894 }
8895
8896 pHddCtx->isWiphySuspended = TRUE;
8897
8898 EXIT();
8899
8900 return 0;
8901}
8902
Jeff Johnson295189b2012-06-20 16:38:30 -07008903/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308904static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07008905{
8906 .add_virtual_intf = wlan_hdd_add_virtual_intf,
8907 .del_virtual_intf = wlan_hdd_del_virtual_intf,
8908 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
8909 .change_station = wlan_hdd_change_station,
8910#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8911 .add_beacon = wlan_hdd_cfg80211_add_beacon,
8912 .del_beacon = wlan_hdd_cfg80211_del_beacon,
8913 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008914#else
8915 .start_ap = wlan_hdd_cfg80211_start_ap,
8916 .change_beacon = wlan_hdd_cfg80211_change_beacon,
8917 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07008918#endif
8919 .change_bss = wlan_hdd_cfg80211_change_bss,
8920 .add_key = wlan_hdd_cfg80211_add_key,
8921 .get_key = wlan_hdd_cfg80211_get_key,
8922 .del_key = wlan_hdd_cfg80211_del_key,
8923 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08008924#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008925 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08008926#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008927 .scan = wlan_hdd_cfg80211_scan,
8928 .connect = wlan_hdd_cfg80211_connect,
8929 .disconnect = wlan_hdd_cfg80211_disconnect,
8930 .join_ibss = wlan_hdd_cfg80211_join_ibss,
8931 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
8932 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
8933 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
8934 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
8936 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
8937 .mgmt_tx = wlan_hdd_action,
8938#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8939 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
8940 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
8941 .set_txq_params = wlan_hdd_set_txq_params,
8942#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 .get_station = wlan_hdd_cfg80211_get_station,
8944 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
8945 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008946 .add_station = wlan_hdd_cfg80211_add_station,
8947#ifdef FEATURE_WLAN_LFR
8948 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
8949 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
8950 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
8951#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008952#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
8953 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
8954#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008955#ifdef FEATURE_WLAN_TDLS
8956 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
8957 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
8958#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308959#ifdef WLAN_FEATURE_GTK_OFFLOAD
8960 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
8961#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308962#ifdef FEATURE_WLAN_SCAN_PNO
8963 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
8964 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
8965#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308966 .resume = wlan_hdd_cfg80211_resume_wlan,
8967 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308968 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07008969#ifdef WLAN_NL80211_TESTMODE
8970 .testmode_cmd = wlan_hdd_cfg80211_testmode,
8971#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308972 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07008973};
8974