blob: 39934081053f97204c488a1b0fc3cb88b9914300 [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"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080087#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053088#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070089#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070090
91#define g_mode_rates_size (12)
92#define a_mode_rates_size (8)
93#define FREQ_BASE_80211G (2407)
94#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070095#define MAX_SCAN_SSID 9
Jeff Johnson295189b2012-06-20 16:38:30 -070096#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
97 ((int) OFFSET_OF( tSirBssDescription, ieFields)))
98
99#define HDD2GHZCHAN(freq, chan, flag) { \
100 .band = IEEE80211_BAND_2GHZ, \
101 .center_freq = (freq), \
102 .hw_value = (chan),\
103 .flags = (flag), \
104 .max_antenna_gain = 0 ,\
105 .max_power = 30, \
106}
107
108#define HDD5GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_5GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
118{\
119 .bitrate = rate, \
120 .hw_value = rate_id, \
121 .flags = flag, \
122}
123
Lee Hoonkic1262f22013-01-24 21:59:00 -0800124#ifndef WLAN_FEATURE_TDLS_DEBUG
125#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
126#else
127#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
128#endif
129
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530130#ifdef WLAN_FEATURE_VOWIFI_11R
131#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
132#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
133#endif
134
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530135static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700136{
137 WLAN_CIPHER_SUITE_WEP40,
138 WLAN_CIPHER_SUITE_WEP104,
139 WLAN_CIPHER_SUITE_TKIP,
140#ifdef FEATURE_WLAN_CCX
141#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
142 WLAN_CIPHER_SUITE_KRK,
143 WLAN_CIPHER_SUITE_CCMP,
144#else
145 WLAN_CIPHER_SUITE_CCMP,
146#endif
147#ifdef FEATURE_WLAN_WAPI
148 WLAN_CIPHER_SUITE_SMS4,
149#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700150#ifdef WLAN_FEATURE_11W
151 WLAN_CIPHER_SUITE_AES_CMAC,
152#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700153};
154
155static inline int is_broadcast_ether_addr(const u8 *addr)
156{
157 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
158 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
159}
160
161static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530162{
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 HDD2GHZCHAN(2412, 1, 0) ,
164 HDD2GHZCHAN(2417, 2, 0) ,
165 HDD2GHZCHAN(2422, 3, 0) ,
166 HDD2GHZCHAN(2427, 4, 0) ,
167 HDD2GHZCHAN(2432, 5, 0) ,
168 HDD2GHZCHAN(2437, 6, 0) ,
169 HDD2GHZCHAN(2442, 7, 0) ,
170 HDD2GHZCHAN(2447, 8, 0) ,
171 HDD2GHZCHAN(2452, 9, 0) ,
172 HDD2GHZCHAN(2457, 10, 0) ,
173 HDD2GHZCHAN(2462, 11, 0) ,
174 HDD2GHZCHAN(2467, 12, 0) ,
175 HDD2GHZCHAN(2472, 13, 0) ,
176 HDD2GHZCHAN(2484, 14, 0) ,
177};
178
Jeff Johnson295189b2012-06-20 16:38:30 -0700179static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
180{
181 HDD2GHZCHAN(2412, 1, 0) ,
182 HDD2GHZCHAN(2437, 6, 0) ,
183 HDD2GHZCHAN(2462, 11, 0) ,
184};
Jeff Johnson295189b2012-06-20 16:38:30 -0700185
186static struct ieee80211_channel hdd_channels_5_GHZ[] =
187{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700188 HDD5GHZCHAN(4920, 240, 0) ,
189 HDD5GHZCHAN(4940, 244, 0) ,
190 HDD5GHZCHAN(4960, 248, 0) ,
191 HDD5GHZCHAN(4980, 252, 0) ,
192 HDD5GHZCHAN(5040, 208, 0) ,
193 HDD5GHZCHAN(5060, 212, 0) ,
194 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700195 HDD5GHZCHAN(5180, 36, 0) ,
196 HDD5GHZCHAN(5200, 40, 0) ,
197 HDD5GHZCHAN(5220, 44, 0) ,
198 HDD5GHZCHAN(5240, 48, 0) ,
199 HDD5GHZCHAN(5260, 52, 0) ,
200 HDD5GHZCHAN(5280, 56, 0) ,
201 HDD5GHZCHAN(5300, 60, 0) ,
202 HDD5GHZCHAN(5320, 64, 0) ,
203 HDD5GHZCHAN(5500,100, 0) ,
204 HDD5GHZCHAN(5520,104, 0) ,
205 HDD5GHZCHAN(5540,108, 0) ,
206 HDD5GHZCHAN(5560,112, 0) ,
207 HDD5GHZCHAN(5580,116, 0) ,
208 HDD5GHZCHAN(5600,120, 0) ,
209 HDD5GHZCHAN(5620,124, 0) ,
210 HDD5GHZCHAN(5640,128, 0) ,
211 HDD5GHZCHAN(5660,132, 0) ,
212 HDD5GHZCHAN(5680,136, 0) ,
213 HDD5GHZCHAN(5700,140, 0) ,
214 HDD5GHZCHAN(5745,149, 0) ,
215 HDD5GHZCHAN(5765,153, 0) ,
216 HDD5GHZCHAN(5785,157, 0) ,
217 HDD5GHZCHAN(5805,161, 0) ,
218 HDD5GHZCHAN(5825,165, 0) ,
219};
220
221static struct ieee80211_rate g_mode_rates[] =
222{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530223 HDD_G_MODE_RATETAB(10, 0x1, 0),
224 HDD_G_MODE_RATETAB(20, 0x2, 0),
225 HDD_G_MODE_RATETAB(55, 0x4, 0),
226 HDD_G_MODE_RATETAB(110, 0x8, 0),
227 HDD_G_MODE_RATETAB(60, 0x10, 0),
228 HDD_G_MODE_RATETAB(90, 0x20, 0),
229 HDD_G_MODE_RATETAB(120, 0x40, 0),
230 HDD_G_MODE_RATETAB(180, 0x80, 0),
231 HDD_G_MODE_RATETAB(240, 0x100, 0),
232 HDD_G_MODE_RATETAB(360, 0x200, 0),
233 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700234 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530235};
Jeff Johnson295189b2012-06-20 16:38:30 -0700236
237static struct ieee80211_rate a_mode_rates[] =
238{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530239 HDD_G_MODE_RATETAB(60, 0x10, 0),
240 HDD_G_MODE_RATETAB(90, 0x20, 0),
241 HDD_G_MODE_RATETAB(120, 0x40, 0),
242 HDD_G_MODE_RATETAB(180, 0x80, 0),
243 HDD_G_MODE_RATETAB(240, 0x100, 0),
244 HDD_G_MODE_RATETAB(360, 0x200, 0),
245 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700246 HDD_G_MODE_RATETAB(540, 0x800, 0),
247};
248
249static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
250{
251 .channels = hdd_channels_2_4_GHZ,
252 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
253 .band = IEEE80211_BAND_2GHZ,
254 .bitrates = g_mode_rates,
255 .n_bitrates = g_mode_rates_size,
256 .ht_cap.ht_supported = 1,
257 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
258 | IEEE80211_HT_CAP_GRN_FLD
259 | IEEE80211_HT_CAP_DSSSCCK40
260 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
261 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
262 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
263 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
264 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
265 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
266};
267
Jeff Johnson295189b2012-06-20 16:38:30 -0700268static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
269{
270 .channels = hdd_social_channels_2_4_GHZ,
271 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
272 .band = IEEE80211_BAND_2GHZ,
273 .bitrates = g_mode_rates,
274 .n_bitrates = g_mode_rates_size,
275 .ht_cap.ht_supported = 1,
276 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
277 | IEEE80211_HT_CAP_GRN_FLD
278 | IEEE80211_HT_CAP_DSSSCCK40
279 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
280 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
281 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
282 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
283 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
284 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
285};
Jeff Johnson295189b2012-06-20 16:38:30 -0700286
287static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
288{
289 .channels = hdd_channels_5_GHZ,
290 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
291 .band = IEEE80211_BAND_5GHZ,
292 .bitrates = a_mode_rates,
293 .n_bitrates = a_mode_rates_size,
294 .ht_cap.ht_supported = 1,
295 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
296 | IEEE80211_HT_CAP_GRN_FLD
297 | IEEE80211_HT_CAP_DSSSCCK40
298 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
299 | IEEE80211_HT_CAP_SGI_40
300 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
301 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
302 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
303 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
304 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
305 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
306};
307
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530308/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 TX/RX direction for each kind of interface */
310static const struct ieee80211_txrx_stypes
311wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
312 [NL80211_IFTYPE_STATION] = {
313 .tx = 0xffff,
314 .rx = BIT(SIR_MAC_MGMT_ACTION) |
315 BIT(SIR_MAC_MGMT_PROBE_REQ),
316 },
317 [NL80211_IFTYPE_AP] = {
318 .tx = 0xffff,
319 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
320 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
321 BIT(SIR_MAC_MGMT_PROBE_REQ) |
322 BIT(SIR_MAC_MGMT_DISASSOC) |
323 BIT(SIR_MAC_MGMT_AUTH) |
324 BIT(SIR_MAC_MGMT_DEAUTH) |
325 BIT(SIR_MAC_MGMT_ACTION),
326 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700327 [NL80211_IFTYPE_ADHOC] = {
328 .tx = 0xffff,
329 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
330 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
331 BIT(SIR_MAC_MGMT_PROBE_REQ) |
332 BIT(SIR_MAC_MGMT_DISASSOC) |
333 BIT(SIR_MAC_MGMT_AUTH) |
334 BIT(SIR_MAC_MGMT_DEAUTH) |
335 BIT(SIR_MAC_MGMT_ACTION),
336 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 [NL80211_IFTYPE_P2P_CLIENT] = {
338 .tx = 0xffff,
339 .rx = BIT(SIR_MAC_MGMT_ACTION) |
340 BIT(SIR_MAC_MGMT_PROBE_REQ),
341 },
342 [NL80211_IFTYPE_P2P_GO] = {
343 /* This is also same as for SoftAP */
344 .tx = 0xffff,
345 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
346 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
347 BIT(SIR_MAC_MGMT_PROBE_REQ) |
348 BIT(SIR_MAC_MGMT_DISASSOC) |
349 BIT(SIR_MAC_MGMT_AUTH) |
350 BIT(SIR_MAC_MGMT_DEAUTH) |
351 BIT(SIR_MAC_MGMT_ACTION),
352 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700353};
354
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800355#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800356static const struct ieee80211_iface_limit
357wlan_hdd_iface_limit[] = {
358 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800359 /* max = 3 ; Our driver create two interfaces during driver init
360 * wlan0 and p2p0 interfaces. p2p0 is considered as station
361 * interface until a group is formed. In JB architecture, once the
362 * group is formed, interface type of p2p0 is changed to P2P GO or
363 * Client.
364 * When supplicant remove the group, it first issue a set interface
365 * cmd to change the mode back to Station. In JB this works fine as
366 * we advertize two station type interface during driver init.
367 * Some vendors create separate interface for P2P GO/Client,
368 * after group formation(Third one). But while group remove
369 * supplicant first tries to change the mode(3rd interface) to STATION
370 * But as we advertized only two sta type interfaces nl80211 was
371 * returning error for the third one which was leading to failure in
372 * delete interface. Ideally while removing the group, supplicant
373 * should not try to change the 3rd interface mode to Station type.
374 * Till we get a fix in wpa_supplicant, we advertize max STA
375 * interface type to 3
376 */
377 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800378 .types = BIT(NL80211_IFTYPE_STATION),
379 },
380 {
381 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700382 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800383 },
384 {
385 .max = 1,
386 .types = BIT(NL80211_IFTYPE_P2P_GO) |
387 BIT(NL80211_IFTYPE_P2P_CLIENT),
388 },
389};
390
391/* By default, only single channel concurrency is allowed */
392static struct ieee80211_iface_combination
393wlan_hdd_iface_combination = {
394 .limits = wlan_hdd_iface_limit,
395 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800396 /*
397 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
398 * and p2p0 interfaces during driver init
399 * Some vendors create separate interface for P2P operations.
400 * wlan0: STA interface
401 * p2p0: P2P Device interface, action frames goes
402 * through this interface.
403 * p2p-xx: P2P interface, After GO negotiation this interface is
404 * created for p2p operations(GO/CLIENT interface).
405 */
406 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800407 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
408 .beacon_int_infra_match = false,
409};
410#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800411
Jeff Johnson295189b2012-06-20 16:38:30 -0700412static struct cfg80211_ops wlan_hdd_cfg80211_ops;
413
414/* Data rate 100KBPS based on IE Index */
415struct index_data_rate_type
416{
417 v_U8_t beacon_rate_index;
418 v_U16_t supported_rate[4];
419};
420
421/* 11B, 11G Rate table include Basic rate and Extended rate
422 The IDX field is the rate index
423 The HI field is the rate when RSSI is strong or being ignored
424 (in this case we report actual rate)
425 The MID field is the rate when RSSI is moderate
426 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
427 The LO field is the rate when RSSI is low
428 (in this case we don't report rates, actual current rate used)
429 */
430static const struct
431{
432 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700433 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700434} supported_data_rate[] =
435{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700436/* IDX HI HM LM LO (RSSI-based index */
437 {2, { 10, 10, 10, 0}},
438 {4, { 20, 20, 10, 0}},
439 {11, { 55, 20, 10, 0}},
440 {12, { 60, 55, 20, 0}},
441 {18, { 90, 55, 20, 0}},
442 {22, {110, 55, 20, 0}},
443 {24, {120, 90, 60, 0}},
444 {36, {180, 120, 60, 0}},
445 {44, {220, 180, 60, 0}},
446 {48, {240, 180, 90, 0}},
447 {66, {330, 180, 90, 0}},
448 {72, {360, 240, 90, 0}},
449 {96, {480, 240, 120, 0}},
450 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700451};
452
453/* MCS Based rate table */
454static struct index_data_rate_type supported_mcs_rate[] =
455{
456/* MCS L20 L40 S20 S40 */
457 {0, {65, 135, 72, 150}},
458 {1, {130, 270, 144, 300}},
459 {2, {195, 405, 217, 450}},
460 {3, {260, 540, 289, 600}},
461 {4, {390, 810, 433, 900}},
462 {5, {520, 1080, 578, 1200}},
463 {6, {585, 1215, 650, 1350}},
464 {7, {650, 1350, 722, 1500}}
465};
466
Leo Chang6f8870f2013-03-26 18:11:36 -0700467#ifdef WLAN_FEATURE_11AC
468
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530469#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700470
471struct index_vht_data_rate_type
472{
473 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530474 v_U16_t supported_VHT80_rate[2];
475 v_U16_t supported_VHT40_rate[2];
476 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700477};
478
479typedef enum
480{
481 DATA_RATE_11AC_MAX_MCS_7,
482 DATA_RATE_11AC_MAX_MCS_8,
483 DATA_RATE_11AC_MAX_MCS_9,
484 DATA_RATE_11AC_MAX_MCS_NA
485} eDataRate11ACMaxMcs;
486
487/* MCS Based VHT rate table */
488static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
489{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530490/* MCS L80 S80 L40 S40 L20 S40*/
491 {0, {293, 325}, {135, 150}, {65, 72}},
492 {1, {585, 650}, {270, 300}, {130, 144}},
493 {2, {878, 975}, {405, 450}, {195, 217}},
494 {3, {1170, 1300}, {540, 600}, {260, 289}},
495 {4, {1755, 1950}, {810, 900}, {390, 433}},
496 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
497 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
498 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
499 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
500 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700501};
502#endif /* WLAN_FEATURE_11AC */
503
Jeff Johnson295189b2012-06-20 16:38:30 -0700504extern struct net_device_ops net_ops_struct;
505
506/*
507 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530508 * This function is called by hdd_wlan_startup()
509 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 * This function is used to initialize and register wiphy structure.
511 */
512struct wiphy *wlan_hdd_cfg80211_init(int priv_size)
513{
514 struct wiphy *wiphy;
515 ENTER();
516
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530517 /*
518 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 */
520 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
521
522 if (!wiphy)
523 {
524 /* Print error and jump into err label and free the memory */
525 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
526 return NULL;
527 }
528
529 return wiphy;
530}
531
532/*
533 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530534 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 * private ioctl to change the band value
536 */
537int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
538{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530539 int i, j;
540 eNVChannelEnabledType channelEnabledState;
541
Jeff Johnsone7245742012-09-05 17:12:55 -0700542 ENTER();
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530543 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530545
546 if (NULL == wiphy->bands[i])
547 {
548 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
549 __func__, i);
550 continue;
551 }
552
553 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
554 {
555 struct ieee80211_supported_band *band = wiphy->bands[i];
556
557 channelEnabledState = vos_nv_getChannelEnabledState(
558 band->channels[j].hw_value);
559
560 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
561 {
562 // Enable Social channels for P2P
563 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
564 NV_CHANNEL_ENABLE == channelEnabledState)
565 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
566 else
567 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
568 continue;
569 }
570 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
571 {
572 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
573 continue;
574 }
575
576 if (NV_CHANNEL_DISABLE == channelEnabledState ||
577 NV_CHANNEL_INVALID == channelEnabledState)
578 {
579 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
580 }
581 else if (NV_CHANNEL_DFS == channelEnabledState)
582 {
583 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
584 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
585 }
586 else
587 {
588 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
589 |IEEE80211_CHAN_RADAR);
590 }
591 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 }
593 return 0;
594}
595/*
596 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530597 * This function is called by hdd_wlan_startup()
598 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 * This function is used to initialize and register wiphy structure.
600 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530601int wlan_hdd_cfg80211_register(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 struct wiphy *wiphy,
603 hdd_config_t *pCfg
604 )
605{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530606
607 int i, j;
608
Jeff Johnsone7245742012-09-05 17:12:55 -0700609 ENTER();
610
Jeff Johnson295189b2012-06-20 16:38:30 -0700611 /* Now bind the underlying wlan device with wiphy */
612 set_wiphy_dev(wiphy, dev);
613
614 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
615
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700616 wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700617
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700618#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700619 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
620 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
621 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700622 | WIPHY_FLAG_OFFCHAN_TX;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700623#endif
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700624#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
625 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800626#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700627 || pCfg->isFastRoamIniFeatureEnabled
628#endif
629#ifdef FEATURE_WLAN_CCX
630 || pCfg->isCcxIniFeatureEnabled
631#endif
632 )
633 {
634 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
635 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800636#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800637#ifdef FEATURE_WLAN_TDLS
638 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
639 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
640#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530641#ifdef FEATURE_WLAN_SCAN_PNO
642 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
643 wiphy->max_sched_scan_ssids = MAX_SCAN_SSID;
644 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
645#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800646
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700647 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
648 driver can still register regulatory callback and
649 it will get CRDA setting in wiphy->band[], but
650 driver need to determine what to do with both
651 regulatory settings */
652 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700653
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530654 wiphy->max_scan_ssids = MAX_SCAN_SSID;
655
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530656 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700657
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530658 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
659
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530661 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700662 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 | BIT(NL80211_IFTYPE_P2P_CLIENT)
664 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 | BIT(NL80211_IFTYPE_AP);
666
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800667#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800668 if( pCfg->enableMCC )
669 {
670 /* Currently, supports up to two channels */
671 wlan_hdd_iface_combination.num_different_channels = 2;
672
673 if( !pCfg->allowMCCGODiffBI )
674 wlan_hdd_iface_combination.beacon_int_infra_match = true;
675
676 }
677 wiphy->iface_combinations = &wlan_hdd_iface_combination;
678 wiphy->n_iface_combinations = 1;
679#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800680
Jeff Johnson295189b2012-06-20 16:38:30 -0700681 /* Before registering we need to update the ht capabilitied based
682 * on ini values*/
683 if( !pCfg->ShortGI20MhzEnable )
684 {
685 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
686 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
687 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
688 }
689
690 if( !pCfg->ShortGI40MhzEnable )
691 {
692 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
693 }
694
695 if( !pCfg->nChannelBondingMode5GHz )
696 {
697 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
698 }
699
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530700 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
701 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
702
703 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
704 {
705
706 if (NULL == wiphy->bands[i])
707 {
708 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
709 __func__, i);
710 continue;
711 }
712
713 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
714 {
715 struct ieee80211_supported_band *band = wiphy->bands[i];
716
717 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
718 {
719 // Enable social channels for P2P
720 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
721 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
722 else
723 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
724 continue;
725 }
726 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
727 {
728 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
729 continue;
730 }
731 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 }
733 /*Initialise the supported cipher suite details*/
734 wiphy->cipher_suites = hdd_cipher_suites;
735 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
736
737 /*signal strength in mBm (100*dBm) */
738 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
739
740#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700741 wiphy->max_remain_on_channel_duration = 1000;
742#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700743
744 /* Register our wiphy dev with cfg80211 */
745 if (0 > wiphy_register(wiphy))
746 {
747 /* print eror */
748 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
749 return -EIO;
750 }
751
752 EXIT();
753 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530754}
Jeff Johnson295189b2012-06-20 16:38:30 -0700755
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700756/* In this function we will try to get default country code from crda.
757 If the gCrdaDefaultCountryCode is configured in ini file,
758 we will try to call user space crda to get the regulatory settings for
759 that country. We will timeout if we can't get it from crda.
760 It's called by hdd_wlan_startup() after wlan_hdd_cfg80211_register.
761*/
762int wlan_hdd_get_crda_regd_entry(struct wiphy *wiphy, hdd_config_t *pCfg)
763{
764 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
765 if (memcmp(pCfg->crdaDefaultCountryCode,
766 CFG_CRDA_DEFAULT_COUNTRY_CODE_DEFAULT , 2) != 0)
767 {
768 init_completion(&pHddCtx->driver_crda_req);
769 regulatory_hint(wiphy, pCfg->crdaDefaultCountryCode);
770 wait_for_completion_interruptible_timeout(&pHddCtx->driver_crda_req,
771 CRDA_WAIT_TIME);
Yunsen Wange3ba1fb2013-04-05 15:04:43 -0700772 /* if the country is not found from current regulatory.bin,
773 fall back to world domain */
774 if (is_crda_regulatory_entry_valid() == VOS_FALSE)
775 crda_regulatory_entry_default(pCfg->crdaDefaultCountryCode, NUM_REG_DOMAINS-1);
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700776 }
777 return 0;
778}
779
Jeff Johnson295189b2012-06-20 16:38:30 -0700780/* In this function we will do all post VOS start initialization.
781 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530782 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700783*/
784void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
785{
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
787 /* Register for all P2P action, public action etc frames */
788 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
789
Jeff Johnsone7245742012-09-05 17:12:55 -0700790 ENTER();
791
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 /* Right now we are registering these frame when driver is getting
793 initialized. Once we will move to 2.6.37 kernel, in which we have
794 frame register ops, we will move this code as a part of that */
795 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530796 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
798
799 /* GAS Initial Response */
800 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
801 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530802
Jeff Johnson295189b2012-06-20 16:38:30 -0700803 /* GAS Comeback Request */
804 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
805 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
806
807 /* GAS Comeback Response */
808 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
809 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
810
811 /* P2P Public Action */
812 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530813 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 P2P_PUBLIC_ACTION_FRAME_SIZE );
815
816 /* P2P Action */
817 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
818 (v_U8_t*)P2P_ACTION_FRAME,
819 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700820
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530821 /* WNM BSS Transition Request frame */
822 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
823 (v_U8_t*)WNM_BSS_ACTION_FRAME,
824 WNM_BSS_ACTION_FRAME_SIZE );
825
Chet Lanctot186b5732013-03-18 10:26:30 -0700826#ifdef WLAN_FEATURE_11W
827 /* SA Query Response Action Frame */
828 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
829 (v_U8_t*)SA_QUERY_FRAME_RSP,
830 SA_QUERY_FRAME_RSP_SIZE );
831#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700832}
833
834void wlan_hdd_cfg80211_pre_voss_stop(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 */
846
847 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
848 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
849
850 /* GAS Initial Response */
851 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
852 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530853
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 /* GAS Comeback Request */
855 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
856 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
857
858 /* GAS Comeback Response */
859 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
860 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
861
862 /* P2P Public Action */
863 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530864 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 P2P_PUBLIC_ACTION_FRAME_SIZE );
866
867 /* P2P Action */
868 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
869 (v_U8_t*)P2P_ACTION_FRAME,
870 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700871
872#ifdef WLAN_FEATURE_11W
873 /* SA Query Response Action Frame */
874 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
875 (v_U8_t*)SA_QUERY_FRAME_RSP,
876 SA_QUERY_FRAME_RSP_SIZE );
877#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700878}
879
880#ifdef FEATURE_WLAN_WAPI
881void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
882 const u8 *mac_addr, u8 *key , int key_Len)
883{
884 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
885 tCsrRoamSetKey setKey;
886 v_BOOL_t isConnected = TRUE;
887 int status = 0;
888 v_U32_t roamId= 0xFF;
889 tANI_U8 *pKeyPtr = NULL;
890 int n = 0;
891
892 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
893 __func__,pAdapter->device_mode);
894
Gopichand Nakkalae7480202013-02-11 15:24:22 +0530895 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 setKey.keyId = key_index; // Store Key ID
897 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
898 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
899 setKey.paeRole = 0 ; // the PAE role
900 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
901 {
902 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
903 }
904 else
905 {
906 isConnected = hdd_connIsConnected(pHddStaCtx);
907 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
908 }
909 setKey.keyLength = key_Len;
910 pKeyPtr = setKey.Key;
911 memcpy( pKeyPtr, key, key_Len);
912
913 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
914 __func__, key_Len);
915 for (n = 0 ; n < key_Len; n++)
916 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
917 __func__,n,setKey.Key[n]);
918
919 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
920 if ( isConnected )
921 {
922 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
923 pAdapter->sessionId, &setKey, &roamId );
924 }
925 if ( status != 0 )
926 {
927 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
928 "[%4d] sme_RoamSetKey returned ERROR status= %d",
929 __LINE__, status );
930 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
931 }
932}
933#endif /* FEATURE_WLAN_WAPI*/
934
935#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530936int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 beacon_data_t **ppBeacon,
938 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700939#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530940int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700941 beacon_data_t **ppBeacon,
942 struct cfg80211_beacon_data *params,
943 int dtim_period)
944#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530945{
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 int size;
947 beacon_data_t *beacon = NULL;
948 beacon_data_t *old = NULL;
949 int head_len,tail_len;
950
Jeff Johnsone7245742012-09-05 17:12:55 -0700951 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700952 if (params->head && !params->head_len)
953 return -EINVAL;
954
955 old = pAdapter->sessionCtx.ap.beacon;
956
957 if (!params->head && !old)
958 return -EINVAL;
959
960 if (params->tail && !params->tail_len)
961 return -EINVAL;
962
963#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
964 /* Kernel 3.0 is not updating dtim_period for set beacon */
965 if (!params->dtim_period)
966 return -EINVAL;
967#endif
968
969 if(params->head)
970 head_len = params->head_len;
971 else
972 head_len = old->head_len;
973
974 if(params->tail || !old)
975 tail_len = params->tail_len;
976 else
977 tail_len = old->tail_len;
978
979 size = sizeof(beacon_data_t) + head_len + tail_len;
980
981 beacon = kzalloc(size, GFP_KERNEL);
982
983 if( beacon == NULL )
984 return -ENOMEM;
985
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700986#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 if(params->dtim_period || !old )
988 beacon->dtim_period = params->dtim_period;
989 else
990 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700991#else
992 if(dtim_period || !old )
993 beacon->dtim_period = dtim_period;
994 else
995 beacon->dtim_period = old->dtim_period;
996#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530997
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
999 beacon->tail = beacon->head + head_len;
1000 beacon->head_len = head_len;
1001 beacon->tail_len = tail_len;
1002
1003 if(params->head) {
1004 memcpy (beacon->head,params->head,beacon->head_len);
1005 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301006 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 if(old)
1008 memcpy (beacon->head,old->head,beacon->head_len);
1009 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301010
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 if(params->tail) {
1012 memcpy (beacon->tail,params->tail,beacon->tail_len);
1013 }
1014 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301015 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 memcpy (beacon->tail,old->tail,beacon->tail_len);
1017 }
1018
1019 *ppBeacon = beacon;
1020
1021 kfree(old);
1022
1023 return 0;
1024
1025}
Jeff Johnson295189b2012-06-20 16:38:30 -07001026
1027v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1028{
1029 int left = length;
1030 v_U8_t *ptr = pIes;
1031 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301032
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301034 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 elem_id = ptr[0];
1036 elem_len = ptr[1];
1037 left -= 2;
1038 if(elem_len > left)
1039 {
1040 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001041 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001042 eid,elem_len,left);
1043 return NULL;
1044 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301045 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 {
1047 return ptr;
1048 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301049
Jeff Johnson295189b2012-06-20 16:38:30 -07001050 left -= elem_len;
1051 ptr += (elem_len + 2);
1052 }
1053 return NULL;
1054}
1055
Jeff Johnson295189b2012-06-20 16:38:30 -07001056/* Check if rate is 11g rate or not */
1057static int wlan_hdd_rate_is_11g(u8 rate)
1058{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001059 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001060 u8 i;
1061 for (i = 0; i < 8; i++)
1062 {
1063 if(rate == gRateArray[i])
1064 return TRUE;
1065 }
1066 return FALSE;
1067}
1068
1069/* Check for 11g rate and set proper 11g only mode */
1070static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1071 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1072{
1073 u8 i, num_rates = pIe[0];
1074
1075 pIe += 1;
1076 for ( i = 0; i < num_rates; i++)
1077 {
1078 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1079 {
1080 /* If rate set have 11g rate than change the mode to 11G */
1081 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1082 if (pIe[i] & BASIC_RATE_MASK)
1083 {
1084 /* If we have 11g rate as basic rate, it means mode
1085 is 11g only mode.
1086 */
1087 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1088 *pCheckRatesfor11g = FALSE;
1089 }
1090 }
1091 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1092 {
1093 *require_ht = TRUE;
1094 }
1095 }
1096 return;
1097}
1098
1099static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1100{
1101 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1102 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1103 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1104 u8 checkRatesfor11g = TRUE;
1105 u8 require_ht = FALSE;
1106 u8 *pIe=NULL;
1107
1108 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1109
1110 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1111 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1112 if (pIe != NULL)
1113 {
1114 pIe += 1;
1115 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1116 &pConfig->SapHw_mode);
1117 }
1118
1119 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1120 WLAN_EID_EXT_SUPP_RATES);
1121 if (pIe != NULL)
1122 {
1123
1124 pIe += 1;
1125 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1126 &pConfig->SapHw_mode);
1127 }
1128
1129 if( pConfig->channel > 14 )
1130 {
1131 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1132 }
1133
1134 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1135 WLAN_EID_HT_CAPABILITY);
1136
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301137 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 {
1139 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1140 if(require_ht)
1141 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1142 }
1143}
1144
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301145static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1146 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1147{
1148 v_U8_t ielen = 0;
1149 v_U8_t *pIe = NULL;
1150 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1151
1152 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1153 pBeacon->tail, pBeacon->tail_len);
1154
1155 if (pIe)
1156 {
1157 ielen = pIe[1] + 2;
1158 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1159 {
1160 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1161 }
1162 else
1163 {
1164 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1165 return -EINVAL;
1166 }
1167 *total_ielen += ielen;
1168 }
1169 return 0;
1170}
1171
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001172#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001173static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1174 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001175#else
1176static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1177 struct cfg80211_beacon_data *params)
1178#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001179{
1180 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301181 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001183 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001184
1185 genie = vos_mem_malloc(MAX_GENIE_LEN);
1186
1187 if(genie == NULL) {
1188
1189 return -ENOMEM;
1190 }
1191
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301192 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1193 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001194 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301195 ret = -EINVAL;
1196 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 }
1198
1199#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301200 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1201 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1202 {
1203 ret = -EINVAL;
1204 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001205 }
1206#endif
1207
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301208 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1209 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001210 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301211 ret = -EINVAL;
1212 goto done;
1213 }
1214
1215 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1216 {
1217 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1218 &total_ielen, SS_OUI_TYPE, SS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001219 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301220 ret = -EINVAL;
1221 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001224
1225 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1226 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1227 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1228 {
1229 hddLog(LOGE,
1230 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001231 ret = -EINVAL;
1232 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 }
1234
1235 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1236 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1237 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1238 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1239 ==eHAL_STATUS_FAILURE)
1240 {
1241 hddLog(LOGE,
1242 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001243 ret = -EINVAL;
1244 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001245 }
1246
1247 // Added for ProResp IE
1248 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1249 {
1250 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1251 u8 probe_rsp_ie_len[3] = {0};
1252 u8 counter = 0;
1253 /* Check Probe Resp Length if it is greater then 255 then Store
1254 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1255 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1256 Store More then 255 bytes into One Variable.
1257 */
1258 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1259 {
1260 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1261 {
1262 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1263 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1264 }
1265 else
1266 {
1267 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1268 rem_probe_resp_ie_len = 0;
1269 }
1270 }
1271
1272 rem_probe_resp_ie_len = 0;
1273
1274 if (probe_rsp_ie_len[0] > 0)
1275 {
1276 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1277 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1278 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1279 probe_rsp_ie_len[0], NULL,
1280 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1281 {
1282 hddLog(LOGE,
1283 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001284 ret = -EINVAL;
1285 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001286 }
1287 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1288 }
1289
1290 if (probe_rsp_ie_len[1] > 0)
1291 {
1292 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1293 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1294 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1295 probe_rsp_ie_len[1], NULL,
1296 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1297 {
1298 hddLog(LOGE,
1299 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001300 ret = -EINVAL;
1301 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 }
1303 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1304 }
1305
1306 if (probe_rsp_ie_len[2] > 0)
1307 {
1308 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1309 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1310 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1311 probe_rsp_ie_len[2], NULL,
1312 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1313 {
1314 hddLog(LOGE,
1315 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001316 ret = -EINVAL;
1317 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 }
1319 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1320 }
1321
1322 if (probe_rsp_ie_len[1] == 0 )
1323 {
1324 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1325 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1326 eANI_BOOLEAN_FALSE) )
1327 {
1328 hddLog(LOGE,
1329 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1330 }
1331 }
1332
1333 if (probe_rsp_ie_len[2] == 0 )
1334 {
1335 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1336 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1337 eANI_BOOLEAN_FALSE) )
1338 {
1339 hddLog(LOGE,
1340 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1341 }
1342 }
1343
1344 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1345 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1346 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1347 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1348 == eHAL_STATUS_FAILURE)
1349 {
1350 hddLog(LOGE,
1351 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001352 ret = -EINVAL;
1353 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 }
1355 }
1356 else
1357 {
1358 // Reset WNI_CFG_PROBE_RSP Flags
1359 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1360
1361 hddLog(VOS_TRACE_LEVEL_INFO,
1362 "%s: No Probe Response IE received in set beacon",
1363 __func__);
1364 }
1365
1366 // Added for AssocResp IE
1367 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1368 {
1369 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1370 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1371 params->assocresp_ies_len, NULL,
1372 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1373 {
1374 hddLog(LOGE,
1375 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001376 ret = -EINVAL;
1377 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 }
1379
1380 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1381 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1382 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1383 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1384 == eHAL_STATUS_FAILURE)
1385 {
1386 hddLog(LOGE,
1387 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001388 ret = -EINVAL;
1389 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 }
1391 }
1392 else
1393 {
1394 hddLog(VOS_TRACE_LEVEL_INFO,
1395 "%s: No Assoc Response IE received in set beacon",
1396 __func__);
1397
1398 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1399 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1400 eANI_BOOLEAN_FALSE) )
1401 {
1402 hddLog(LOGE,
1403 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1404 }
1405 }
1406
Jeff Johnsone7245742012-09-05 17:12:55 -07001407done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001408 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301409 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001410}
Jeff Johnson295189b2012-06-20 16:38:30 -07001411
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301412/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 * FUNCTION: wlan_hdd_validate_operation_channel
1414 * called by wlan_hdd_cfg80211_start_bss() and
1415 * wlan_hdd_cfg80211_set_channel()
1416 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301417 * channel list.
1418 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001419VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001420{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301421
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 v_U32_t num_ch = 0;
1423 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1424 u32 indx = 0;
1425 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301426 v_U8_t fValidChannel = FALSE, count = 0;
1427 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301428
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1430
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301431 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301433 /* Validate the channel */
1434 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301436 if ( channel == rfChannels[count].channelNum )
1437 {
1438 fValidChannel = TRUE;
1439 break;
1440 }
1441 }
1442 if (fValidChannel != TRUE)
1443 {
1444 hddLog(VOS_TRACE_LEVEL_ERROR,
1445 "%s: Invalid Channel [%d]", __func__, channel);
1446 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 }
1448 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301449 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001450 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301451 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1452 valid_ch, &num_ch))
1453 {
1454 hddLog(VOS_TRACE_LEVEL_ERROR,
1455 "%s: failed to get valid channel list", __func__);
1456 return VOS_STATUS_E_FAILURE;
1457 }
1458 for (indx = 0; indx < num_ch; indx++)
1459 {
1460 if (channel == valid_ch[indx])
1461 {
1462 break;
1463 }
1464 }
1465
1466 if (indx >= num_ch)
1467 {
1468 hddLog(VOS_TRACE_LEVEL_ERROR,
1469 "%s: Invalid Channel [%d]", __func__, channel);
1470 return VOS_STATUS_E_FAILURE;
1471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 }
1473 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301474
Jeff Johnson295189b2012-06-20 16:38:30 -07001475}
1476
Viral Modi3a32cc52013-02-08 11:14:52 -08001477/**
1478 * FUNCTION: wlan_hdd_cfg80211_set_channel
1479 * This function is used to set the channel number
1480 */
1481static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1482 struct ieee80211_channel *chan,
1483 enum nl80211_channel_type channel_type
1484 )
1485{
1486 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001487 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001488 hdd_adapter_t *pAdapter = NULL;
1489 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301490 hdd_context_t *pHddCtx;
1491 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001492
1493 ENTER();
1494
1495 if( NULL == dev )
1496 {
1497 hddLog(VOS_TRACE_LEVEL_ERROR,
1498 "%s: Called with dev = NULL.\n", __func__);
1499 return -ENODEV;
1500 }
1501 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1502
1503 hddLog(VOS_TRACE_LEVEL_INFO,
1504 "%s: device_mode = %d freq = %d \n",__func__,
1505 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301506
1507 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1508 status = wlan_hdd_validate_context(pHddCtx);
1509
1510 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001511 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301512 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1513 "%s: HDD context is not valid", __func__);
1514 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001515 }
1516
1517 /*
1518 * Do freq to chan conversion
1519 * TODO: for 11a
1520 */
1521
1522 channel = ieee80211_frequency_to_channel(freq);
1523
1524 /* Check freq range */
1525 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1526 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1527 {
1528 hddLog(VOS_TRACE_LEVEL_ERROR,
1529 "%s: Channel [%d] is outside valid range from %d to %d\n",
1530 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1531 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1532 return -EINVAL;
1533 }
1534
1535 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1536
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301537 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1538 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001539 {
1540 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1541 {
1542 hddLog(VOS_TRACE_LEVEL_ERROR,
1543 "%s: Invalid Channel [%d] \n", __func__, channel);
1544 return -EINVAL;
1545 }
1546 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1547 "%s: set channel to [%d] for device mode =%d",
1548 __func__, channel,pAdapter->device_mode);
1549 }
1550 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001551 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001552 )
1553 {
1554 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1555 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1556 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1557
1558 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1559 {
1560 /* Link is up then return cant set channel*/
1561 hddLog( VOS_TRACE_LEVEL_ERROR,
1562 "%s: IBSS Associated, can't set the channel\n", __func__);
1563 return -EINVAL;
1564 }
1565
1566 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1567 pHddStaCtx->conn_info.operationChannel = channel;
1568 pRoamProfile->ChannelInfo.ChannelList =
1569 &pHddStaCtx->conn_info.operationChannel;
1570 }
1571 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001572 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001573 )
1574 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301575 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1576 {
1577 if(VOS_STATUS_SUCCESS !=
1578 wlan_hdd_validate_operation_channel(pAdapter,channel))
1579 {
1580 hddLog(VOS_TRACE_LEVEL_ERROR,
1581 "%s: Invalid Channel [%d] \n", __func__, channel);
1582 return -EINVAL;
1583 }
1584 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1585 }
1586 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001587 {
1588 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1589
1590 /* If auto channel selection is configured as enable/ 1 then ignore
1591 channel set by supplicant
1592 */
1593 if ( cfg_param->apAutoChannelSelection )
1594 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301595 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1596 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001597 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1598 "%s: set channel to auto channel (0) for device mode =%d",
1599 __func__, pAdapter->device_mode);
1600 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301601 else
1602 {
1603 if(VOS_STATUS_SUCCESS !=
1604 wlan_hdd_validate_operation_channel(pAdapter,channel))
1605 {
1606 hddLog(VOS_TRACE_LEVEL_ERROR,
1607 "%s: Invalid Channel [%d] \n", __func__, channel);
1608 return -EINVAL;
1609 }
1610 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1611 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001612 }
1613 }
1614 else
1615 {
1616 hddLog(VOS_TRACE_LEVEL_FATAL,
1617 "%s: Invalid device mode failed to set valid channel", __func__);
1618 return -EINVAL;
1619 }
1620 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301621 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001622}
1623
Jeff Johnson295189b2012-06-20 16:38:30 -07001624#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1625static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1626 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001627#else
1628static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1629 struct cfg80211_beacon_data *params,
1630 const u8 *ssid, size_t ssid_len,
1631 enum nl80211_hidden_ssid hidden_ssid)
1632#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001633{
1634 tsap_Config_t *pConfig;
1635 beacon_data_t *pBeacon = NULL;
1636 struct ieee80211_mgmt *pMgmt_frame;
1637 v_U8_t *pIe=NULL;
1638 v_U16_t capab_info;
1639 eCsrAuthType RSNAuthType;
1640 eCsrEncryptionType RSNEncryptType;
1641 eCsrEncryptionType mcRSNEncryptType;
1642 int status = VOS_STATUS_SUCCESS;
1643 tpWLAN_SAPEventCB pSapEventCallback;
1644 hdd_hostapd_state_t *pHostapdState;
1645 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1646 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301647 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 struct qc_mac_acl_entry *acl_entry = NULL;
1649 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001650 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001651
1652 ENTER();
1653
1654 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1655
1656 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1657
1658 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1659
1660 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1661
1662 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1663
1664 //channel is already set in the set_channel Call back
1665 //pConfig->channel = pCommitConfig->channel;
1666
1667 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301668 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1670
1671 pConfig->dtim_period = pBeacon->dtim_period;
1672
1673 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1674 pConfig->dtim_period);
1675
1676
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001677 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001678 {
1679 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 WLAN_EID_COUNTRY);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001681 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001683 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001684 pConfig->ieee80211d = 1;
1685 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1686 sme_setRegInfo(hHal, pConfig->countryCode);
1687 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001689 else
1690 {
1691 pConfig->ieee80211d = 0;
1692 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301693 /*
1694 * If auto channel is configured i.e. channel is 0,
1695 * so skip channel validation.
1696 */
1697 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1698 {
1699 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1700 {
1701 hddLog(VOS_TRACE_LEVEL_ERROR,
1702 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1703 return -EINVAL;
1704 }
1705 }
1706 else
1707 {
1708 if(1 != pHddCtx->is_dynamic_channel_range_set)
1709 {
1710 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1711 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1712 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1713 }
1714 pHddCtx->is_dynamic_channel_range_set = 0;
1715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001716 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001717 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 {
1719 pConfig->ieee80211d = 0;
1720 }
1721 pConfig->authType = eSAP_AUTO_SWITCH;
1722
1723 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301724
1725 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1727
1728 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1729
1730 /*Set wps station to configured*/
1731 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1732
1733 if(pIe)
1734 {
1735 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1736 {
1737 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1738 return -EINVAL;
1739 }
1740 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1741 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001742 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001743 /* Check 15 bit of WPS IE as it contain information for wps state
1744 * WPS state
1745 */
1746 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1747 {
1748 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1749 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1750 {
1751 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1752 }
1753 }
1754 }
1755 else
1756 {
1757 pConfig->wps_state = SAP_WPS_DISABLED;
1758 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301759 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001760
1761 pConfig->RSNWPAReqIELength = 0;
1762 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301763 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 WLAN_EID_RSN);
1765 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301766 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1768 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1769 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301770 /* The actual processing may eventually be more extensive than
1771 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 * by the app.
1773 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301774 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001775 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1776 &RSNEncryptType,
1777 &mcRSNEncryptType,
1778 &RSNAuthType,
1779 pConfig->pRSNWPAReqIE[1]+2,
1780 pConfig->pRSNWPAReqIE );
1781
1782 if( VOS_STATUS_SUCCESS == status )
1783 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301784 /* Now copy over all the security attributes you have
1785 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 * */
1787 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1788 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1789 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1790 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301791 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 "EncryptionType = %d mcEncryptionType = %d\n"),
1793 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1794 }
1795 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301796
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1798 pBeacon->tail, pBeacon->tail_len);
1799
1800 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1801 {
1802 if (pConfig->pRSNWPAReqIE)
1803 {
1804 /*Mixed mode WPA/WPA2*/
1805 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1806 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1807 }
1808 else
1809 {
1810 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1811 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1812 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301813 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1815 &RSNEncryptType,
1816 &mcRSNEncryptType,
1817 &RSNAuthType,
1818 pConfig->pRSNWPAReqIE[1]+2,
1819 pConfig->pRSNWPAReqIE );
1820
1821 if( VOS_STATUS_SUCCESS == status )
1822 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301823 /* Now copy over all the security attributes you have
1824 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001825 * */
1826 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1827 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1828 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1829 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301830 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 "EncryptionType = %d mcEncryptionType = %d\n"),
1832 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1833 }
1834 }
1835 }
1836
Jeff Johnson4416a782013-03-25 14:17:50 -07001837 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1838 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1839 return -EINVAL;
1840 }
1841
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1843
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001844#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 if (params->ssid != NULL)
1846 {
1847 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1848 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1849 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1850 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1851 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001852#else
1853 if (ssid != NULL)
1854 {
1855 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1856 pConfig->SSIDinfo.ssid.length = ssid_len;
1857 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1858 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1859 }
1860#endif
1861
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301862 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301864
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 /* default value */
1866 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1867 pConfig->num_accept_mac = 0;
1868 pConfig->num_deny_mac = 0;
1869
1870 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1871 pBeacon->tail, pBeacon->tail_len);
1872
1873 /* pIe for black list is following form:
1874 type : 1 byte
1875 length : 1 byte
1876 OUI : 4 bytes
1877 acl type : 1 byte
1878 no of mac addr in black list: 1 byte
1879 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301880 */
1881 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 {
1883 pConfig->SapMacaddr_acl = pIe[6];
1884 pConfig->num_deny_mac = pIe[7];
1885 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
1886 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05301887 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
1888 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
1890 for (i = 0; i < pConfig->num_deny_mac; i++)
1891 {
1892 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
1893 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 }
1896 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1897 pBeacon->tail, pBeacon->tail_len);
1898
1899 /* pIe for white list is following form:
1900 type : 1 byte
1901 length : 1 byte
1902 OUI : 4 bytes
1903 acl type : 1 byte
1904 no of mac addr in white list: 1 byte
1905 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301906 */
1907 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 {
1909 pConfig->SapMacaddr_acl = pIe[6];
1910 pConfig->num_accept_mac = pIe[7];
1911 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
1912 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05301913 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
1914 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
1916 for (i = 0; i < pConfig->num_accept_mac; i++)
1917 {
1918 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
1919 acl_entry++;
1920 }
1921 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05301922
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 wlan_hdd_set_sapHwmode(pHostapdAdapter);
1924
Jeff Johnsone7245742012-09-05 17:12:55 -07001925#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08001926 /* Overwrite the hostapd setting for HW mode only for 11ac.
1927 * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini .
1928 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */
1929 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
1930 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301931 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08001932 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
1933 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07001934 {
1935 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001936
1937 /* Disable VHT support in 2.4 GHz band */
1938 if (pConfig->channel <= 14 &&
1939 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
1940 {
1941 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
1942 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001943 }
1944#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301945
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07001946 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
1947 {
1948 sme_SelectCBMode(hHal,
1949 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
1950 pConfig->channel);
1951 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001952 // ht_capab is not what the name conveys,this is used for protection bitmap
1953 pConfig->ht_capab =
1954 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
1955
1956 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
1957 {
1958 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
1959 return -EINVAL;
1960 }
1961
1962 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301963 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
1965 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301966 pConfig->obssProtEnabled =
1967 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001968
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301969 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001970 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301971 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
1973 (int)pConfig->channel);
1974 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301975 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
1976 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301978 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001979 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
1980 pConfig->protEnabled, pConfig->obssProtEnabled);
1981
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301982 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 {
1984 //Bss already started. just return.
1985 //TODO Probably it should update some beacon params.
1986 hddLog( LOGE, "Bss Already started...Ignore the request");
1987 EXIT();
1988 return 0;
1989 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301990
Jeff Johnson295189b2012-06-20 16:38:30 -07001991 pConfig->persona = pHostapdAdapter->device_mode;
1992
1993 pSapEventCallback = hdd_hostapd_SAPEventCB;
1994 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
1995 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
1996 {
1997 hddLog(LOGE,FL("SAP Start Bss fail\n"));
1998 return -EINVAL;
1999 }
2000
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302001 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2003
2004 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302005
Jeff Johnson295189b2012-06-20 16:38:30 -07002006 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302007 {
2008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 ("ERROR: HDD vos wait for single_event failed!!\n"));
2010 VOS_ASSERT(0);
2011 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302012
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 //Succesfully started Bss update the state bit.
2014 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2015
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002016#ifdef WLAN_FEATURE_P2P_DEBUG
2017 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2018 {
2019 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2020 {
2021 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2022 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002023 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002024 }
2025 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2026 {
2027 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2028 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002029 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002030 }
2031 }
2032#endif
2033
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 pHostapdState->bCommit = TRUE;
2035 EXIT();
2036
2037 return 0;
2038}
2039
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002040#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302041static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2042 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 struct beacon_parameters *params)
2044{
2045 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302046 hdd_context_t *pHddCtx;
2047 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002048
2049 ENTER();
2050
2051 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
2052
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302053 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2054 status = wlan_hdd_validate_context(pHddCtx);
2055
2056 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002057 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302058 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2059 "%s: HDD context is not valid", __func__);
2060 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002061 }
2062
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302063 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002064 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 )
2066 {
2067 beacon_data_t *old,*new;
2068
2069 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302070
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 if (old)
2072 return -EALREADY;
2073
2074 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2075
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302076 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 {
2078 hddLog(VOS_TRACE_LEVEL_FATAL,
2079 "%s:Error!!! Allocating the new beacon\n",__func__);
2080 return -EINVAL;
2081 }
2082
2083 pAdapter->sessionCtx.ap.beacon = new;
2084
2085 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2086 }
2087
2088 EXIT();
2089 return status;
2090}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302091
2092static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 struct net_device *dev,
2094 struct beacon_parameters *params)
2095{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302096 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302097 hdd_context_t *pHddCtx;
2098 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002099
2100 ENTER();
2101
2102 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2103 __func__,pAdapter->device_mode);
2104
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302105 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2106 status = wlan_hdd_validate_context(pHddCtx);
2107
2108 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002109 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302110 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2111 "%s: HDD context is not valid", __func__);
2112 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002113 }
2114
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302115 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302117 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 {
2119 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302120
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302122
Jeff Johnson295189b2012-06-20 16:38:30 -07002123 if (!old)
2124 return -ENOENT;
2125
2126 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2127
2128 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302129 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 "%s: Error!!! Allocating the new beacon\n",__func__);
2131 return -EINVAL;
2132 }
2133
2134 pAdapter->sessionCtx.ap.beacon = new;
2135
2136 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2137 }
2138
2139 EXIT();
2140 return status;
2141}
2142
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002143#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2144
2145#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002146static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2147 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002148#else
2149static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2150 struct net_device *dev)
2151#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002152{
2153 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002154 hdd_context_t *pHddCtx = NULL;
2155 hdd_scaninfo_t *pScanInfo = NULL;
2156 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302157 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002158
2159 ENTER();
2160
2161 if (NULL == pAdapter)
2162 {
2163 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002164 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 return -ENODEV;
2166 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002167
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302168 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2169 status = wlan_hdd_validate_context(pHddCtx);
2170
2171 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002172 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302173 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2174 "%s: HDD context is not valid", __func__);
2175 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002176 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002177
2178 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2179 if (NULL == staAdapter)
2180 {
2181 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2182 if (NULL == staAdapter)
2183 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302184 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002185 "%s: HDD adapter context is Null", __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002186 return -ENODEV;
2187 }
2188 }
2189
2190 pScanInfo = &pHddCtx->scan_info;
2191
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2193 __func__,pAdapter->device_mode);
2194
Jeff Johnsone7245742012-09-05 17:12:55 -07002195 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
2196 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002197 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -07002198 hdd_abort_mac_scan(staAdapter->pHddCtx);
2199 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002200 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002201 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2202 if (!status)
2203 {
2204 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson902c9832012-12-10 14:28:09 -08002205 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002206 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002207 VOS_ASSERT(pScanInfo->mScanPending);
2208 return 0;
2209 }
2210 }
2211
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 )
2215 {
2216 beacon_data_t *old;
2217
2218 old = pAdapter->sessionCtx.ap.beacon;
2219
2220 if (!old)
2221 return -ENOENT;
2222
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002224
2225 mutex_lock(&pHddCtx->sap_lock);
2226 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2227 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002228 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 {
2230 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2231
2232 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2233
2234 if (!VOS_IS_STATUS_SUCCESS(status))
2235 {
2236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2237 ("ERROR: HDD vos wait for single_event failed!!\n"));
2238 VOS_ASSERT(0);
2239 }
2240 }
2241 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2242 }
2243 mutex_unlock(&pHddCtx->sap_lock);
2244
2245 if(status != VOS_STATUS_SUCCESS)
2246 {
2247 hddLog(VOS_TRACE_LEVEL_FATAL,
2248 "%s:Error!!! Stopping the BSS\n",__func__);
2249 return -EINVAL;
2250 }
2251
Jeff Johnson4416a782013-03-25 14:17:50 -07002252 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2254 ==eHAL_STATUS_FAILURE)
2255 {
2256 hddLog(LOGE,
2257 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2258 }
2259
Jeff Johnson4416a782013-03-25 14:17:50 -07002260 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002261 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2262 eANI_BOOLEAN_FALSE) )
2263 {
2264 hddLog(LOGE,
2265 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2266 }
2267
2268 // Reset WNI_CFG_PROBE_RSP Flags
2269 wlan_hdd_reset_prob_rspies(pAdapter);
2270
2271 pAdapter->sessionCtx.ap.beacon = NULL;
2272 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002273#ifdef WLAN_FEATURE_P2P_DEBUG
2274 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2275 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2276 {
2277 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2278 "GO got removed");
2279 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2280 }
2281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002282 }
2283 EXIT();
2284 return status;
2285}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002286
2287#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2288
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302289static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2290 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002291 struct cfg80211_ap_settings *params)
2292{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302293 hdd_adapter_t *pAdapter;
2294 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302295 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002296
2297 ENTER();
2298
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302299 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002300 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302301 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302302 "%s: Device is Null", __func__);
2303 return -ENODEV;
2304 }
2305
2306 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2307 if (NULL == pAdapter)
2308 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302309 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302310 "%s: HDD adapter is Null", __func__);
2311 return -ENODEV;
2312 }
2313
2314 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2315 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302316 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302317 "%s: HDD adapter magic is invalid", __func__);
2318 return -ENODEV;
2319 }
2320
2321 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302322 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302323
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302324 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302325 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302326 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2327 "%s: HDD context is not valid", __func__);
2328 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302329 }
2330
2331 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2332 __func__, pAdapter->device_mode);
2333
2334 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002335 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002336 )
2337 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302338 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002339
2340 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302341
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002342 if (old)
2343 return -EALREADY;
2344
2345 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2346
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302347 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002348 {
2349 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302350 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002351 return -EINVAL;
2352 }
2353 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002354#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
2355 wlan_hdd_cfg80211_set_channel(wiphy, dev, params->channel, params->channel_type);
2356#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002357 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2358 params->ssid_len, params->hidden_ssid);
Gopichand Nakkala8c0386c2013-07-09 23:31:37 +05302359 if (0 == status)
2360 {
2361 hdd_start_p2p_go_connection_in_progress_timer(pAdapter);
2362 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002363 }
2364
2365 EXIT();
2366 return status;
2367}
2368
2369
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302370static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002371 struct net_device *dev,
2372 struct cfg80211_beacon_data *params)
2373{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302374 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302375 hdd_context_t *pHddCtx;
2376 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002377
2378 ENTER();
2379
2380 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2381 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302382
2383 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2384 status = wlan_hdd_validate_context(pHddCtx);
2385
2386 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002387 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302388 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2389 "%s: HDD context is not valid", __func__);
2390 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002391 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002392
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302393 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002394 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302395 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002396 {
2397 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302398
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002399 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302400
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002401 if (!old)
2402 return -ENOENT;
2403
2404 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2405
2406 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302407 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002408 "%s: Error!!! Allocating the new beacon\n",__func__);
2409 return -EINVAL;
2410 }
2411
2412 pAdapter->sessionCtx.ap.beacon = new;
2413
2414 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2415 }
2416
2417 EXIT();
2418 return status;
2419}
2420
2421#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2422
Jeff Johnson295189b2012-06-20 16:38:30 -07002423
2424static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2425 struct net_device *dev,
2426 struct bss_parameters *params)
2427{
2428 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2429
2430 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302431
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2433 __func__,pAdapter->device_mode);
2434
2435 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002436 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302437 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 {
2439 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2440 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302441 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 {
2443 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002445 }
2446
2447 EXIT();
2448 return 0;
2449}
2450
2451/*
2452 * FUNCTION: wlan_hdd_cfg80211_change_iface
2453 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2454 */
2455int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2456 struct net_device *ndev,
2457 enum nl80211_iftype type,
2458 u32 *flags,
2459 struct vif_params *params
2460 )
2461{
2462 struct wireless_dev *wdev;
2463 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2464 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002465 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 tCsrRoamProfile *pRoamProfile = NULL;
2467 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302468 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 eMib_dot11DesiredBssType connectedBssType;
2470 VOS_STATUS status;
2471
2472 ENTER();
2473
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302474 status = wlan_hdd_validate_context(pHddCtx);
2475
2476 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302478 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2479 "%s: HDD context is not valid", __func__);
2480 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002481 }
2482
2483 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2484 __func__, pAdapter->device_mode);
2485
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302486 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 wdev = ndev->ieee80211_ptr;
2488
2489#ifdef WLAN_BTAMP_FEATURE
2490 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2491 (NL80211_IFTYPE_ADHOC == type)||
2492 (NL80211_IFTYPE_AP == type)||
2493 (NL80211_IFTYPE_P2P_GO == type))
2494 {
2495 pHddCtx->isAmpAllowed = VOS_FALSE;
2496 // stop AMP traffic
2497 status = WLANBAP_StopAmp();
2498 if(VOS_STATUS_SUCCESS != status )
2499 {
2500 pHddCtx->isAmpAllowed = VOS_TRUE;
2501 hddLog(VOS_TRACE_LEVEL_FATAL,
2502 "%s: Failed to stop AMP", __func__);
2503 return -EINVAL;
2504 }
2505 }
2506#endif //WLAN_BTAMP_FEATURE
2507 /* Reset the current device mode bit mask*/
2508 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2509
2510 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002512 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 )
2514 {
2515 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2516 pRoamProfile = &pWextState->roamProfile;
2517 LastBSSType = pRoamProfile->BSSType;
2518
2519 switch (type)
2520 {
2521 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002523 hddLog(VOS_TRACE_LEVEL_INFO,
2524 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2525 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002526#ifdef WLAN_FEATURE_11AC
2527 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2528 {
2529 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2530 }
2531#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302532 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002533 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002535 //Check for sub-string p2p to confirm its a p2p interface
2536 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302537 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002538 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2539 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2540 }
2541 else
2542 {
2543 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002545 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302546#ifdef FEATURE_WLAN_TDLS
2547 /* The open adapter for the p2p shall skip initializations in
2548 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2549 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2550 * tdls_init when the change_iface sets the device mode to
2551 * WLAN_HDD_P2P_CLIENT.
2552 */
2553
2554 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2555 {
2556 if (0 != wlan_hdd_tdls_init (pAdapter))
2557 {
2558 return -EINVAL;
2559 }
2560 }
2561#endif
2562
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 break;
2564 case NL80211_IFTYPE_ADHOC:
2565 hddLog(VOS_TRACE_LEVEL_INFO,
2566 "%s: setting interface Type to ADHOC", __func__);
2567 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2568 pRoamProfile->phyMode =
2569 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002570 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002571 wdev->iftype = type;
2572 break;
2573
2574 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 {
2577 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2578 "%s: setting interface Type to %s", __func__,
2579 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2580
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002581 //Cancel any remain on channel for GO mode
2582 if (NL80211_IFTYPE_P2P_GO == type)
2583 {
2584 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2585 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002586 if (NL80211_IFTYPE_AP == type)
2587 {
2588 /* As Loading WLAN Driver one interface being created for p2p device
2589 * address. This will take one HW STA and the max number of clients
2590 * that can connect to softAP will be reduced by one. so while changing
2591 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2592 * interface as it is not required in SoftAP mode.
2593 */
2594
2595 // Get P2P Adapter
2596 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2597
2598 if (pP2pAdapter)
2599 {
2600 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2601 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2602 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2603 }
2604 }
2605
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 //De-init the adapter.
2607 hdd_stop_adapter( pHddCtx, pAdapter );
2608 hdd_deinit_adapter( pHddCtx, pAdapter );
2609 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2611 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002612
2613 //Disable BMPS and IMPS if enabled
2614 //before starting Go
2615 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2616 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302617 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002618 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2619 {
2620 //Fail to Exit BMPS
2621 VOS_ASSERT(0);
2622 }
2623 }
2624
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002625 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2626 (pConfig->apRandomBssidEnabled))
2627 {
2628 /* To meet Android requirements create a randomized
2629 MAC address of the form 02:1A:11:Fx:xx:xx */
2630 get_random_bytes(&ndev->dev_addr[3], 3);
2631 ndev->dev_addr[0] = 0x02;
2632 ndev->dev_addr[1] = 0x1A;
2633 ndev->dev_addr[2] = 0x11;
2634 ndev->dev_addr[3] |= 0xF0;
2635 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2636 VOS_MAC_ADDR_SIZE);
2637 pr_info("wlan: Generated HotSpot BSSID "
2638 "%02x:%02x:%02x:%02x:%02x:%02x\n",
2639 ndev->dev_addr[0],
2640 ndev->dev_addr[1],
2641 ndev->dev_addr[2],
2642 ndev->dev_addr[3],
2643 ndev->dev_addr[4],
2644 ndev->dev_addr[5]);
2645 }
2646
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 hdd_set_ap_ops( pAdapter->dev );
2648
2649 status = hdd_init_ap_mode(pAdapter);
2650 if(status != VOS_STATUS_SUCCESS)
2651 {
2652 hddLog(VOS_TRACE_LEVEL_FATAL,
2653 "%s: Error initializing the ap mode", __func__);
2654 return -EINVAL;
2655 }
2656 hdd_set_conparam(1);
2657
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 /*interface type changed update in wiphy structure*/
2659 if(wdev)
2660 {
2661 wdev->iftype = type;
2662 pHddCtx->change_iface = type;
2663 }
2664 else
2665 {
2666 hddLog(VOS_TRACE_LEVEL_ERROR,
2667 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2668 return -EINVAL;
2669 }
2670 goto done;
2671 }
2672
2673 default:
2674 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2675 __func__);
2676 return -EOPNOTSUPP;
2677 }
2678 }
2679 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 )
2682 {
2683 switch(type)
2684 {
2685 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 case NL80211_IFTYPE_ADHOC:
Jeff Johnson32d95a32012-09-10 13:15:23 -07002688 hdd_stop_adapter( pHddCtx, pAdapter );
2689 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002691 //Check for sub-string p2p to confirm its a p2p interface
2692 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002693 {
2694 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2695 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2696 }
2697 else
2698 {
2699 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 hdd_set_conparam(0);
2703 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2705 hdd_set_station_ops( pAdapter->dev );
2706 status = hdd_init_station_mode( pAdapter );
2707 if( VOS_STATUS_SUCCESS != status )
2708 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002709 /* In case of JB, for P2P-GO, only change interface will be called,
2710 * This is the right place to enable back bmps_imps()
2711 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302712 if (pHddCtx->hdd_wlan_suspended)
2713 {
2714 hdd_set_pwrparams(pHddCtx);
2715 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002716 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 goto done;
2718 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2722 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 goto done;
2724 default:
2725 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2726 __func__);
2727 return -EOPNOTSUPP;
2728
2729 }
2730
2731 }
2732 else
2733 {
2734 return -EOPNOTSUPP;
2735 }
2736
2737
2738 if(pRoamProfile)
2739 {
2740 if ( LastBSSType != pRoamProfile->BSSType )
2741 {
2742 /*interface type changed update in wiphy structure*/
2743 wdev->iftype = type;
2744
2745 /*the BSS mode changed, We need to issue disconnect
2746 if connected or in IBSS disconnect state*/
2747 if ( hdd_connGetConnectedBssType(
2748 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2749 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2750 {
2751 /*need to issue a disconnect to CSR.*/
2752 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2753 if( eHAL_STATUS_SUCCESS ==
2754 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2755 pAdapter->sessionId,
2756 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2757 {
2758 wait_for_completion_interruptible_timeout(
2759 &pAdapter->disconnect_comp_var,
2760 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2761 }
2762 }
2763 }
2764 }
2765
2766done:
2767 /*set bitmask based on updated value*/
2768 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002769
2770 /* Only STA mode support TM now
2771 * all other mode, TM feature should be disabled */
2772 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2773 (~VOS_STA & pHddCtx->concurrency_mode) )
2774 {
2775 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2776 }
2777
Jeff Johnson295189b2012-06-20 16:38:30 -07002778#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302779 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2781 {
2782 //we are ok to do AMP
2783 pHddCtx->isAmpAllowed = VOS_TRUE;
2784 }
2785#endif //WLAN_BTAMP_FEATURE
2786 EXIT();
2787 return 0;
2788}
2789
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002790#ifdef FEATURE_WLAN_TDLS
2791static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2792 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2793{
2794 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2795 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2796 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002797 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002798
2799 ENTER();
2800
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302801 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002802 {
2803 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2804 "Invalid arguments");
2805 return -EINVAL;
2806 }
Hoonki Lee27511902013-03-14 18:19:06 -07002807
2808 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
2809 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
2810 {
2811 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2812 "%s: TDLS mode is disabled OR not enabled in FW."
2813 MAC_ADDRESS_STR " Request declined.",
2814 __func__, MAC_ADDR_ARRAY(mac));
2815 return -ENOTSUPP;
2816 }
2817
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002818 if (pHddCtx->isLogpInProgress)
2819 {
2820 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2821 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07002822 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002823 return -EBUSY;
2824 }
2825
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002826 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac);
2827
2828 if ( NULL == pTdlsPeer ) {
2829 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2830 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
2831 __func__, MAC_ADDR_ARRAY(mac), update);
2832 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002833 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002834
2835 /* in add station, we accept existing valid staId if there is */
2836 if ((0 == update) &&
2837 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
2838 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002839 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002840 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002841 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002842 " link_status %d. staId %d. add station ignored.",
2843 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
2844 return 0;
2845 }
2846 /* in change station, we accept only when staId is valid */
2847 if ((1 == update) &&
2848 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
2849 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
2850 {
2851 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2852 "%s: " MAC_ADDRESS_STR
2853 " link status %d. staId %d. change station %s.",
2854 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
2855 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
2856 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002857 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002858
2859 /* when others are on-going, we want to change link_status to idle */
Hoonki Leefb8df672013-04-10 18:20:34 -07002860 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002861 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002862 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2863 "%s: " MAC_ADDRESS_STR
2864 " TDLS setup is ongoing. Request declined.",
2865 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07002866 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002867 }
2868
2869 /* first to check if we reached to maximum supported TDLS peer.
2870 TODO: for now, return -EPERM looks working fine,
2871 but need to check if any other errno fit into this category.*/
2872 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
2873 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002874 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2875 "%s: " MAC_ADDRESS_STR
2876 " TDLS Max peer already connected. Request declined.",
2877 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07002878 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002879 }
2880 else
2881 {
2882 hddTdlsPeer_t *pTdlsPeer;
2883 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002884 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002885 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002886 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2887 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
2888 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002889 return -EPERM;
2890 }
2891 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002892 if (0 == update)
2893 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002894
Jeff Johnsond75fe012013-04-06 10:53:06 -07002895 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302896 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002897 {
2898 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2899 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07002900 if(StaParams->htcap_present)
2901 {
2902 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2903 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
2904 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2905 "ht_capa->extended_capabilities: %0x",
2906 StaParams->HTCap.extendedHtCapInfo);
2907 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002908 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2909 "params->capability: %0x",StaParams->capability);
2910 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2911 "params->ext_capab_len: %0x",StaParams->extn_capability);
Hoonki Lee66b75f32013-04-16 18:30:07 -07002912 if(StaParams->vhtcap_present)
2913 {
2914 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2915 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
2916 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
2917 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
2918 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002919 {
2920 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002921 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002922 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
2923 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2924 "[%d]: %x ", i, StaParams->supported_rates[i]);
2925 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07002926 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302927 else if ((1 == update) && (NULL == StaParams))
2928 {
2929 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2930 "%s : update is true, but staParams is NULL. Error!", __func__);
2931 return -EPERM;
2932 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002933
2934 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
2935
2936 if (!update)
2937 {
2938 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
2939 pAdapter->sessionId, mac);
2940 }
2941 else
2942 {
2943 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
2944 pAdapter->sessionId, mac, StaParams);
2945 }
2946
2947 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
2948 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
2949
2950 if (!status)
2951 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002953 "%s: timeout waiting for tdls add station indication",
2954 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002955 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002956 }
2957 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
2958 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002960 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002961 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002962 }
2963
2964 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07002965
2966error:
2967 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
2968 return -EPERM;
2969
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002970}
2971#endif
2972
Jeff Johnson295189b2012-06-20 16:38:30 -07002973static int wlan_hdd_change_station(struct wiphy *wiphy,
2974 struct net_device *dev,
2975 u8 *mac,
2976 struct station_parameters *params)
2977{
2978 VOS_STATUS status = VOS_STATUS_SUCCESS;
2979 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05302980 hdd_context_t *pHddCtx;
2981 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07002983#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002984 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002985 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07002986#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002987 ENTER();
2988
Gopichand Nakkala29149562013-05-10 21:43:41 +05302989 if ((NULL == pAdapter))
2990 {
2991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2992 "invalid adapter ");
2993 return -EINVAL;
2994 }
2995
2996 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2997 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2998
2999 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3000 {
3001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3002 "invalid HDD state or HDD station context");
3003 return -EINVAL;
3004 }
3005
3006 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003007 {
3008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3009 "%s:LOGP in Progress. Ignore!!!", __func__);
3010 return -EAGAIN;
3011 }
3012
Jeff Johnson295189b2012-06-20 16:38:30 -07003013 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3014
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003015 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3016 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003017 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003018 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303020 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 WLANTL_STA_AUTHENTICATED);
3022
Gopichand Nakkala29149562013-05-10 21:43:41 +05303023 if (status != VOS_STATUS_SUCCESS)
3024 {
3025 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3026 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3027 return -EINVAL;
3028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 }
3030 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003031 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3032 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303033#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003034 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3035 StaParams.capability = params->capability;
3036 StaParams.uapsd_queues = params->uapsd_queues;
3037 StaParams.max_sp = params->max_sp;
3038
3039 if (0 != params->ext_capab_len)
3040 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3041 sizeof(StaParams.extn_capability));
3042
3043 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003044 {
3045 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003046 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003047 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003048
3049 StaParams.supported_rates_len = params->supported_rates_len;
3050
3051 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3052 * The supported_rates array , for all the structures propogating till Add Sta
3053 * to the firmware has to be modified , if the supplicant (ieee80211) is
3054 * modified to send more rates.
3055 */
3056
3057 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3058 */
3059 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3060 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3061
3062 if (0 != StaParams.supported_rates_len) {
3063 int i = 0;
3064 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3065 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003066 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003067 "Supported Rates with Length %d", StaParams.supported_rates_len);
3068 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003069 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003070 "[%d]: %0x", i, StaParams.supported_rates[i]);
3071 }
3072
3073 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003074 {
3075 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003076 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003077 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003078
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003079 if (0 != params->ext_capab_len ) {
3080 /*Define A Macro : TODO Sunil*/
3081 if ((1<<4) & StaParams.extn_capability[3]) {
3082 isBufSta = 1;
3083 }
3084 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303085 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3086 params->max_sp, isBufSta);
3087 if (VOS_STATUS_SUCCESS != status) {
3088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3089 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3090 return -EINVAL;
3091 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003092 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3093
3094 if (VOS_STATUS_SUCCESS != status) {
3095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3096 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3097 return -EINVAL;
3098 }
3099 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003100#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303101 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003102 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 return status;
3104}
3105
3106/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003107 * FUNCTION: wlan_hdd_cfg80211_add_key
3108 * This function is used to initialize the key information
3109 */
3110#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003111static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 struct net_device *ndev,
3113 u8 key_index, bool pairwise,
3114 const u8 *mac_addr,
3115 struct key_params *params
3116 )
3117#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003118static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 struct net_device *ndev,
3120 u8 key_index, const u8 *mac_addr,
3121 struct key_params *params
3122 )
3123#endif
3124{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003125 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 tCsrRoamSetKey setKey;
3127 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303128 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003129 v_U32_t roamId= 0xFF;
3130 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 hdd_hostapd_state_t *pHostapdState;
3132 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003133 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303134 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003135
3136 ENTER();
3137
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303138 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3139 status = wlan_hdd_validate_context(pHddCtx);
3140
3141 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003142 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303143 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3144 "%s: HDD context is not valid", __func__);
3145 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003146 }
3147
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003148 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3149 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003150
3151 if (CSR_MAX_NUM_KEY <= key_index)
3152 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003153 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 key_index);
3155
3156 return -EINVAL;
3157 }
3158
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003159 if (CSR_MAX_KEY_LEN < params->key_len)
3160 {
3161 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3162 params->key_len);
3163
3164 return -EINVAL;
3165 }
3166
3167 hddLog(VOS_TRACE_LEVEL_INFO,
3168 "%s: called with key index = %d & key length %d",
3169 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003170
3171 /*extract key idx, key len and key*/
3172 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3173 setKey.keyId = key_index;
3174 setKey.keyLength = params->key_len;
3175 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3176
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003177 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003178 {
3179 case WLAN_CIPHER_SUITE_WEP40:
3180 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3181 break;
3182
3183 case WLAN_CIPHER_SUITE_WEP104:
3184 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3185 break;
3186
3187 case WLAN_CIPHER_SUITE_TKIP:
3188 {
3189 u8 *pKey = &setKey.Key[0];
3190 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3191
3192 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3193
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003194 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003195
3196 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003197 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 |--------------|----------|----------|
3199 <---16bytes---><--8bytes--><--8bytes-->
3200
3201 */
3202 /*Sme expects the 32 bytes key to be in the below order
3203
3204 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003205 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 |--------------|----------|----------|
3207 <---16bytes---><--8bytes--><--8bytes-->
3208 */
3209 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003210 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003211
3212 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003213 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003214
3215 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003216 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003217
3218
3219 break;
3220 }
3221
3222 case WLAN_CIPHER_SUITE_CCMP:
3223 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3224 break;
3225
3226#ifdef FEATURE_WLAN_WAPI
3227 case WLAN_CIPHER_SUITE_SMS4:
3228 {
3229 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3230 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3231 params->key, params->key_len);
3232 return 0;
3233 }
3234#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003235
Jeff Johnson295189b2012-06-20 16:38:30 -07003236#ifdef FEATURE_WLAN_CCX
3237 case WLAN_CIPHER_SUITE_KRK:
3238 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3239 break;
3240#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003241
3242#ifdef WLAN_FEATURE_11W
3243 case WLAN_CIPHER_SUITE_AES_CMAC:
3244 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003245 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003246#endif
3247
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 default:
3249 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu",
3250 __func__, params->cipher);
3251 return -EOPNOTSUPP;
3252 }
3253
3254 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3255 __func__, setKey.encType);
3256
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003257 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003258#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3259 (!pairwise)
3260#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003261 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003262#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003263 )
3264 {
3265 /* set group key*/
3266 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3267 "%s- %d: setting Broadcast key",
3268 __func__, __LINE__);
3269 setKey.keyDirection = eSIR_RX_ONLY;
3270 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3271 }
3272 else
3273 {
3274 /* set pairwise key*/
3275 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3276 "%s- %d: setting pairwise key",
3277 __func__, __LINE__);
3278 setKey.keyDirection = eSIR_TX_RX;
3279 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3280 }
3281 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3282 {
3283 setKey.keyDirection = eSIR_TX_RX;
3284 /*Set the group key*/
3285 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3286 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003287
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003288 if ( 0 != status )
3289 {
3290 hddLog(VOS_TRACE_LEVEL_ERROR,
3291 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3292 return -EINVAL;
3293 }
3294 /*Save the keys here and call sme_RoamSetKey for setting
3295 the PTK after peer joins the IBSS network*/
3296 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3297 &setKey, sizeof(tCsrRoamSetKey));
3298 return status;
3299 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303300 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3301 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3302 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003304 if( pHostapdState->bssState == BSS_START )
3305 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3307
3308 if ( status != eHAL_STATUS_SUCCESS )
3309 {
3310 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3311 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3312 __LINE__, status );
3313 }
3314 }
3315
3316 /* Saving WEP keys */
3317 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3318 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3319 {
3320 //Save the wep key in ap context. Issue setkey after the BSS is started.
3321 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3322 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3323 }
3324 else
3325 {
3326 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003327 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3329 }
3330 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003331 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3332 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 {
3334 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3335 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3336
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303337#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3338 if (!pairwise)
3339#else
3340 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3341#endif
3342 {
3343 /* set group key*/
3344 if (pHddStaCtx->roam_info.deferKeyComplete)
3345 {
3346 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3347 "%s- %d: Perform Set key Complete",
3348 __func__, __LINE__);
3349 hdd_PerformRoamSetKeyComplete(pAdapter);
3350 }
3351 }
3352
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3354
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003355 pWextState->roamProfile.Keys.defaultIndex = key_index;
3356
3357
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003358 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003359 params->key, params->key_len);
3360
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303361
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3363
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303364 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303366 __func__, setKey.peerMac[0], setKey.peerMac[1],
3367 setKey.peerMac[2], setKey.peerMac[3],
3368 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 setKey.keyDirection);
3370
3371 vos_status = wlan_hdd_check_ula_done(pAdapter);
3372
3373 if ( vos_status != VOS_STATUS_SUCCESS )
3374 {
3375 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3376 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3377 __LINE__, vos_status );
3378
3379 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3380
3381 return -EINVAL;
3382
3383 }
3384
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003385#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303386 /* The supplicant may attempt to set the PTK once pre-authentication
3387 is done. Save the key in the UMAC and include it in the ADD BSS
3388 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003389 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303390 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003391 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303392 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3393 "%s: Update PreAuth Key success", __func__);
3394 return 0;
3395 }
3396 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3397 {
3398 hddLog(VOS_TRACE_LEVEL_ERROR,
3399 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303400 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003401 }
3402#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003403
3404 /* issue set key request to SME*/
3405 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3406 pAdapter->sessionId, &setKey, &roamId );
3407
3408 if ( 0 != status )
3409 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303410 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3412 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3413 return -EINVAL;
3414 }
3415
3416
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303417 /* in case of IBSS as there was no information available about WEP keys during
3418 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303420 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3421 !( ( IW_AUTH_KEY_MGMT_802_1X
3422 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3424 )
3425 &&
3426 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3427 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3428 )
3429 )
3430 {
3431 setKey.keyDirection = eSIR_RX_ONLY;
3432 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3433
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303434 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303436 __func__, setKey.peerMac[0], setKey.peerMac[1],
3437 setKey.peerMac[2], setKey.peerMac[3],
3438 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 setKey.keyDirection);
3440
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303441 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 pAdapter->sessionId, &setKey, &roamId );
3443
3444 if ( 0 != status )
3445 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303446 hddLog(VOS_TRACE_LEVEL_ERROR,
3447 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 __func__, status);
3449 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3450 return -EINVAL;
3451 }
3452 }
3453 }
3454
3455 return 0;
3456}
3457
3458/*
3459 * FUNCTION: wlan_hdd_cfg80211_get_key
3460 * This function is used to get the key information
3461 */
3462#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303463static int wlan_hdd_cfg80211_get_key(
3464 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303466 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 const u8 *mac_addr, void *cookie,
3468 void (*callback)(void *cookie, struct key_params*)
3469 )
3470#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303471static int wlan_hdd_cfg80211_get_key(
3472 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 struct net_device *ndev,
3474 u8 key_index, const u8 *mac_addr, void *cookie,
3475 void (*callback)(void *cookie, struct key_params*)
3476 )
3477#endif
3478{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303479 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3481 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3482 struct key_params params;
3483
3484 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303485
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3487 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303488
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 memset(&params, 0, sizeof(params));
3490
3491 if (CSR_MAX_NUM_KEY <= key_index)
3492 {
3493 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003495
3496 switch(pRoamProfile->EncryptionType.encryptionType[0])
3497 {
3498 case eCSR_ENCRYPT_TYPE_NONE:
3499 params.cipher = IW_AUTH_CIPHER_NONE;
3500 break;
3501
3502 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3503 case eCSR_ENCRYPT_TYPE_WEP40:
3504 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3505 break;
3506
3507 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3508 case eCSR_ENCRYPT_TYPE_WEP104:
3509 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3510 break;
3511
3512 case eCSR_ENCRYPT_TYPE_TKIP:
3513 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3514 break;
3515
3516 case eCSR_ENCRYPT_TYPE_AES:
3517 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3518 break;
3519
3520 default:
3521 params.cipher = IW_AUTH_CIPHER_NONE;
3522 break;
3523 }
3524
3525 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3526 params.seq_len = 0;
3527 params.seq = NULL;
3528 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3529 callback(cookie, &params);
3530 return 0;
3531}
3532
3533/*
3534 * FUNCTION: wlan_hdd_cfg80211_del_key
3535 * This function is used to delete the key information
3536 */
3537#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303538static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303540 u8 key_index,
3541 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003542 const u8 *mac_addr
3543 )
3544#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303545static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 struct net_device *ndev,
3547 u8 key_index,
3548 const u8 *mac_addr
3549 )
3550#endif
3551{
3552 int status = 0;
3553
3554 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303555 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 //it is observed that this is invalidating peer
3557 //key index whenever re-key is done. This is affecting data link.
3558 //It should be ok to ignore del_key.
3559#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303560 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3561 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3563 tCsrRoamSetKey setKey;
3564 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303565
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 ENTER();
3567
3568 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3569 __func__,pAdapter->device_mode);
3570
3571 if (CSR_MAX_NUM_KEY <= key_index)
3572 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303573 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 key_index);
3575
3576 return -EINVAL;
3577 }
3578
3579 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3580 setKey.keyId = key_index;
3581
3582 if (mac_addr)
3583 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3584 else
3585 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3586
3587 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3588
3589 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303591 )
3592 {
3593
3594 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003595 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3596 if( pHostapdState->bssState == BSS_START)
3597 {
3598 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303599
Jeff Johnson295189b2012-06-20 16:38:30 -07003600 if ( status != eHAL_STATUS_SUCCESS )
3601 {
3602 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3603 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3604 __LINE__, status );
3605 }
3606 }
3607 }
3608 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303609 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 )
3611 {
3612 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3613
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303614 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3615
3616 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303618 __func__, setKey.peerMac[0], setKey.peerMac[1],
3619 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303621 if(pAdapter->sessionCtx.station.conn_info.connState ==
3622 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303624 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303626
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 if ( 0 != status )
3628 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303629 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 "%s: sme_RoamSetKey failure, returned %d",
3631 __func__, status);
3632 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3633 return -EINVAL;
3634 }
3635 }
3636 }
3637#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003638 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 return status;
3640}
3641
3642/*
3643 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3644 * This function is used to set the default tx key index
3645 */
3646#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3647static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3648 struct net_device *ndev,
3649 u8 key_index,
3650 bool unicast, bool multicast)
3651#else
3652static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3653 struct net_device *ndev,
3654 u8 key_index)
3655#endif
3656{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303657 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303658 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303659 hdd_wext_state_t *pWextState;
3660 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303661 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003662
3663 ENTER();
3664
Gopichand Nakkala29149562013-05-10 21:43:41 +05303665 if ((NULL == pAdapter))
3666 {
3667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3668 "invalid adapter");
3669 return -EINVAL;
3670 }
3671
3672 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3673 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3674
3675 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3676 {
3677 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3678 "invalid Wext state or HDD context");
3679 return -EINVAL;
3680 }
3681
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3683 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303684
Jeff Johnson295189b2012-06-20 16:38:30 -07003685 if (CSR_MAX_NUM_KEY <= key_index)
3686 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303687 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 key_index);
3689
3690 return -EINVAL;
3691 }
3692
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303693 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3694 status = wlan_hdd_validate_context(pHddCtx);
3695
3696 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003697 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303698 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3699 "%s: HDD context is not valid", __func__);
3700 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003701 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303702
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303705 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303707 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303709 (eCSR_ENCRYPT_TYPE_AES !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 pWextState->roamProfile.EncryptionType.encryptionType[0])
3711 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303712 {
3713 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303715
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 tCsrRoamSetKey setKey;
3717 v_U32_t roamId= 0xFF;
3718 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303719
3720 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303722
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 Keys->defaultIndex = (u8)key_index;
3724 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3725 setKey.keyId = key_index;
3726 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303727
3728 vos_mem_copy(&setKey.Key[0],
3729 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303731
Gopichand Nakkala29149562013-05-10 21:43:41 +05303732 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303733
3734 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 &pHddStaCtx->conn_info.bssId[0],
3736 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303737
Gopichand Nakkala29149562013-05-10 21:43:41 +05303738 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3739 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3740 eCSR_ENCRYPT_TYPE_WEP104)
3741 {
3742 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3743 even though ap is configured for WEP-40 encryption. In this canse the key length
3744 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3745 type(104) and switching encryption type to 40*/
3746 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3747 eCSR_ENCRYPT_TYPE_WEP40;
3748 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3749 eCSR_ENCRYPT_TYPE_WEP40;
3750 }
3751
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303752 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303754
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303756 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303758
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 if ( 0 != status )
3760 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303761 hddLog(VOS_TRACE_LEVEL_ERROR,
3762 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 status);
3764 return -EINVAL;
3765 }
3766 }
3767 }
3768
3769 /* In SoftAp mode setting key direction for default mode */
3770 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3771 {
3772 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3773 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3774 (eCSR_ENCRYPT_TYPE_AES !=
3775 pWextState->roamProfile.EncryptionType.encryptionType[0])
3776 )
3777 {
3778 /* Saving key direction for default key index to TX default */
3779 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3780 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3781 }
3782 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303783
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 return status;
3785}
3786
Jeff Johnson295189b2012-06-20 16:38:30 -07003787/*
3788 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3789 * This function is used to inform the BSS details to nl80211 interface.
3790 */
3791static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3792 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3793{
3794 struct net_device *dev = pAdapter->dev;
3795 struct wireless_dev *wdev = dev->ieee80211_ptr;
3796 struct wiphy *wiphy = wdev->wiphy;
3797 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3798 int chan_no;
3799 int ie_length;
3800 const char *ie;
3801 unsigned int freq;
3802 struct ieee80211_channel *chan;
3803 int rssi = 0;
3804 struct cfg80211_bss *bss = NULL;
3805
3806 ENTER();
3807
3808 if( NULL == pBssDesc )
3809 {
3810 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
3811 return bss;
3812 }
3813
3814 chan_no = pBssDesc->channelId;
3815 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
3816 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
3817
3818 if( NULL == ie )
3819 {
3820 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
3821 return bss;
3822 }
3823
3824#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
3825 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
3826 {
3827 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
3828 }
3829 else
3830 {
3831 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
3832 }
3833#else
3834 freq = ieee80211_channel_to_frequency(chan_no);
3835#endif
3836
3837 chan = __ieee80211_get_channel(wiphy, freq);
3838
3839 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
3840 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
3841 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
3842 if (bss == NULL)
3843 {
3844 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
3845
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303846 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
3847 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 pBssDesc->capabilityInfo,
3849 pBssDesc->beaconInterval, ie, ie_length,
3850 rssi, GFP_KERNEL ));
3851}
3852 else
3853 {
3854 return bss;
3855 }
3856}
3857
3858
3859
3860/*
3861 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
3862 * This function is used to inform the BSS details to nl80211 interface.
3863 */
3864struct cfg80211_bss*
3865wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
3866 tSirBssDescription *bss_desc
3867 )
3868{
3869 /*
3870 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
3871 already exists in bss data base of cfg80211 for that particular BSS ID.
3872 Using cfg80211_inform_bss_frame to update the bss entry instead of
3873 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
3874 now there is no possibility to get the mgmt(probe response) frame from PE,
3875 converting bss_desc to ieee80211_mgmt(probe response) and passing to
3876 cfg80211_inform_bss_frame.
3877 */
3878 struct net_device *dev = pAdapter->dev;
3879 struct wireless_dev *wdev = dev->ieee80211_ptr;
3880 struct wiphy *wiphy = wdev->wiphy;
3881 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08003882#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
3883 qcom_ie_age *qie_age = NULL;
3884 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
3885#else
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08003887#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 const char *ie =
3889 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
3890 unsigned int freq;
3891 struct ieee80211_channel *chan;
3892 struct ieee80211_mgmt *mgmt =
3893 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
3894 struct cfg80211_bss *bss_status = NULL;
3895 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
3896 int rssi = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07003897#ifdef WLAN_OPEN_SOURCE
3898 struct timespec ts;
3899#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003900
3901 ENTER();
3902
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07003903 if (!mgmt)
3904 return NULL;
3905
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07003907
3908#ifdef WLAN_OPEN_SOURCE
3909 /* Android does not want the timestamp from the frame.
3910 Instead it wants a monotonic increasing value */
3911 get_monotonic_boottime(&ts);
3912 mgmt->u.probe_resp.timestamp =
3913 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
3914#else
3915 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
3917 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07003918
3919#endif
3920
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
3922 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08003923
3924#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
3925 /* GPS Requirement: need age ie per entry. Using vendor specific. */
3926 /* Assuming this is the last IE, copy at the end */
3927 ie_length -=sizeof(qcom_ie_age);
3928 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
3929 qie_age->element_id = QCOM_VENDOR_IE_ID;
3930 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
3931 qie_age->oui_1 = QCOM_OUI1;
3932 qie_age->oui_2 = QCOM_OUI2;
3933 qie_age->oui_3 = QCOM_OUI3;
3934 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
3935 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
3936#endif
3937
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05303939 if (bss_desc->fProbeRsp)
3940 {
3941 mgmt->frame_control |=
3942 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
3943 }
3944 else
3945 {
3946 mgmt->frame_control |=
3947 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
3948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003949
3950#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303951 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
3953 {
3954 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
3955 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303956 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
3958
3959 {
3960 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
3961 }
3962 else
3963 {
3964 kfree(mgmt);
3965 return NULL;
3966 }
3967#else
3968 freq = ieee80211_channel_to_frequency(chan_no);
3969#endif
3970 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08003971 /*when the band is changed on the fly using the GUI, three things are done
3972 * 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)
3973 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
3974 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
3975 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
3976 * and discards the channels correponding to previous band and calls back with zero bss results.
3977 * 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
3978 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
3979 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
3980 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
3981 * So drop the bss and continue to next bss.
3982 */
3983 if(chan == NULL)
3984 {
3985 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07003986 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08003987 return NULL;
3988 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003989 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303990 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 * */
3992 if (( eConnectionState_Associated ==
3993 pAdapter->sessionCtx.station.conn_info.connState ) &&
3994 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
3995 pAdapter->sessionCtx.station.conn_info.bssId,
3996 WNI_CFG_BSSID_LEN)))
3997 {
3998 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
3999 rssi = (pAdapter->rssi * 100);
4000 }
4001 else
4002 {
4003 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4004 }
4005
4006 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4007 frame_len, rssi, GFP_KERNEL);
4008 kfree(mgmt);
4009 return bss_status;
4010}
4011
4012/*
4013 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4014 * This function is used to update the BSS data base of CFG8011
4015 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304016struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004017 tCsrRoamInfo *pRoamInfo
4018 )
4019{
4020 tCsrRoamConnectedProfile roamProfile;
4021 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4022 struct cfg80211_bss *bss = NULL;
4023
4024 ENTER();
4025
4026 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4027 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4028
4029 if (NULL != roamProfile.pBssDesc)
4030 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304031 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 &roamProfile);
4033
4034 if (NULL == bss)
4035 {
4036 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4037 __func__);
4038 }
4039
4040 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4041 }
4042 else
4043 {
4044 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4045 __func__);
4046 }
4047 return bss;
4048}
4049
4050/*
4051 * FUNCTION: wlan_hdd_cfg80211_update_bss
4052 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304053static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4054 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304056{
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4058 tCsrScanResultInfo *pScanResult;
4059 eHalStatus status = 0;
4060 tScanResultHandle pResult;
4061 struct cfg80211_bss *bss_status = NULL;
4062
4063 ENTER();
4064
4065 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4066 {
4067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
4068 return -EAGAIN;
4069 }
4070
4071 /*
4072 * start getting scan results and populate cgf80211 BSS database
4073 */
4074 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4075
4076 /* no scan results */
4077 if (NULL == pResult)
4078 {
4079 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4080 return status;
4081 }
4082
4083 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4084
4085 while (pScanResult)
4086 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304087 /*
4088 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4089 * entry already exists in bss data base of cfg80211 for that
4090 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4091 * bss entry instead of cfg80211_inform_bss, But this call expects
4092 * mgmt packet as input. As of now there is no possibility to get
4093 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 * ieee80211_mgmt(probe response) and passing to c
4095 * fg80211_inform_bss_frame.
4096 * */
4097
4098 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4099 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304100
Jeff Johnson295189b2012-06-20 16:38:30 -07004101
4102 if (NULL == bss_status)
4103 {
4104 hddLog(VOS_TRACE_LEVEL_INFO,
4105 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4106 }
4107 else
4108 {
4109 cfg80211_put_bss(bss_status);
4110 }
4111
4112 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4113 }
4114
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304115 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004116
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304117 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004118}
4119
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004120void
4121hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4122{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304123 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004124 "%02X:%02X:%02X:%02X:%02X:%02X\n",
4125 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
4126 macAddr[5]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004127} /****** end hddPrintMacAddr() ******/
4128
4129void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004130hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004131{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304132 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004133 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4134 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4135 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4136 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004137} /****** end hddPrintPmkId() ******/
4138
4139//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4140//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4141
4142//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4143//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4144
4145#define dump_bssid(bssid) \
4146 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004147 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4148 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4149 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004150 }
4151
4152#define dump_pmkid(pMac, pmkid) \
4153 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004154 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4155 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4156 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004157 }
4158
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004159#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004160/*
4161 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4162 * This function is used to notify the supplicant of a new PMKSA candidate.
4163 */
4164int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304165 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004166 int index, bool preauth )
4167{
Jeff Johnsone7245742012-09-05 17:12:55 -07004168#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004169 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004170 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004171
4172 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004173 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004174
4175 if( NULL == pRoamInfo )
4176 {
4177 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4178 return -EINVAL;
4179 }
4180
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004181 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4182 {
4183 dump_bssid(pRoamInfo->bssid);
4184 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004185 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004186 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004187#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304188 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004189}
4190#endif //FEATURE_WLAN_LFR
4191
Jeff Johnson295189b2012-06-20 16:38:30 -07004192/*
4193 * FUNCTION: hdd_cfg80211_scan_done_callback
4194 * scanning callback function, called after finishing scan
4195 *
4196 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304197static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4199{
4200 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304201 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004203 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4204 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 struct cfg80211_scan_request *req = NULL;
4206 int ret = 0;
4207
4208 ENTER();
4209
4210 hddLog(VOS_TRACE_LEVEL_INFO,
4211 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304212 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 __func__, halHandle, pContext, (int) scanId, (int) status);
4214
4215 //Block on scan req completion variable. Can't wait forever though.
4216 ret = wait_for_completion_interruptible_timeout(
4217 &pScanInfo->scan_req_completion_event,
4218 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4219 if (!ret)
4220 {
4221 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004222 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 }
4224
4225 if(pScanInfo->mScanPending != VOS_TRUE)
4226 {
4227 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004228 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 }
4230
4231 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304232 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 {
4234 hddLog(VOS_TRACE_LEVEL_INFO,
4235 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304236 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 (int) scanId);
4238 }
4239
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304240 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 pAdapter);
4242
4243 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304244 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004245
4246
4247 /* If any client wait scan result through WEXT
4248 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004249 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 {
4251 /* The other scan request waiting for current scan finish
4252 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004253 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004254 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004255 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004256 }
4257 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004258 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004259 {
4260 struct net_device *dev = pAdapter->dev;
4261 union iwreq_data wrqu;
4262 int we_event;
4263 char *msg;
4264
4265 memset(&wrqu, '\0', sizeof(wrqu));
4266 we_event = SIOCGIWSCAN;
4267 msg = NULL;
4268 wireless_send_event(dev, we_event, &wrqu, msg);
4269 }
4270 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004271 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004272
4273 /* Get the Scan Req */
4274 req = pAdapter->request;
4275
4276 if (!req)
4277 {
4278 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004279 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004280 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004281 }
4282
4283 /*
4284 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304285 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 req->n_ssids = 0;
4287 req->n_channels = 0;
4288 req->ie = 0;
4289
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004291 /* Scan is no longer pending */
4292 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004293
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004294 /*
4295 * cfg80211_scan_done informing NL80211 about completion
4296 * of scanning
4297 */
4298 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004299 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004300
Jeff Johnsone7245742012-09-05 17:12:55 -07004301allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004302 /* release the wake lock at the end of the scan*/
4303 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004304
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004305 /* Acquire wakelock to handle the case where APP's tries to suspend
4306 * immediatly after the driver gets connect request(i.e after scan)
4307 * from supplicant, this result in app's is suspending and not able
4308 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004309 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004310
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004311#ifdef FEATURE_WLAN_TDLS
4312 wlan_hdd_tdls_scan_done_callback(pAdapter);
4313#endif
4314
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 EXIT();
4316 return 0;
4317}
4318
4319/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004320 * FUNCTION: hdd_isScanAllowed
4321 * Go through each adapter and check if scan allowed
4322 *
4323 */
4324v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4325{
4326 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4327 hdd_station_ctx_t *pHddStaCtx = NULL;
4328 hdd_adapter_t *pAdapter = NULL;
4329 VOS_STATUS status = 0;
4330 v_U8_t staId = 0;
4331 v_U8_t *staMac = NULL;
4332
Gopichand Nakkala8c0386c2013-07-09 23:31:37 +05304333 if (VOS_TIMER_STATE_RUNNING ==
4334 vos_timer_getCurrentState(&pHddCtx->hdd_p2p_go_conn_is_in_progress))
4335 {
4336 hddLog(VOS_TRACE_LEVEL_INFO,
4337 "%s: Connection is in progress, Do not allow the scan", __func__);
4338 return VOS_FALSE;
4339 }
4340
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004341 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4342
4343 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4344 {
4345 pAdapter = pAdapterNode->pAdapter;
4346
4347 if( pAdapter )
4348 {
4349 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304350 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004351 __func__, pAdapter->device_mode);
4352 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4353 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4354 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4355 {
4356 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4357 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4358 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4359 {
4360 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4361 hddLog(VOS_TRACE_LEVEL_ERROR,
4362 "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304363 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004364 staMac[0], staMac[1], staMac[2],
4365 staMac[3], staMac[4], staMac[5]);
4366 return VOS_FALSE;
4367 }
4368 }
4369 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4370 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4371 {
4372 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4373 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304374 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004375 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4376 {
4377 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4378
4379 hddLog(VOS_TRACE_LEVEL_ERROR,
4380 "%s: client %02x:%02x:%02x:%02x:%02x:%02x of SoftAP/P2P-GO is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304381 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004382 staMac[0], staMac[1], staMac[2],
4383 staMac[3], staMac[4], staMac[5]);
4384 return VOS_FALSE;
4385 }
4386 }
4387 }
4388 }
4389 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4390 pAdapterNode = pNext;
4391 }
4392 hddLog(VOS_TRACE_LEVEL_INFO,
4393 "%s: Scan allowed", __func__);
4394 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304395}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004396
4397/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 * FUNCTION: wlan_hdd_cfg80211_scan
4399 * this scan respond to scan trigger and update cfg80211 scan database
4400 * later, scan dump command can be used to recieve scan results
4401 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004402int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4403#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4404 struct net_device *dev,
4405#endif
4406 struct cfg80211_scan_request *request)
4407{
4408#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4409 struct net_device *dev = request->wdev->netdev;
4410#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304411 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4413 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304414 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 tCsrScanRequest scanRequest;
4416 tANI_U8 *channelList = NULL, i;
4417 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304418 int status;
4419 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004421
4422 ENTER();
4423
4424 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4425 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004426
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304427 status = wlan_hdd_validate_context(pHddCtx);
4428
4429 if (0 != status)
4430 {
4431 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4432 "%s: HDD context is not valid", __func__);
4433 return status;
4434 }
4435
4436 cfg_param = pHddCtx->cfg_ini;
4437 pScanInfo = &pHddCtx->scan_info;
4438
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004439 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004440 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004441 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004442 {
4443 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004444 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4445 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004446 return -EBUSY;
4447 }
4448
Jeff Johnson295189b2012-06-20 16:38:30 -07004449#ifdef WLAN_BTAMP_FEATURE
4450 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004451 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004452 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004453 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 "%s: No scanning when AMP is on", __func__);
4455 return -EOPNOTSUPP;
4456 }
4457#endif
4458 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004459 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004461 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 "%s: Not scanning on device_mode = %d",
4463 __func__, pAdapter->device_mode);
4464 return -EOPNOTSUPP;
4465 }
4466
4467 if (TRUE == pScanInfo->mScanPending)
4468 {
4469 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004470 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 }
4472
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304473 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004474 //Channel and action frame is pending
4475 //Otherwise Cancel Remain On Channel and allow Scan
4476 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004477 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004478 {
4479 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__);
4480 return -EBUSY;
4481 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004482#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004483 /* if tdls disagree scan right now, return immediately.
4484 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4485 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4486 */
4487 status = wlan_hdd_tdls_scan_callback (pAdapter,
4488 wiphy,
4489#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4490 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004491#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004492 request);
4493 if(status <= 0)
4494 {
4495 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4496 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004497 }
4498#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004499
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4501 {
4502 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004503 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4507 {
4508 hddLog(VOS_TRACE_LEVEL_WARN,
4509 "%s: MAX TM Level Scan not allowed", __func__);
4510 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304511 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 }
4513 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4514
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004515 /* Check if scan is allowed at this point of time.
4516 */
4517 if (!hdd_isScanAllowed(pHddCtx))
4518 {
4519 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4520 return -EBUSY;
4521 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304522
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4524
4525 if (NULL != request)
4526 {
4527 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304528 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004529
4530 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4531 * Becasue of this, driver is assuming that this is not wildcard scan and so
4532 * is not aging out the scan results.
4533 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004534 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 {
4536 request->n_ssids = 0;
4537 }
4538
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004539 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 {
4541 tCsrSSIDInfo *SsidInfo;
4542 int j;
4543 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4544 /* Allocate num_ssid tCsrSSIDInfo structure */
4545 SsidInfo = scanRequest.SSIDs.SSIDList =
4546 ( tCsrSSIDInfo *)vos_mem_malloc(
4547 request->n_ssids*sizeof(tCsrSSIDInfo));
4548
4549 if(NULL == scanRequest.SSIDs.SSIDList)
4550 {
4551 hddLog(VOS_TRACE_LEVEL_ERROR,
4552 "memory alloc failed SSIDInfo buffer");
4553 return -ENOMEM;
4554 }
4555
4556 /* copy all the ssid's and their length */
4557 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4558 {
4559 /* get the ssid length */
4560 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4561 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4562 SsidInfo->SSID.length);
4563 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4564 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4565 j, SsidInfo->SSID.ssId);
4566 }
4567 /* set the scan type to active */
4568 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4569 }
4570 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4571 {
4572 /* set the scan type to active */
4573 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4574 }
4575 else
4576 {
4577 /*Set the scan type to default type, in this case it is ACTIVE*/
4578 scanRequest.scanType = pScanInfo->scan_mode;
4579 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304580 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4582 }
4583 else
4584 {
4585 /* set the scan type to active */
4586 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4587 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4588
4589 /* set min and max channel time to zero */
4590 scanRequest.minChnTime = 0;
4591 scanRequest.maxChnTime = 0;
4592 }
4593
4594 /* set BSSType to default type */
4595 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4596
4597 /*TODO: scan the requested channels only*/
4598
4599 /*Right now scanning all the channels */
4600 if( request )
4601 {
4602 if( request->n_channels )
4603 {
4604 channelList = vos_mem_malloc( request->n_channels );
4605 if( NULL == channelList )
4606 {
4607 status = -ENOMEM;
4608 goto free_mem;
4609 }
4610
4611 for( i = 0 ; i < request->n_channels ; i++ )
4612 channelList[i] = request->channels[i]->hw_value;
4613 }
4614
4615 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4616 scanRequest.ChannelInfo.ChannelList = channelList;
4617
4618 /* set requestType to full scan */
4619 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304620
4621 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004622 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304623 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004624 */
4625
4626 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304627 * and in that case driver shoudnt flush scan results. If
4628 * driver flushes the scan results here and unfortunately if
4629 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004630 * fails which is not desired
4631 */
4632
4633 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4634 {
4635 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4636 pAdapter->sessionId );
4637 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004638
4639 if( request->ie_len )
4640 {
4641 /* save this for future association (join requires this) */
4642 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4643 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4644 pScanInfo->scanAddIE.length = request->ie_len;
4645
4646 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07004647 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4648 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 )
4650 {
4651 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
4652 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
4653 }
4654
4655 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
4656 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
4657
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
4659 request->ie_len);
4660 if (pP2pIe != NULL)
4661 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07004662#ifdef WLAN_FEATURE_P2P_DEBUG
4663 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
4664 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
4665 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4666 {
4667 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
4668 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4669 "Go nego completed to Connection is started");
4670 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4671 "for 8way Handshake");
4672 }
4673 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
4674 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4675 {
4676 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
4677 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4678 "Disconnected state to Connection is started");
4679 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4680 "for 4way Handshake");
4681 }
4682#endif
4683
Jeff Johnsone7245742012-09-05 17:12:55 -07004684 /* no_cck will be set during p2p find to disable 11b rates */
4685 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004687 hddLog(VOS_TRACE_LEVEL_INFO,
4688 "%s: This is a P2P Search", __func__);
4689 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07004690
Jeff Johnsone7245742012-09-05 17:12:55 -07004691 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
4692 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07004693 /* set requestType to P2P Discovery */
4694 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07004695 }
4696
4697 /*
4698 Skip Dfs Channel in case of P2P Search
4699 if it is set in ini file
4700 */
4701 if(cfg_param->skipDfsChnlInP2pSearch)
4702 {
4703 scanRequest.skipDfsChnlInP2pSearch = 1;
4704 }
4705 else
4706 {
4707 scanRequest.skipDfsChnlInP2pSearch = 0;
4708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004709
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 }
4711 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 }
4713 }
4714
4715 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
4716
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004717 /* acquire the wakelock to avoid the apps suspend during the scan. To
4718 * address the following issues.
4719 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
4720 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
4721 * for long time, this result in apps running at full power for long time.
4722 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
4723 * be stuck in full power because of resume BMPS
4724 */
4725 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004726
4727 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 pAdapter->sessionId, &scanRequest, &scanId,
4729 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07004730
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 if (eHAL_STATUS_SUCCESS != status)
4732 {
4733 hddLog(VOS_TRACE_LEVEL_ERROR,
4734 "%s: sme_ScanRequest returned error %d", __func__, status);
4735 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07004736 if(eHAL_STATUS_RESOURCES == status)
4737 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07004738 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 -07004739 status = -EBUSY;
4740 } else {
4741 status = -EIO;
4742 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004743 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 goto free_mem;
4745 }
4746
4747 pScanInfo->mScanPending = TRUE;
4748 pAdapter->request = request;
4749 pScanInfo->scanId = scanId;
4750
4751 complete(&pScanInfo->scan_req_completion_event);
4752
4753free_mem:
4754 if( scanRequest.SSIDs.SSIDList )
4755 {
4756 vos_mem_free(scanRequest.SSIDs.SSIDList);
4757 }
4758
4759 if( channelList )
4760 vos_mem_free( channelList );
4761
4762 EXIT();
4763
4764 return status;
4765}
4766
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004767
4768void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
4769{
4770 v_U8_t iniDot11Mode =
4771 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
4772 eHddDot11Mode hddDot11Mode = iniDot11Mode;
4773
4774 switch ( iniDot11Mode )
4775 {
4776 case eHDD_DOT11_MODE_AUTO:
4777 case eHDD_DOT11_MODE_11ac:
4778 case eHDD_DOT11_MODE_11ac_ONLY:
4779#ifdef WLAN_FEATURE_11AC
4780 hddDot11Mode = eHDD_DOT11_MODE_11ac;
4781#else
4782 hddDot11Mode = eHDD_DOT11_MODE_11n;
4783#endif
4784 break;
4785 case eHDD_DOT11_MODE_11n:
4786 case eHDD_DOT11_MODE_11n_ONLY:
4787 hddDot11Mode = eHDD_DOT11_MODE_11n;
4788 break;
4789 default:
4790 hddDot11Mode = iniDot11Mode;
4791 break;
4792 }
4793 /* This call decides required channel bonding mode */
4794 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
4795 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
4796 operationChannel);
4797}
4798
Jeff Johnson295189b2012-06-20 16:38:30 -07004799/*
4800 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304801 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304803int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004804 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07004805{
4806 int status = 0;
4807 hdd_wext_state_t *pWextState;
4808 v_U32_t roamId;
4809 tCsrRoamProfile *pRoamProfile;
4810 eMib_dot11DesiredBssType connectedBssType;
4811 eCsrAuthType RSNAuthType;
4812
4813 ENTER();
4814
4815 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304816
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
4818 {
4819 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
4820 return -EINVAL;
4821 }
4822
4823 pRoamProfile = &pWextState->roamProfile;
4824
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304825 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004827 int ret = 0;
4828 hdd_station_ctx_t *pHddStaCtx;
4829 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4830 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
4831
4832 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
4833 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
4834 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 {
4836 /* Issue disconnect to CSR */
4837 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304838 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
4840 pAdapter->sessionId,
4841 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
4842 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004843 ret = wait_for_completion_interruptible_timeout(
4844 &pAdapter->disconnect_comp_var,
4845 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4846 if (0 == ret)
4847 {
4848 VOS_ASSERT(0);
4849 }
4850 }
4851 }
4852 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
4853 {
4854 ret = wait_for_completion_interruptible_timeout(
4855 &pAdapter->disconnect_comp_var,
4856 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4857 if (0 == ret)
4858 {
4859 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004860 }
4861 }
4862
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304863 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07004864 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
4865 {
4866 /*QoS not enabled in cfg file*/
4867 pRoamProfile->uapsd_mask = 0;
4868 }
4869 else
4870 {
4871 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304872 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
4874 }
4875
4876 pRoamProfile->SSIDs.numOfSSIDs = 1;
4877 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
4878 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304879 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
4881 ssid, ssid_len);
4882
4883 if (bssid)
4884 {
4885 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
4886 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
4887 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304888 /* Save BSSID in seperate variable as well, as RoamProfile
4889 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 case of join failure we should send valid BSSID to supplicant
4891 */
4892 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
4893 WNI_CFG_BSSID_LEN);
4894 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004895 else
4896 {
4897 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
4898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004899
4900 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
4901 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304902 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 /*set gen ie*/
4904 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4905 /*set auth*/
4906 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4907 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004908#ifdef FEATURE_WLAN_WAPI
4909 if (pAdapter->wapi_info.nWapiMode)
4910 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004911 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004912 switch (pAdapter->wapi_info.wapiAuthMode)
4913 {
4914 case WAPI_AUTH_MODE_PSK:
4915 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004916 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 pAdapter->wapi_info.wapiAuthMode);
4918 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4919 break;
4920 }
4921 case WAPI_AUTH_MODE_CERT:
4922 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004923 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 pAdapter->wapi_info.wapiAuthMode);
4925 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4926 break;
4927 }
4928 } // End of switch
4929 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4930 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4931 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004932 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 pRoamProfile->AuthType.numEntries = 1;
4934 pRoamProfile->EncryptionType.numEntries = 1;
4935 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4936 pRoamProfile->mcEncryptionType.numEntries = 1;
4937 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4938 }
4939 }
4940#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05304941#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05304942 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05304943 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4944 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4945 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05304946 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
4947 sizeof (tSirGtkOffloadParams));
4948 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05304949 }
4950#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 pRoamProfile->csrPersona = pAdapter->device_mode;
4952
Jeff Johnson32d95a32012-09-10 13:15:23 -07004953 if( operatingChannel )
4954 {
4955 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
4956 pRoamProfile->ChannelInfo.numOfChannels = 1;
4957 }
Chet Lanctot186b5732013-03-18 10:26:30 -07004958 else
4959 {
4960 pRoamProfile->ChannelInfo.ChannelList = NULL;
4961 pRoamProfile->ChannelInfo.numOfChannels = 0;
4962 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004963 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
4964 {
4965 hdd_select_cbmode(pAdapter,operatingChannel);
4966 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004967 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
4968 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304969 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004970 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08004971 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
4972 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05304973 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4974 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08004975 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4976 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304977
4978 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 pAdapter->sessionId, pRoamProfile, &roamId);
4980
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05304981 if ((eHAL_STATUS_SUCCESS != status) &&
4982 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4983 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05304984
4985 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004986 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
4987 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
4988 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05304989 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004990 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05304991 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08004992
4993 pRoamProfile->ChannelInfo.ChannelList = NULL;
4994 pRoamProfile->ChannelInfo.numOfChannels = 0;
4995
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 }
4997 else
4998 {
4999 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5000 return -EINVAL;
5001 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005002 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 return status;
5004}
5005
5006/*
5007 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5008 * This function is used to set the authentication type (OPEN/SHARED).
5009 *
5010 */
5011static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5012 enum nl80211_auth_type auth_type)
5013{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305014 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5016
5017 ENTER();
5018
5019 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305020 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305023 hddLog(VOS_TRACE_LEVEL_INFO,
5024 "%s: set authentication type to AUTOSWITCH", __func__);
5025 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5026 break;
5027
5028 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005029#ifdef WLAN_FEATURE_VOWIFI_11R
5030 case NL80211_AUTHTYPE_FT:
5031#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305032 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 "%s: set authentication type to OPEN", __func__);
5034 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5035 break;
5036
5037 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305038 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 "%s: set authentication type to SHARED", __func__);
5040 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5041 break;
5042#ifdef FEATURE_WLAN_CCX
5043 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305044 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 "%s: set authentication type to CCKM WPA", __func__);
5046 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5047 break;
5048#endif
5049
5050
5051 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305052 hddLog(VOS_TRACE_LEVEL_ERROR,
5053 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 auth_type);
5055 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5056 return -EINVAL;
5057 }
5058
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305059 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005060 pHddStaCtx->conn_info.authType;
5061 return 0;
5062}
5063
5064/*
5065 * FUNCTION: wlan_hdd_set_akm_suite
5066 * This function is used to set the key mgmt type(PSK/8021x).
5067 *
5068 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305069static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 u32 key_mgmt
5071 )
5072{
5073 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5074 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305075
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 /*set key mgmt type*/
5077 switch(key_mgmt)
5078 {
5079 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305080#ifdef WLAN_FEATURE_VOWIFI_11R
5081 case WLAN_AKM_SUITE_FT_PSK:
5082#endif
5083 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 __func__);
5085 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5086 break;
5087
5088 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305089#ifdef WLAN_FEATURE_VOWIFI_11R
5090 case WLAN_AKM_SUITE_FT_8021X:
5091#endif
5092 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005093 __func__);
5094 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5095 break;
5096#ifdef FEATURE_WLAN_CCX
5097#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5098#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5099 case WLAN_AKM_SUITE_CCKM:
5100 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5101 __func__);
5102 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5103 break;
5104#endif
5105
5106 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305107 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 __func__, key_mgmt);
5109 return -EINVAL;
5110
5111 }
5112 return 0;
5113}
5114
5115/*
5116 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305117 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 * (NONE/WEP40/WEP104/TKIP/CCMP).
5119 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305120static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5121 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005122 bool ucast
5123 )
5124{
5125 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305126 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005127 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5128
5129 ENTER();
5130
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305131 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005132 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305133 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005134 __func__, cipher);
5135 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5136 }
5137 else
5138 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305139
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305141 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 {
5143 case IW_AUTH_CIPHER_NONE:
5144 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5145 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305146
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305148 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005149 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305150
Jeff Johnson295189b2012-06-20 16:38:30 -07005151 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305152 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305154
Jeff Johnson295189b2012-06-20 16:38:30 -07005155 case WLAN_CIPHER_SUITE_TKIP:
5156 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5157 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305158
Jeff Johnson295189b2012-06-20 16:38:30 -07005159 case WLAN_CIPHER_SUITE_CCMP:
5160 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5161 break;
5162#ifdef FEATURE_WLAN_WAPI
5163 case WLAN_CIPHER_SUITE_SMS4:
5164 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5165 break;
5166#endif
5167
5168#ifdef FEATURE_WLAN_CCX
5169 case WLAN_CIPHER_SUITE_KRK:
5170 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5171 break;
5172#endif
5173 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305174 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005175 __func__, cipher);
5176 return -EOPNOTSUPP;
5177 }
5178 }
5179
5180 if (ucast)
5181 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305182 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005183 __func__, encryptionType);
5184 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5185 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305186 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005187 encryptionType;
5188 }
5189 else
5190 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305191 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 __func__, encryptionType);
5193 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5194 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5195 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5196 }
5197
5198 return 0;
5199}
5200
5201
5202/*
5203 * FUNCTION: wlan_hdd_cfg80211_set_ie
5204 * This function is used to parse WPA/RSN IE's.
5205 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305206int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5207 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 size_t ie_len
5209 )
5210{
5211 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5212 u8 *genie = ie;
5213 v_U16_t remLen = ie_len;
5214#ifdef FEATURE_WLAN_WAPI
5215 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5216 u16 *tmp;
5217 v_U16_t akmsuiteCount;
5218 int *akmlist;
5219#endif
5220 ENTER();
5221
5222 /* clear previous assocAddIE */
5223 pWextState->assocAddIE.length = 0;
5224 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5225
5226 while (remLen >= 2)
5227 {
5228 v_U16_t eLen = 0;
5229 v_U8_t elementId;
5230 elementId = *genie++;
5231 eLen = *genie++;
5232 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305233
5234 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305236
5237 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305239 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005240 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 -07005241 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305242 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 "%s: Invalid WPA IE", __func__);
5244 return -EINVAL;
5245 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305246 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005247 {
5248 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305249 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005250 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305251
Jeff Johnson295189b2012-06-20 16:38:30 -07005252 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5253 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005254 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5255 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 VOS_ASSERT(0);
5257 return -ENOMEM;
5258 }
5259 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5260 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5261 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305262
Jeff Johnson295189b2012-06-20 16:38:30 -07005263 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5264 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5265 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5266 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305267 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5268 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5270 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5271 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5272 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5273 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5274 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305275 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
5276 P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005277 /*Consider P2P IE, only for P2P Client */
5278 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5279 {
5280 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305281 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305283
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5285 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005286 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5287 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 VOS_ASSERT(0);
5289 return -ENOMEM;
5290 }
5291 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5292 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5293 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305294
Jeff Johnson295189b2012-06-20 16:38:30 -07005295 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5296 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005298#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305299 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5300 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005301 /*Consider WFD IE, only for P2P Client */
5302 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5303 {
5304 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305305 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005306 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305307
Jeff Johnson295189b2012-06-20 16:38:30 -07005308 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5309 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005310 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5311 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005312 VOS_ASSERT(0);
5313 return -ENOMEM;
5314 }
5315 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5316 // WPS IE + P2P IE + WFD IE
5317 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5318 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305319
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5321 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5322 }
5323#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005324 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305325 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005326 HS20_OUI_TYPE_SIZE)) )
5327 {
5328 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305329 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005330 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005331
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005332 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5333 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005334 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5335 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005336 VOS_ASSERT(0);
5337 return -ENOMEM;
5338 }
5339 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5340 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005341
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005342 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5343 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5344 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005345
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 break;
5347 case DOT11F_EID_RSN:
5348 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5349 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5350 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5351 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5352 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5353 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005354 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5355 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305356 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005357 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305358 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005359 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305360
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005361 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5362 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005363 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5364 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005365 VOS_ASSERT(0);
5366 return -ENOMEM;
5367 }
5368 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5369 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305370
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005371 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5372 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5373 break;
5374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005375#ifdef FEATURE_WLAN_WAPI
5376 case WLAN_EID_WAPI:
5377 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
5378 hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n",
5379 pAdapter->wapi_info.nWapiMode);
5380 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305381 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 akmsuiteCount = WPA_GET_LE16(tmp);
5383 tmp = tmp + 1;
5384 akmlist = (int *)(tmp);
5385 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5386 {
5387 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5388 }
5389 else
5390 {
5391 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5392 VOS_ASSERT(0);
5393 return -EINVAL;
5394 }
5395
5396 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5397 {
5398 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005399 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005400 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305401 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305403 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005404 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005405 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005406 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5407 }
5408 break;
5409#endif
5410 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305411 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005413 /* when Unknown IE is received we should break and continue
5414 * to the next IE in the buffer instead we were returning
5415 * so changing this to break */
5416 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 }
5418 genie += eLen;
5419 remLen -= eLen;
5420 }
5421 EXIT();
5422 return 0;
5423}
5424
5425/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305426 * FUNCTION: hdd_isWPAIEPresent
5427 * Parse the received IE to find the WPA IE
5428 *
5429 */
5430static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5431{
5432 v_U8_t eLen = 0;
5433 v_U16_t remLen = ie_len;
5434 v_U8_t elementId = 0;
5435
5436 while (remLen >= 2)
5437 {
5438 elementId = *ie++;
5439 eLen = *ie++;
5440 remLen -= 2;
5441 if (eLen > remLen)
5442 {
5443 hddLog(VOS_TRACE_LEVEL_ERROR,
5444 "%s: IE length is wrong %d", __func__, eLen);
5445 return FALSE;
5446 }
5447 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5448 {
5449 /* OUI - 0x00 0X50 0XF2
5450 WPA Information Element - 0x01
5451 WPA version - 0x01*/
5452 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5453 return TRUE;
5454 }
5455 ie += eLen;
5456 remLen -= eLen;
5457 }
5458 return FALSE;
5459}
5460
5461/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305463 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 * parameters during connect operation.
5465 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305466int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 struct cfg80211_connect_params *req
5468 )
5469{
5470 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305471 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 ENTER();
5473
5474 /*set wpa version*/
5475 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5476
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305477 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305479 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005480 {
5481 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5482 }
5483 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5484 {
5485 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5486 }
5487 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305488
5489 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 pWextState->wpaVersion);
5491
5492 /*set authentication type*/
5493 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5494
5495 if (0 > status)
5496 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305497 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 "%s: failed to set authentication type ", __func__);
5499 return status;
5500 }
5501
5502 /*set key mgmt type*/
5503 if (req->crypto.n_akm_suites)
5504 {
5505 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5506 if (0 > status)
5507 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305508 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 __func__);
5510 return status;
5511 }
5512 }
5513
5514 /*set pairwise cipher type*/
5515 if (req->crypto.n_ciphers_pairwise)
5516 {
5517 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5518 req->crypto.ciphers_pairwise[0], true);
5519 if (0 > status)
5520 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305521 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005522 "%s: failed to set unicast cipher type", __func__);
5523 return status;
5524 }
5525 }
5526 else
5527 {
5528 /*Reset previous cipher suite to none*/
5529 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5530 if (0 > status)
5531 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305532 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 "%s: failed to set unicast cipher type", __func__);
5534 return status;
5535 }
5536 }
5537
5538 /*set group cipher type*/
5539 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
5540 false);
5541
5542 if (0 > status)
5543 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305544 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 __func__);
5546 return status;
5547 }
5548
Chet Lanctot186b5732013-03-18 10:26:30 -07005549#ifdef WLAN_FEATURE_11W
5550 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
5551#endif
5552
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
5554 if (req->ie_len)
5555 {
5556 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
5557 if ( 0 > status)
5558 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305559 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07005560 __func__);
5561 return status;
5562 }
5563 }
5564
5565 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305566 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 {
5568 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
5569 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
5570 )
5571 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305572 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07005573 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5574 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305575 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 __func__);
5577 return -EOPNOTSUPP;
5578 }
5579 else
5580 {
5581 u8 key_len = req->key_len;
5582 u8 key_idx = req->key_idx;
5583
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305584 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005585 && (CSR_MAX_NUM_KEY > key_idx)
5586 )
5587 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305588 hddLog(VOS_TRACE_LEVEL_INFO,
5589 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 __func__, key_idx, key_len);
5591 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305592 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305594 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 (u8)key_len;
5596 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
5597 }
5598 }
5599 }
5600 }
5601
5602 return status;
5603}
5604
5605/*
5606 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305607 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005608 * parameters during connect operation.
5609 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305610static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005611 struct net_device *ndev,
5612 struct cfg80211_connect_params *req
5613 )
5614{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305615 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305616 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
5618 hdd_context_t *pHddCtx = NULL;
5619
5620 ENTER();
5621
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305622 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
5624
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305625 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5626 status = wlan_hdd_validate_context(pHddCtx);
5627
5628 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005629 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305630 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5631 "%s: HDD context is not valid", __func__);
5632 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 }
5634
5635#ifdef WLAN_BTAMP_FEATURE
5636 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305637 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07005638 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305639 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08005641 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 }
5643#endif
5644 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305645 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07005646
5647 if ( 0 > status)
5648 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305649 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 __func__);
5651 return status;
5652 }
5653
5654 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005655 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
5657 (vos_concurrent_sessions_running()))
5658 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305659 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 }
5661
Mohit Khanna765234a2012-09-11 15:08:35 -07005662 if ( req->channel )
5663 {
5664 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
5665 req->ssid_len, req->bssid,
5666 req->channel->hw_value);
5667 }
5668 else
5669 {
5670 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305671 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07005672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005673
5674 if (0 > status)
5675 {
5676 //ReEnable BMPS if disabled
5677 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
5678 (NULL != pHddCtx))
5679 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05305680 if (pHddCtx->hdd_wlan_suspended)
5681 {
5682 hdd_set_pwrparams(pHddCtx);
5683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 //ReEnable Bmps and Imps back
5685 hdd_enable_bmps_imps(pHddCtx);
5686 }
5687
5688 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
5689 return status;
5690 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305691 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 EXIT();
5693 return status;
5694}
5695
5696
5697/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305698 * FUNCTION: wlan_hdd_disconnect
5699 * This function is used to issue a disconnect request to SME
5700 */
5701int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
5702{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305703 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305704 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305705 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5706
5707 status = wlan_hdd_validate_context(pHddCtx);
5708
5709 if (0 != status)
5710 {
5711 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5712 "%s: HDD context is not valid", __func__);
5713 return status;
5714 }
5715
5716 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305717 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305718 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305719
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305720 /*issue disconnect*/
5721 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5722 pAdapter->sessionId, reason);
5723
5724 if ( 0 != status )
5725 {
5726 hddLog(VOS_TRACE_LEVEL_ERROR,
5727 "%s csrRoamDisconnect failure, returned %d \n",
5728 __func__, (int)status );
5729 return -EINVAL;
5730 }
5731 wait_for_completion_interruptible_timeout(
5732 &pAdapter->disconnect_comp_var,
5733 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5734 /*stop tx queues*/
5735 netif_tx_disable(pAdapter->dev);
5736 netif_carrier_off(pAdapter->dev);
5737 return status;
5738}
5739
5740
5741/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 * FUNCTION: wlan_hdd_cfg80211_disconnect
5743 * This function is used to issue a disconnect request to SME
5744 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305745static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 struct net_device *dev,
5747 u16 reason
5748 )
5749{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305750 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
5751 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305753 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005755 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05305756#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005757 tANI_U8 staIdx;
5758#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305759
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305761
5762 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 __func__,pAdapter->device_mode);
5764
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305765 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
5766 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005767
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305768 status = wlan_hdd_validate_context(pHddCtx);
5769
5770 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305772 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5773 "%s: HDD context is not valid", __func__);
5774 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305776
Jeff Johnson295189b2012-06-20 16:38:30 -07005777 if (NULL != pRoamProfile)
5778 {
5779 /*issue disconnect request to SME, if station is in connected state*/
5780 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
5781 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305782 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05305784 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 switch(reason)
5786 {
5787 case WLAN_REASON_MIC_FAILURE:
5788 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
5789 break;
5790
5791 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
5792 case WLAN_REASON_DISASSOC_AP_BUSY:
5793 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
5794 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
5795 break;
5796
5797 case WLAN_REASON_PREV_AUTH_NOT_VALID:
5798 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
5799 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
5800 break;
5801
5802 case WLAN_REASON_DEAUTH_LEAVING:
5803 default:
5804 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5805 break;
5806 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05305807 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
5808 pScanInfo = &pHddCtx->scan_info;
5809 if (pScanInfo->mScanPending)
5810 {
5811 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
5812 "Aborting Scan");
5813 hdd_abort_mac_scan(pHddCtx);
5814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005815
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005816#ifdef FEATURE_WLAN_TDLS
5817 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005818 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005819 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005820 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
5821 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005822 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08005823 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005824 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08005825 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07005826 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005827 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07005828 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005829 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005830 pAdapter->sessionId,
5831 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005832 }
5833 }
5834#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305835 status = wlan_hdd_disconnect(pAdapter, reasonCode);
5836 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 {
5838 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305839 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 __func__, (int)status );
5841 return -EINVAL;
5842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 }
5844 }
5845 else
5846 {
5847 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
5848 }
5849
5850 return status;
5851}
5852
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305853
Jeff Johnson295189b2012-06-20 16:38:30 -07005854/*
5855 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305856 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 * settings in IBSS mode.
5858 */
5859static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305860 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 struct cfg80211_ibss_params *params
5862 )
5863{
5864 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305865 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5867 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305868
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 ENTER();
5870
5871 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5872
5873 if (params->ie_len && ( NULL != params->ie) )
5874 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005875 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
5876 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 {
5878 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5879 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5880 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005881 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005883 tDot11fIEWPA dot11WPAIE;
5884 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005885 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005886
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005887 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
5888 params->ie_len, DOT11F_EID_WPA);
5889 if ( NULL != ie )
5890 {
5891 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5892 // Unpack the WPA IE
5893 //Skip past the EID byte and length byte - and four byte WiFi OUI
5894 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
5895 &ie[2+4],
5896 ie[1] - 4,
5897 &dot11WPAIE);
5898 /*Extract the multicast cipher, the encType for unicast
5899 cipher for wpa-none is none*/
5900 encryptionType =
5901 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
5902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005903 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005904
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
5906
5907 if (0 > status)
5908 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305909 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 __func__);
5911 return status;
5912 }
5913 }
5914
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305915 pWextState->roamProfile.AuthType.authType[0] =
5916 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07005917 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5918
5919 if (params->privacy)
5920 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305921 /* Security enabled IBSS, At this time there is no information available
5922 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305924 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305926 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 *enable privacy bit in beacons */
5928
5929 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5930 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005931 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
5932 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5934 pWextState->roamProfile.EncryptionType.numEntries = 1;
5935 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 return status;
5937}
5938
5939/*
5940 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305941 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305943static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 struct net_device *dev,
5945 struct cfg80211_ibss_params *params
5946 )
5947{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305948 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5950 tCsrRoamProfile *pRoamProfile;
5951 int status;
5952 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305953 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005954
5955 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305956
5957 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
5959
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305960 status = wlan_hdd_validate_context(pHddCtx);
5961
5962 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305964 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5965 "%s: HDD context is not valid", __func__);
5966 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 }
5968
5969 if (NULL == pWextState)
5970 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305971 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 __func__);
5973 return -EIO;
5974 }
5975
5976 pRoamProfile = &pWextState->roamProfile;
5977
5978 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
5979 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305980 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 "%s Interface type is not set to IBSS \n", __func__);
5982 return -EINVAL;
5983 }
5984
5985 /* Set Channel */
5986 if (NULL != params->channel)
5987 {
5988 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005989 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
5990 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
5991 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5992 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005993
5994 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305995 channelNum =
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 ieee80211_frequency_to_channel(params->channel->center_freq);
5997
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005998
5999 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6000 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006001 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006002 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6003 __func__);
6004 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006006
6007 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006009 if (channelNum == validChan[indx])
6010 {
6011 break;
6012 }
6013 }
6014 if (indx >= numChans)
6015 {
6016 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 __func__, channelNum);
6018 return -EINVAL;
6019 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006020 /* Set the Operational Channel */
6021 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6022 channelNum);
6023 pRoamProfile->ChannelInfo.numOfChannels = 1;
6024 pHddStaCtx->conn_info.operationChannel = channelNum;
6025 pRoamProfile->ChannelInfo.ChannelList =
6026 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 }
6028
6029 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306030 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 if (status < 0)
6032 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306033 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 __func__);
6035 return status;
6036 }
6037
6038 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306039 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006040 params->ssid_len, params->bssid,
6041 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006042
6043 if (0 > status)
6044 {
6045 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6046 return status;
6047 }
6048
6049 return 0;
6050}
6051
6052/*
6053 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306054 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306056static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006057 struct net_device *dev
6058 )
6059{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306060 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6062 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306063 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6064 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006065
6066 ENTER();
6067
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306068 status = wlan_hdd_validate_context(pHddCtx);
6069
6070 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006071 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306072 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6073 "%s: HDD context is not valid", __func__);
6074 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006075 }
6076
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6078 if (NULL == pWextState)
6079 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306080 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006081 __func__);
6082 return -EIO;
6083 }
6084
6085 pRoamProfile = &pWextState->roamProfile;
6086
6087 /* Issue disconnect only if interface type is set to IBSS */
6088 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6089 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306090 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 __func__);
6092 return -EINVAL;
6093 }
6094
6095 /* Issue Disconnect request */
6096 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6097 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6098 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6099
6100 return 0;
6101}
6102
6103/*
6104 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6105 * This function is used to set the phy parameters
6106 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6107 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306108static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 u32 changed)
6110{
6111 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6112 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306113 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006114
6115 ENTER();
6116
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306117 status = wlan_hdd_validate_context(pHddCtx);
6118
6119 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006120 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306121 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6122 "%s: HDD context is not valid", __func__);
6123 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006124 }
6125
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6127 {
6128 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6129 WNI_CFG_RTS_THRESHOLD_STAMAX :
6130 wiphy->rts_threshold;
6131
6132 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306133 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306135 hddLog(VOS_TRACE_LEVEL_ERROR,
6136 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006137 __func__, rts_threshold);
6138 return -EINVAL;
6139 }
6140
6141 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6142 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306143 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006144 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306145 hddLog(VOS_TRACE_LEVEL_ERROR,
6146 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 __func__, rts_threshold);
6148 return -EIO;
6149 }
6150
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306151 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 rts_threshold);
6153 }
6154
6155 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6156 {
6157 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6158 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6159 wiphy->frag_threshold;
6160
6161 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306162 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306164 hddLog(VOS_TRACE_LEVEL_ERROR,
6165 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 frag_threshold);
6167 return -EINVAL;
6168 }
6169
6170 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6171 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306172 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306174 hddLog(VOS_TRACE_LEVEL_ERROR,
6175 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006176 __func__, frag_threshold);
6177 return -EIO;
6178 }
6179
6180 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6181 frag_threshold);
6182 }
6183
6184 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6185 || (changed & WIPHY_PARAM_RETRY_LONG))
6186 {
6187 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6188 wiphy->retry_short :
6189 wiphy->retry_long;
6190
6191 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6192 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6193 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306194 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006195 __func__, retry_value);
6196 return -EINVAL;
6197 }
6198
6199 if (changed & WIPHY_PARAM_RETRY_SHORT)
6200 {
6201 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6202 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306203 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306205 hddLog(VOS_TRACE_LEVEL_ERROR,
6206 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 __func__, retry_value);
6208 return -EIO;
6209 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306210 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 __func__, retry_value);
6212 }
6213 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6214 {
6215 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6216 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306217 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306219 hddLog(VOS_TRACE_LEVEL_ERROR,
6220 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 __func__, retry_value);
6222 return -EIO;
6223 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306224 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 __func__, retry_value);
6226 }
6227 }
6228
6229 return 0;
6230}
6231
6232/*
6233 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6234 * This function is used to set the txpower
6235 */
6236static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
6237#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306238 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006239#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306240 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006241#endif
6242 int dbm)
6243{
6244 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306245 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6247 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306248 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006249
6250 ENTER();
6251
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306252 status = wlan_hdd_validate_context(pHddCtx);
6253
6254 if (0 != status)
6255 {
6256 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6257 "%s: HDD context is not valid", __func__);
6258 return status;
6259 }
6260
6261 hHal = pHddCtx->hHal;
6262
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306263 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6264 dbm, ccmCfgSetCallback,
6265 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306267 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006268 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6269 return -EIO;
6270 }
6271
6272 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6273 dbm);
6274
6275 switch(type)
6276 {
6277 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6278 /* Fall through */
6279 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6280 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6281 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306282 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6283 __func__);
6284 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 }
6286 break;
6287 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306288 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006289 __func__);
6290 return -EOPNOTSUPP;
6291 break;
6292 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306293 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6294 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 return -EIO;
6296 }
6297
6298 return 0;
6299}
6300
6301/*
6302 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6303 * This function is used to read the txpower
6304 */
6305static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm)
6306{
6307
6308 hdd_adapter_t *pAdapter;
6309 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306310 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006311
Jeff Johnsone7245742012-09-05 17:12:55 -07006312 ENTER();
6313
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306314 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006315
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306316 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006317 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306318 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6319 "%s: HDD context is not valid", __func__);
6320 *dbm = 0;
6321 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006322 }
6323
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6325 if (NULL == pAdapter)
6326 {
6327 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6328 return -ENOENT;
6329 }
6330
6331 wlan_hdd_get_classAstats(pAdapter);
6332 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6333
Jeff Johnsone7245742012-09-05 17:12:55 -07006334 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 return 0;
6336}
6337
6338static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6339 u8* mac, struct station_info *sinfo)
6340{
6341 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6342 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6343 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6344 tANI_U8 rate_flags;
6345
6346 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6347 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006348
6349 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6350 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6351 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6352 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6353 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6354 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6355 tANI_U16 maxRate = 0;
6356 tANI_U16 myRate;
6357 tANI_U16 currentRate = 0;
6358 tANI_U8 maxSpeedMCS = 0;
6359 tANI_U8 maxMCSIdx = 0;
6360 tANI_U8 rateFlag = 1;
6361 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006362 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306363 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006364
Leo Chang6f8870f2013-03-26 18:11:36 -07006365#ifdef WLAN_FEATURE_11AC
6366 tANI_U32 vht_mcs_map;
6367 eDataRate11ACMaxMcs vhtMaxMcs;
6368#endif /* WLAN_FEATURE_11AC */
6369
Jeff Johnsone7245742012-09-05 17:12:55 -07006370 ENTER();
6371
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6373 (0 == ssidlen))
6374 {
6375 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6376 " Invalid ssidlen, %d", __func__, ssidlen);
6377 /*To keep GUI happy*/
6378 return 0;
6379 }
6380
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306381 status = wlan_hdd_validate_context(pHddCtx);
6382
6383 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006384 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306385 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6386 "%s: HDD context is not valid", __func__);
6387 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006388 }
6389
Jeff Johnson295189b2012-06-20 16:38:30 -07006390 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6391 sinfo->filled |= STATION_INFO_SIGNAL;
6392
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006393 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006394 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6395
6396 //convert to the UI units of 100kbps
6397 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6398
6399#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006400 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 -07006401 sinfo->signal,
6402 pCfg->reportMaxLinkSpeed,
6403 myRate,
6404 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006405 (int) pCfg->linkSpeedRssiMid,
6406 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006407 (int) rate_flags,
6408 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006409#endif //LINKSPEED_DEBUG_ENABLED
6410
6411 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6412 {
6413 // we do not want to necessarily report the current speed
6414 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6415 {
6416 // report the max possible speed
6417 rssidx = 0;
6418 }
6419 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6420 {
6421 // report the max possible speed with RSSI scaling
6422 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6423 {
6424 // report the max possible speed
6425 rssidx = 0;
6426 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006427 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006428 {
6429 // report middle speed
6430 rssidx = 1;
6431 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006432 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6433 {
6434 // report middle speed
6435 rssidx = 2;
6436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 else
6438 {
6439 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006440 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 }
6442 }
6443 else
6444 {
6445 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6446 hddLog(VOS_TRACE_LEVEL_ERROR,
6447 "%s: Invalid value for reportMaxLinkSpeed: %u",
6448 __func__, pCfg->reportMaxLinkSpeed);
6449 rssidx = 0;
6450 }
6451
6452 maxRate = 0;
6453
6454 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306455 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6456 OperationalRates, &ORLeng))
6457 {
6458 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6459 /*To keep GUI happy*/
6460 return 0;
6461 }
6462
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 for (i = 0; i < ORLeng; i++)
6464 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006465 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006466 {
6467 /* Validate Rate Set */
6468 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6469 {
6470 currentRate = supported_data_rate[j].supported_rate[rssidx];
6471 break;
6472 }
6473 }
6474 /* Update MAX rate */
6475 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6476 }
6477
6478 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306479 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
6480 ExtendedRates, &ERLeng))
6481 {
6482 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6483 /*To keep GUI happy*/
6484 return 0;
6485 }
6486
Jeff Johnson295189b2012-06-20 16:38:30 -07006487 for (i = 0; i < ERLeng; i++)
6488 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006489 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 {
6491 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
6492 {
6493 currentRate = supported_data_rate[j].supported_rate[rssidx];
6494 break;
6495 }
6496 }
6497 /* Update MAX rate */
6498 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 /* Get MCS Rate Set -- but only if we are connected at MCS
6501 rates or if we are always reporting max speed or if we have
6502 good rssi */
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006503 if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -07006504 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306505 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
6506 MCSRates, &MCSLeng))
6507 {
6508 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6509 /*To keep GUI happy*/
6510 return 0;
6511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07006513#ifdef WLAN_FEATURE_11AC
6514 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306515 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07006516 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006517 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306518 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07006519 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006521 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006522 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006523 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006525 maxMCSIdx = 7;
6526 }
6527 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
6528 {
6529 maxMCSIdx = 8;
6530 }
6531 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
6532 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306533 //VHT20 is supporting 0~8
6534 if (rate_flags & eHAL_TX_RATE_VHT20)
6535 maxMCSIdx = 8;
6536 else
6537 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07006538 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306539
6540 if (rate_flags & eHAL_TX_RATE_VHT80)
6541 {
6542 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
6543 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
6544 }
6545 else if (rate_flags & eHAL_TX_RATE_VHT40)
6546 {
6547 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
6548 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
6549 }
6550 else if (rate_flags & eHAL_TX_RATE_VHT20)
6551 {
6552 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
6553 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
6554 }
6555
Leo Chang6f8870f2013-03-26 18:11:36 -07006556 maxSpeedMCS = 1;
6557 if (currentRate > maxRate)
6558 {
6559 maxRate = currentRate;
6560 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306561
Leo Chang6f8870f2013-03-26 18:11:36 -07006562 }
6563 else
6564#endif /* WLAN_FEATURE_11AC */
6565 {
6566 if (rate_flags & eHAL_TX_RATE_HT40)
6567 {
6568 rateFlag |= 1;
6569 }
6570 if (rate_flags & eHAL_TX_RATE_SGI)
6571 {
6572 rateFlag |= 2;
6573 }
6574
6575 for (i = 0; i < MCSLeng; i++)
6576 {
6577 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
6578 for (j = 0; j < temp; j++)
6579 {
6580 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
6581 {
6582 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
6583 break;
6584 }
6585 }
6586 if ((j < temp) && (currentRate > maxRate))
6587 {
6588 maxRate = currentRate;
6589 maxSpeedMCS = 1;
6590 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
6591 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 }
6593 }
6594 }
6595
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306596 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
6597 {
6598 maxRate = myRate;
6599 maxSpeedMCS = 1;
6600 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6601 }
6602
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006604 if (((maxRate < myRate) && (0 == rssidx)) ||
6605 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 {
6607 maxRate = myRate;
6608 if (rate_flags & eHAL_TX_RATE_LEGACY)
6609 {
6610 maxSpeedMCS = 0;
6611 }
6612 else
6613 {
6614 maxSpeedMCS = 1;
6615 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6616 }
6617 }
6618
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306619 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 {
6621 sinfo->txrate.legacy = maxRate;
6622#ifdef LINKSPEED_DEBUG_ENABLED
6623 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
6624#endif //LINKSPEED_DEBUG_ENABLED
6625 }
6626 else
6627 {
6628 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07006629#ifdef WLAN_FEATURE_11AC
6630 sinfo->txrate.nss = 1;
6631 if (rate_flags & eHAL_TX_RATE_VHT80)
6632 {
6633 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306634 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07006635 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306636 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07006637 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306638 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6639 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6640 }
6641 else if (rate_flags & eHAL_TX_RATE_VHT20)
6642 {
6643 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6644 }
6645#endif /* WLAN_FEATURE_11AC */
6646 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
6647 {
6648 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
6649 if (rate_flags & eHAL_TX_RATE_HT40)
6650 {
6651 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6652 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006653 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 if (rate_flags & eHAL_TX_RATE_SGI)
6655 {
6656 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
6657 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306658
Jeff Johnson295189b2012-06-20 16:38:30 -07006659#ifdef LINKSPEED_DEBUG_ENABLED
6660 pr_info("Reporting MCS rate %d flags %x\n",
6661 sinfo->txrate.mcs,
6662 sinfo->txrate.flags );
6663#endif //LINKSPEED_DEBUG_ENABLED
6664 }
6665 }
6666 else
6667 {
6668 // report current rate instead of max rate
6669
6670 if (rate_flags & eHAL_TX_RATE_LEGACY)
6671 {
6672 //provide to the UI in units of 100kbps
6673 sinfo->txrate.legacy = myRate;
6674#ifdef LINKSPEED_DEBUG_ENABLED
6675 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
6676#endif //LINKSPEED_DEBUG_ENABLED
6677 }
6678 else
6679 {
6680 //must be MCS
6681 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07006682#ifdef WLAN_FEATURE_11AC
6683 sinfo->txrate.nss = 1;
6684 if (rate_flags & eHAL_TX_RATE_VHT80)
6685 {
6686 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6687 }
6688 else
6689#endif /* WLAN_FEATURE_11AC */
6690 {
6691 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
6692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 if (rate_flags & eHAL_TX_RATE_SGI)
6694 {
6695 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
6696 }
6697 if (rate_flags & eHAL_TX_RATE_HT40)
6698 {
6699 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6700 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006701#ifdef WLAN_FEATURE_11AC
6702 else if (rate_flags & eHAL_TX_RATE_VHT80)
6703 {
6704 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
6705 }
6706#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07006707#ifdef LINKSPEED_DEBUG_ENABLED
6708 pr_info("Reporting actual MCS rate %d flags %x\n",
6709 sinfo->txrate.mcs,
6710 sinfo->txrate.flags );
6711#endif //LINKSPEED_DEBUG_ENABLED
6712 }
6713 }
6714 sinfo->filled |= STATION_INFO_TX_BITRATE;
6715
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006716 sinfo->tx_packets =
6717 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
6718 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
6719 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
6720 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
6721
6722 sinfo->tx_retries =
6723 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
6724 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
6725 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
6726 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
6727
6728 sinfo->tx_failed =
6729 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
6730 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
6731 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
6732 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
6733
6734 sinfo->filled |=
6735 STATION_INFO_TX_PACKETS |
6736 STATION_INFO_TX_RETRIES |
6737 STATION_INFO_TX_FAILED;
6738
6739 EXIT();
6740 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006741}
6742
6743static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07006744 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07006745{
6746 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306747 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306749 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006750
Jeff Johnsone7245742012-09-05 17:12:55 -07006751 ENTER();
6752
Jeff Johnson295189b2012-06-20 16:38:30 -07006753 if (NULL == pAdapter)
6754 {
6755 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
6756 return -ENODEV;
6757 }
6758
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306759 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306760 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306761
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306762 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306763 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306764 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6765 "%s: HDD context is not valid", __func__);
6766 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306767 }
6768
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306769 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
6770 (TRUE == pHddCtx->hdd_wlan_suspended) &&
6771 (pHddCtx->cfg_ini->fhostArpOffload) &&
6772 (eConnectionState_Associated ==
6773 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6774 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306775 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306776 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6777 {
6778 hddLog(VOS_TRACE_LEVEL_INFO,
6779 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
6780 __func__, vos_status);
6781 }
6782 }
6783
Jeff Johnson295189b2012-06-20 16:38:30 -07006784 /**The get power cmd from the supplicant gets updated by the nl only
6785 *on successful execution of the function call
6786 *we are oppositely mapped w.r.t mode in the driver
6787 **/
6788 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
6789
Jeff Johnsone7245742012-09-05 17:12:55 -07006790 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006791 if (VOS_STATUS_E_FAILURE == vos_status)
6792 {
6793 return -EINVAL;
6794 }
6795 return 0;
6796}
6797
6798
6799#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
6800static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
6801 struct net_device *netdev,
6802 u8 key_index)
6803{
Jeff Johnsone7245742012-09-05 17:12:55 -07006804 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006805 return 0;
6806}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306807#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07006808
6809#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
6810static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
6811 struct net_device *dev,
6812 struct ieee80211_txq_params *params)
6813{
Jeff Johnsone7245742012-09-05 17:12:55 -07006814 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006815 return 0;
6816}
6817#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
6818static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
6819 struct ieee80211_txq_params *params)
6820{
Jeff Johnsone7245742012-09-05 17:12:55 -07006821 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 return 0;
6823}
6824#endif //LINUX_VERSION_CODE
6825
6826static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
6827 struct net_device *dev, u8 *mac)
6828{
6829 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306830 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006831 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306832 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006833 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006834
Jeff Johnsone7245742012-09-05 17:12:55 -07006835 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306836 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07006837 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306838 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006839 return -EINVAL;
6840 }
6841
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306842 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6843 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006844
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306845 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006846 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306847 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6848 "%s: HDD context is not valid", __func__);
6849 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006850 }
6851
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07006854 )
6855 {
6856 if( NULL == mac )
6857 {
6858 v_U16_t i;
6859 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
6860 {
6861 if(pAdapter->aStaInfo[i].isUsed)
6862 {
6863 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
6864 hddLog(VOS_TRACE_LEVEL_INFO,
6865 "%s: Delete STA with MAC::"
6866 "%02x:%02x:%02x:%02x:%02x:%02x",
6867 __func__,
6868 macAddr[0], macAddr[1], macAddr[2],
6869 macAddr[3], macAddr[4], macAddr[5]);
6870 hdd_softap_sta_deauth(pAdapter, macAddr);
6871 }
6872 }
6873 }
6874 else
6875 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006876
6877 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
6878 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6879 {
6880 hddLog(VOS_TRACE_LEVEL_INFO,
6881 "%s: Skip this DEL STA as this is not used::"
6882 "%02x:%02x:%02x:%02x:%02x:%02x",
6883 __func__,
6884 mac[0], mac[1], mac[2],
6885 mac[3], mac[4], mac[5]);
6886 return -ENOENT;
6887 }
6888
6889 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
6890 {
6891 hddLog(VOS_TRACE_LEVEL_INFO,
6892 "%s: Skip this DEL STA as deauth is in progress::"
6893 "%02x:%02x:%02x:%02x:%02x:%02x",
6894 __func__,
6895 mac[0], mac[1], mac[2],
6896 mac[3], mac[4], mac[5]);
6897 return -ENOENT;
6898 }
6899
6900 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
6901
Jeff Johnson295189b2012-06-20 16:38:30 -07006902 hddLog(VOS_TRACE_LEVEL_INFO,
6903 "%s: Delete STA with MAC::"
6904 "%02x:%02x:%02x:%02x:%02x:%02x",
6905 __func__,
6906 mac[0], mac[1], mac[2],
6907 mac[3], mac[4], mac[5]);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006908
6909 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
6910 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6911 {
6912 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
6913 hddLog(VOS_TRACE_LEVEL_INFO,
6914 "%s: STA removal failed for ::"
6915 "%02x:%02x:%02x:%02x:%02x:%02x",
6916 __func__,
6917 mac[0], mac[1], mac[2],
6918 mac[3], mac[4], mac[5]);
6919 return -ENOENT;
6920 }
6921
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 }
6923 }
6924
6925 EXIT();
6926
6927 return 0;
6928}
6929
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006930static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
6931 struct net_device *dev, u8 *mac, struct station_parameters *params)
6932{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08006933 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006934#ifdef FEATURE_WLAN_TDLS
6935 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006936 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006937 mask = params->sta_flags_mask;
6938
6939 set = params->sta_flags_set;
6940
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006941#ifdef WLAN_FEATURE_TDLS_DEBUG
6942 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6943 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
6944 __func__, mask, set, MAC_ADDR_ARRAY(mac));
6945#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006946
6947 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
6948 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08006949 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08006950 }
6951 }
6952#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08006953 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006954}
6955
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006956
6957#ifdef FEATURE_WLAN_LFR
6958static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07006959 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006960{
6961#define MAX_PMKSAIDS_IN_CACHE 8
6962 static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306963 static tANI_U32 i; // HDD Local Cache index
6964 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006965 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6966 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306967 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306968 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006969 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306970 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306971
Jeff Johnsone7245742012-09-05 17:12:55 -07006972 ENTER();
6973
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306974 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306975 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006976 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306977 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006978 return -EINVAL;
6979 }
6980
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306981 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6982 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006983
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306984 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006985 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306986 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6987 "%s: HDD context is not valid", __func__);
6988 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006989 }
6990
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306991 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006992 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
6993
6994 for (j = 0; j < i; j++)
6995 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306996 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006997 pmksa->bssid, WNI_CFG_BSSID_LEN))
6998 {
6999 /* BSSID matched previous entry. Overwrite it. */
7000 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307001 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007002 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307003 vos_mem_copy(PMKIDCache[j].PMKID,
7004 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007005 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307006 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007007 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007008 dump_bssid(pmksa->bssid);
7009 dump_pmkid(halHandle, pmksa->pmkid);
7010 break;
7011 }
7012 }
7013
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007014 /* Check we compared all entries,if then take the first slot now */
7015 if(j == MAX_PMKSAIDS_IN_CACHE) i=0;
7016
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007017 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307018 {
7019 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
7020 vos_mem_copy(PMKIDCache[i].BSSID,
7021 pmksa->bssid, ETHER_ADDR_LEN);
7022 vos_mem_copy(PMKIDCache[i].PMKID,
7023 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007024 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307025 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007026 __func__, i );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007027 dump_bssid(pmksa->bssid);
7028 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307029 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007030 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307031 if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007032 }
7033
7034
7035 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307036 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007037 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307038 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007039 __func__, i );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007040 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307041 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7042 PMKIDCache,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007043 i );
7044 return 0;
7045}
7046
7047
7048static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007049 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007050{
Jeff Johnsone7245742012-09-05 17:12:55 -07007051 ENTER();
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007052 // TODO: Implement this later.
7053 return 0;
7054}
7055
7056static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7057{
Jeff Johnsone7245742012-09-05 17:12:55 -07007058 ENTER();
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007059 // TODO: Implement this later.
7060 return 0;
7061}
7062#endif
7063
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007064#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307065static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007066 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7067{
7068 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7069 hdd_station_ctx_t *pHddStaCtx;
7070
7071 if (NULL == pAdapter)
7072 {
7073 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7074 return -ENODEV;
7075 }
7076
7077 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7078
7079 // Added for debug on reception of Re-assoc Req.
7080 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7081 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307082 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007083 ftie->ie_len);
7084 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7085 }
7086
7087#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307088 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007089 ftie->ie_len);
7090#endif
7091
7092 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307093 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7094 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007095 ftie->ie_len);
7096 return 0;
7097}
7098#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007099
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307100#ifdef FEATURE_WLAN_SCAN_PNO
7101
7102void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7103 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7104{
7105 int ret;
7106 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7107 hdd_context_t *pHddCtx;
7108
7109 if (NULL == pAdapter)
7110 {
7111 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7112 "%s: HDD adapter is Null", __func__);
7113 return ;
7114 }
7115
7116 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7117 if (NULL == pHddCtx)
7118 {
7119 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7120 "%s: HDD context is Null!!!", __func__);
7121 return ;
7122 }
7123
7124 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7125
7126 if (0 > ret)
7127 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7128
7129 cfg80211_sched_scan_results(pHddCtx->wiphy);
7130}
7131
7132/*
7133 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7134 * NL interface to enable PNO
7135 */
7136static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7137 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7138{
7139 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7140 tpSirPNOScanReq pPnoRequest = NULL;
7141 hdd_context_t *pHddCtx;
7142 tHalHandle hHal;
7143 v_U32_t i, indx, num_ch;
7144 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7145 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7146 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7147 eHalStatus status = eHAL_STATUS_FAILURE;
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307148 int result;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307149
7150 if (NULL == pAdapter)
7151 {
7152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7153 "%s: HDD adapter is Null", __func__);
7154 return -ENODEV;
7155 }
7156
7157 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307158 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307159
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307160 if (0 != result)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307161 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307162 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7163 "%s: HDD context is not valid", __func__);
7164 return result;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307165 }
7166
7167 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7168 if (NULL == hHal)
7169 {
7170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7171 "%s: HAL context is Null!!!", __func__);
7172 return -EAGAIN;
7173 }
7174
7175 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7176 if (NULL == pPnoRequest)
7177 {
7178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7179 "%s: vos_mem_malloc failed", __func__);
7180 return -ENODEV;
7181 }
7182
7183 pPnoRequest->enable = 1; /*Enable PNO */
7184 pPnoRequest->ucNetworksCount = request->n_match_sets;
7185
7186 if (( !pPnoRequest->ucNetworksCount ) ||
7187 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7188 {
7189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7190 "Network input is not correct");
7191 goto error;
7192 }
7193
7194 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7195 {
7196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7197 "Incorrect number of channels");
7198 goto error;
7199 }
7200
7201 /* Framework provides one set of channels(all)
7202 * common for all saved profile */
7203 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7204 channels_allowed, &num_channels_allowed))
7205 {
7206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7207 "%s: failed to get valid channel list", __func__);
7208 goto error;
7209 }
7210 /* Checking each channel against allowed channel list */
7211 num_ch = 0;
7212 for (i = 0; i < request->n_channels; i++)
7213 {
7214 for (indx = 0; indx < num_channels_allowed; indx++)
7215 {
7216 if (request->channels[i]->hw_value == channels_allowed[indx])
7217 {
7218 valid_ch[num_ch++] = request->channels[i]->hw_value;
7219 break ;
7220 }
7221 }
7222 }
7223
7224 /* Filling per profile params */
7225 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7226 {
7227 pPnoRequest->aNetworks[i].ssId.length =
7228 request->match_sets[i].ssid.ssid_len;
7229
7230 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7231 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7232 {
7233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7234 "SSID Len %d is not correct for network %d",
7235 pPnoRequest->aNetworks[i].ssId.length, i);
7236 goto error;
7237 }
7238
7239 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7240 request->match_sets[i].ssid.ssid,
7241 request->match_sets[i].ssid.ssid_len);
7242 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7243 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7244 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7245
7246 /*Copying list of valid channel into request */
7247 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7248 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7249
7250 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7251 }
7252
7253 /* framework provides interval in ms */
7254 pPnoRequest->scanTimers.ucScanTimersCount = 1;
7255 pPnoRequest->scanTimers.aTimerValues[0].uTimerValue =
7256 (request->interval)/1000;
7257 pPnoRequest->scanTimers.aTimerValues[0].uTimerRepeat = 0;
7258 pPnoRequest->modePNO = SIR_PNO_MODE_ON_SUSPEND;
7259
7260 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7261 pPnoRequest, pAdapter->sessionId,
7262 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7263 if (eHAL_STATUS_SUCCESS != status)
7264 {
7265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7266 "Failed to enable PNO");
7267 goto error;
7268 }
7269
7270error:
7271 vos_mem_free(pPnoRequest);
7272 return status;
7273}
7274
7275/*
7276 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
7277 * NL interface to disable PNO
7278 */
7279static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
7280 struct net_device *dev)
7281{
7282 eHalStatus status = eHAL_STATUS_FAILURE;
7283 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7284 hdd_context_t *pHddCtx;
7285 tHalHandle hHal;
7286 tpSirPNOScanReq pPnoRequest = NULL;
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307287 int result;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307288
7289 ENTER();
7290
7291 if (NULL == pAdapter)
7292 {
7293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7294 "%s: HDD adapter is Null", __func__);
7295 return -ENODEV;
7296 }
7297
7298 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307299 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307300
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307301 if (0 != result)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307302 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307303 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7304 "%s: HDD context is not valid", __func__);
7305 return result;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307306 }
7307
7308 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7309 if (NULL == hHal)
7310 {
7311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7312 "%s: HAL context is Null!!!", __func__);
7313 return -EAGAIN;
7314 }
7315
7316 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7317 if (NULL == pPnoRequest)
7318 {
7319 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7320 "%s: vos_mem_malloc failed", __func__);
7321 return -ENODEV;
7322 }
7323
7324 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
7325 pPnoRequest->enable = 0; /* Disable PNO */
7326 pPnoRequest->ucNetworksCount = 0;
7327
7328 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
7329 pAdapter->sessionId,
7330 NULL, pAdapter);
7331 if (eHAL_STATUS_SUCCESS != status)
7332 {
7333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7334 "Failed to disabled PNO");
7335 }
7336
7337 vos_mem_free(pPnoRequest);
7338
7339 EXIT();
7340 return status;
7341}
7342
7343#endif /*FEATURE_WLAN_SCAN_PNO*/
7344
7345
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007346#ifdef FEATURE_WLAN_TDLS
7347static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
7348 u8 *peer, u8 action_code, u8 dialog_token,
7349 u16 status_code, const u8 *buf, size_t len)
7350{
7351
7352 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7353 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007354 u8 peerMac[6];
7355 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007356 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08007357 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007358 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007359
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007360 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007361 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307362 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007363 "Invalid arguments");
7364 return -EINVAL;
7365 }
7366
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007367 if (pHddCtx->isLogpInProgress)
7368 {
7369 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7370 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007371 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007372 return -EBUSY;
7373 }
7374
Hoonki Lee27511902013-03-14 18:19:06 -07007375 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007376 {
Hoonki Lee27511902013-03-14 18:19:06 -07007377 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7378 "%s: TDLS mode is disabled OR not enabled in FW."
7379 MAC_ADDRESS_STR " action %d declined.",
7380 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007381 return -ENOTSUPP;
7382 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08007383
Hoonki Lee27511902013-03-14 18:19:06 -07007384 /* other than teardown frame, other mgmt frames are not sent if disabled */
7385 if (SIR_MAC_TDLS_TEARDOWN != action_code)
7386 {
7387 /* if tdls_mode is disabled to respond to peer's request */
7388 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
7389 {
7390 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7391 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007392 " TDLS mode is disabled. action %d declined.",
7393 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07007394
7395 return -ENOTSUPP;
7396 }
7397 }
7398
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007399 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
7400 {
Hoonki Leefb8df672013-04-10 18:20:34 -07007401 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007402 {
7403 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007404 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007405 " TDLS setup is ongoing. action %d declined.",
7406 __func__, MAC_ADDR_ARRAY(peer), action_code);
7407 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007408 }
7409 }
7410
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007411 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
7412 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08007413 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007414 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08007415 {
7416 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
7417 we return error code at 'add_station()'. Hence we have this
7418 check again in addtion to add_station().
7419 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007420 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08007421 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7423 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007424 " TDLS Max peer already connected. action %d declined.",
7425 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007426 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08007427 }
7428 else
7429 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007430 /* maximum reached. tweak to send error code to peer and return
7431 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08007432 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007433 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7434 "%s: " MAC_ADDRESS_STR
7435 " TDLS Max peer already connected send response status %d",
7436 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007437 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007438 /* fall through to send setup resp with failure status
7439 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08007440 }
7441 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007442 else
7443 {
7444 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007445 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007446 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007447 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007448 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007449 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
7450 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007451 return -EPERM;
7452 }
7453 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08007454 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007455 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007456
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007457#ifdef WLAN_FEATURE_TDLS_DEBUG
7458 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007459 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
7460 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
7461 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007462#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007463
Hoonki Leea34dd892013-02-05 22:56:02 -08007464 /*Except teardown responder will not be used so just make 0*/
7465 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007466 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08007467 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007468
7469 hddTdlsPeer_t *pTdlsPeer;
7470 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac);
7471
7472 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
7473 responder = pTdlsPeer->is_responder;
7474 else
Hoonki Leea34dd892013-02-05 22:56:02 -08007475 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007476 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7477 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
7478 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
7479 dialog_token, status_code, len);
7480 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08007481 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007482 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007483
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307484 /* For explicit trigger of DIS_REQ come out of BMPS for
7485 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07007486 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307487 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
7488 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07007489 {
7490 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7491 {
7492 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307493 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07007494 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
7495 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307496 if (SIR_MAC_TDLS_DIS_REQ != action_code)
7497 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07007498 }
7499
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007500 /* make sure doesn't call send_mgmt() while it is pending */
7501 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
7502 {
7503 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7504 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
7505 __func__, MAC_ADDR_ARRAY(peer), action_code);
7506 return -EBUSY;
7507 }
7508
7509 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007510 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
7511
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007512 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08007513 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007514
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007515 if (VOS_STATUS_SUCCESS != status)
7516 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7518 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007519 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07007520 wlan_hdd_tdls_check_bmps(pAdapter);
7521 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007522 }
7523
Hoonki Leed37cbb32013-04-20 00:31:14 -07007524 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
7525 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
7526
7527 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007528 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07007529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7530 "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu",
7531 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007532 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007533 wlan_hdd_tdls_check_bmps(pAdapter);
7534 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007535 }
7536
Gopichand Nakkala05922802013-03-14 12:23:19 -07007537 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07007538 {
7539 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007540 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07007541 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007542
Hoonki Leea34dd892013-02-05 22:56:02 -08007543 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
7544 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007545 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08007546 }
7547 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
7548 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007549 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08007550 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007551
7552 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007553error:
7554 /* max_sta_failed ; we didn't set to CONNECTING for this case,
7555 because we already know that this transaction will be failed,
7556 but we weren't sure if supplicant call DISABLE_LINK or not. So,
7557 to be safe, do not change the state mahine.
7558 */
7559 if(max_sta_failed == 0 &&
7560 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
7561 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
7562 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007563}
7564
7565static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
7566 u8 *peer, enum nl80211_tdls_operation oper)
7567{
7568 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7569 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307570 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05307571#ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP
7572 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05307573 tANI_U8 staIdx;
7574#endif
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007575#ifdef WLAN_FEATURE_TDLS_DEBUG
7576 const char *tdls_oper_str[]= {
7577 "NL80211_TDLS_DISCOVERY_REQ",
7578 "NL80211_TDLS_SETUP",
7579 "NL80211_TDLS_TEARDOWN",
7580 "NL80211_TDLS_ENABLE_LINK",
7581 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05307582 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007583#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007584 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007585
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307586 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007587 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007588 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07007589 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007590 return -EINVAL;
7591 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007592
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307593 status = wlan_hdd_validate_context(pHddCtx);
7594
7595 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007596 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307597 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7598 "%s: HDD context is not valid", __func__);
7599 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007600 }
7601
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007602 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer);
7603
7604 if ( NULL == pTdlsPeer ) {
7605 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
7606 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
7607 return -EINVAL;
7608 }
7609
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007610#ifdef WLAN_FEATURE_TDLS_DEBUG
7611 if((int)oper > 4)
7612 oper = 5;
7613
7614 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007615 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
7616 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007617 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007618#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007619
7620 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007621 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007622 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007623 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07007624 "TDLS Disabled in INI OR not enabled in FW. "
7625 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007626 return -ENOTSUPP;
7627 }
7628
7629 switch (oper) {
7630 case NL80211_TDLS_ENABLE_LINK:
7631 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007632 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307633 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007634
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07007635 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
7636 {
7637 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
7638 MAC_ADDRESS_STR " failed",
7639 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
7640 return -EINVAL;
7641 }
7642
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007643 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007644 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307645 long ret;
7646
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307647 if (0 != wlan_hdd_tdls_get_link_establish_params(pAdapter, peer,&tdlsLinkEstablishParams)) {
7648 return -EINVAL;
7649 }
7650 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
7651
7652 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
7653 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
7654 /* Send TDLS peer UAPSD capabilities to the firmware and
7655 * register with the TL on after the response for this operation
7656 * is received .
7657 */
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307658 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_link_establish_req_comp,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307659 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307660 if (ret <= 0)
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307661 {
7662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7663 "%s: Link Establish Request Faled Status %ld",
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307664 __func__, ret);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307665 return -EINVAL;
7666 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007667 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05307668 /* Mark TDLS client Authenticated .*/
7669 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
7670 pTdlsPeer->staId,
7671 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007672 if (VOS_STATUS_SUCCESS == status)
7673 {
Hoonki Lee14621352013-04-16 17:51:19 -07007674 if (pTdlsPeer->is_responder == 0)
7675 {
7676 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
7677
7678 wlan_hdd_tdls_timer_restart(pAdapter,
7679 &pTdlsPeer->initiatorWaitTimeoutTimer,
7680 WAIT_TIME_TDLS_INITIATOR);
7681 /* suspend initiator TX until it receives direct packet from the
7682 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
7683 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
7684 &staId, NULL);
7685 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007686 wlan_hdd_tdls_increment_peer_count(pAdapter);
7687 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007688 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307689
7690 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307691 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
7692 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307693 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307694 int ac;
7695 uint8 ucAc[4] = { WLANTL_AC_VO,
7696 WLANTL_AC_VI,
7697 WLANTL_AC_BK,
7698 WLANTL_AC_BE };
7699 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
7700 for(ac=0; ac < 4; ac++)
7701 {
7702 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
7703 pTdlsPeer->staId, ucAc[ac],
7704 tlTid[ac], tlTid[ac], 0, 0,
7705 WLANTL_BI_DIR );
7706 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307707 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007708 }
7709
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007710 }
7711 break;
7712 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08007713 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007714 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08007715 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007716 long status;
7717
7718 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
7719
Lee Hoonkic1262f22013-01-24 21:59:00 -08007720 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
7721 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007722
7723 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
7724 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
7725 if (status <= 0)
7726 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007727 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007728 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7729 "%s: Del station failed status %ld",
7730 __func__, status);
7731 return -EPERM;
7732 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007733 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08007734 }
7735 else
7736 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007737 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7738 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08007739 }
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05307740#ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP
7741 if (pHddTdlsCtx->defer_link_lost_indication)
7742 {
7743 if (( TRUE == pHddCtx->cfg_ini->fEnableTDLSOxygenSupport ) &&
7744 (wlan_hdd_tdlsConnectedPeers(pAdapter) == 0))
7745 {
7746 status = wlan_hdd_disconnect(pAdapter, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7747 if ( 0 != status)
7748 {
7749 hddLog(VOS_TRACE_LEVEL_ERROR,
7750 "%s wlan_hdd_disconnect failure, returned %d \n",
7751 __func__, (int)status );
7752 return -EINVAL;
7753 }
7754 }
7755 }
7756#endif
Lee Hoonkic1262f22013-01-24 21:59:00 -08007757 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007758 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007759 case NL80211_TDLS_TEARDOWN:
7760 case NL80211_TDLS_SETUP:
7761 case NL80211_TDLS_DISCOVERY_REQ:
7762 /* We don't support in-driver setup/teardown/discovery */
7763 return -ENOTSUPP;
7764 default:
7765 return -ENOTSUPP;
7766 }
7767 return 0;
7768}
Chilam NG571c65a2013-01-19 12:27:36 +05307769
7770int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
7771 struct net_device *dev, u8 *peer)
7772{
7773 hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x",
7774 peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]);
7775
7776 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
7777 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
7778}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007779#endif
7780
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307781#ifdef WLAN_FEATURE_GTK_OFFLOAD
7782/*
7783 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
7784 * Callback rountine called upon receiving response for
7785 * get offload info
7786 */
7787void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
7788 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
7789{
7790
7791 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307792 tANI_U8 tempReplayCounter[8];
7793 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307794
7795 ENTER();
7796
7797 if (NULL == pAdapter)
7798 {
7799 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7800 "%s: HDD adapter is Null", __func__);
7801 return ;
7802 }
7803
7804 if (NULL == pGtkOffloadGetInfoRsp)
7805 {
7806 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7807 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
7808 return ;
7809 }
7810
7811 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
7812 {
7813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7814 "%s: wlan Failed to get replay counter value",
7815 __func__);
7816 return ;
7817 }
7818
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307819 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7820 /* Update replay counter */
7821 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
7822 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
7823
7824 {
7825 /* changing from little to big endian since supplicant
7826 * works on big endian format
7827 */
7828 int i;
7829 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
7830
7831 for (i = 0; i < 8; i++)
7832 {
7833 tempReplayCounter[7-i] = (tANI_U8)p[i];
7834 }
7835 }
7836
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307837 /* Update replay counter to NL */
7838 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307839 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307840}
7841
7842/*
7843 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
7844 * This function is used to offload GTK rekeying job to the firmware.
7845 */
7846int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
7847 struct cfg80211_gtk_rekey_data *data)
7848{
7849 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7850 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
7851 hdd_station_ctx_t *pHddStaCtx;
7852 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307853 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307854 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307855 eHalStatus status = eHAL_STATUS_FAILURE;
7856
7857 ENTER();
7858
7859 if (NULL == pAdapter)
7860 {
7861 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7862 "%s: HDD adapter is Null", __func__);
7863 return -ENODEV;
7864 }
7865
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307866 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307867
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307868 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307869 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307870 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7871 "%s: HDD context is not valid", __func__);
7872 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307873 }
7874
7875 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7876 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7877 if (NULL == hHal)
7878 {
7879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7880 "%s: HAL context is Null!!!", __func__);
7881 return -EAGAIN;
7882 }
7883
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307884 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
7885 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
7886 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
7887 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307888 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307889 {
7890 /* changing from big to little endian since driver
7891 * works on little endian format
7892 */
7893 tANI_U8 *p =
7894 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
7895 int i;
7896
7897 for (i = 0; i < 8; i++)
7898 {
7899 p[7-i] = data->replay_ctr[i];
7900 }
7901 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307902
7903 if (TRUE == pHddCtx->hdd_wlan_suspended)
7904 {
7905 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307906 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
7907 sizeof (tSirGtkOffloadParams));
7908 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307909 pAdapter->sessionId);
7910
7911 if (eHAL_STATUS_SUCCESS != status)
7912 {
7913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7914 "%s: sme_SetGTKOffload failed, returned %d",
7915 __func__, status);
7916 return status;
7917 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307918 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7919 "%s: sme_SetGTKOffload successfull", __func__);
7920 }
7921 else
7922 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7924 "%s: wlan not suspended GTKOffload request is stored",
7925 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307926 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307927
7928 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307929}
7930#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
7931
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307932/*
7933 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
7934 * This function is used to set access control policy
7935 */
7936static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
7937 struct net_device *dev, const struct cfg80211_acl_data *params)
7938{
7939 int i;
7940 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7941 hdd_hostapd_state_t *pHostapdState;
7942 tsap_Config_t *pConfig;
7943 v_CONTEXT_t pVosContext = NULL;
7944 hdd_context_t *pHddCtx;
7945 int status;
7946
7947 ENTER();
7948
7949 if (NULL == pAdapter)
7950 {
7951 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7952 "%s: HDD adapter is Null", __func__);
7953 return -ENODEV;
7954 }
7955
7956 if (NULL == params)
7957 {
7958 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7959 "%s: params is Null", __func__);
7960 return -EINVAL;
7961 }
7962
7963 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7964 status = wlan_hdd_validate_context(pHddCtx);
7965
7966 if (0 != status)
7967 {
7968 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7969 "%s: HDD context is not valid", __func__);
7970 return status;
7971 }
7972
7973 pVosContext = pHddCtx->pvosContext;
7974 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7975
7976 if (NULL == pHostapdState)
7977 {
7978 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7979 "%s: pHostapdState is Null", __func__);
7980 return -EINVAL;
7981 }
7982
7983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
7984 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
7985
7986 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
7987 {
7988 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
7989
7990 /* default value */
7991 pConfig->num_accept_mac = 0;
7992 pConfig->num_deny_mac = 0;
7993
7994 /**
7995 * access control policy
7996 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
7997 * listed in hostapd.deny file.
7998 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
7999 * listed in hostapd.accept file.
8000 */
8001 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8002 {
8003 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8004 }
8005 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8006 {
8007 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8008 }
8009 else
8010 {
8011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8012 "%s:Acl Policy : %d is not supported",
8013 __func__, params->acl_policy);
8014 return -ENOTSUPP;
8015 }
8016
8017 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8018 {
8019 pConfig->num_accept_mac = params->n_acl_entries;
8020 for (i = 0; i < params->n_acl_entries; i++)
8021 {
8022 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8023 "** Add ACL MAC entry %i in WhiletList :"
8024 MAC_ADDRESS_STR, i,
8025 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8026
8027 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8028 sizeof(qcmacaddr));
8029 }
8030 }
8031 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8032 {
8033 pConfig->num_deny_mac = params->n_acl_entries;
8034 for (i = 0; i < params->n_acl_entries; i++)
8035 {
8036 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8037 "** Add ACL MAC entry %i in BlackList :"
8038 MAC_ADDRESS_STR, i,
8039 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8040
8041 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8042 sizeof(qcmacaddr));
8043 }
8044 }
8045
8046 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8047 {
8048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8049 "%s: SAP Set Mac Acl fail", __func__);
8050 return -EINVAL;
8051 }
8052 }
8053 else
8054 {
8055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8056 "%s: Invalid device_mode = %d",
8057 __func__, pAdapter->device_mode);
8058 return -EINVAL;
8059 }
8060
8061 return 0;
8062}
8063
Jeff Johnson295189b2012-06-20 16:38:30 -07008064/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308065static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07008066{
8067 .add_virtual_intf = wlan_hdd_add_virtual_intf,
8068 .del_virtual_intf = wlan_hdd_del_virtual_intf,
8069 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
8070 .change_station = wlan_hdd_change_station,
8071#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8072 .add_beacon = wlan_hdd_cfg80211_add_beacon,
8073 .del_beacon = wlan_hdd_cfg80211_del_beacon,
8074 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008075#else
8076 .start_ap = wlan_hdd_cfg80211_start_ap,
8077 .change_beacon = wlan_hdd_cfg80211_change_beacon,
8078 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07008079#endif
8080 .change_bss = wlan_hdd_cfg80211_change_bss,
8081 .add_key = wlan_hdd_cfg80211_add_key,
8082 .get_key = wlan_hdd_cfg80211_get_key,
8083 .del_key = wlan_hdd_cfg80211_del_key,
8084 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08008085#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008086 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08008087#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 .scan = wlan_hdd_cfg80211_scan,
8089 .connect = wlan_hdd_cfg80211_connect,
8090 .disconnect = wlan_hdd_cfg80211_disconnect,
8091 .join_ibss = wlan_hdd_cfg80211_join_ibss,
8092 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
8093 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
8094 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
8095 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07008096 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
8097 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
8098 .mgmt_tx = wlan_hdd_action,
8099#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8100 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
8101 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
8102 .set_txq_params = wlan_hdd_set_txq_params,
8103#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 .get_station = wlan_hdd_cfg80211_get_station,
8105 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
8106 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008107 .add_station = wlan_hdd_cfg80211_add_station,
8108#ifdef FEATURE_WLAN_LFR
8109 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
8110 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
8111 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
8112#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008113#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
8114 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
8115#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008116#ifdef FEATURE_WLAN_TDLS
8117 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
8118 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
8119#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308120#ifdef WLAN_FEATURE_GTK_OFFLOAD
8121 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
8122#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308123#ifdef FEATURE_WLAN_SCAN_PNO
8124 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
8125 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
8126#endif /*FEATURE_WLAN_SCAN_PNO */
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308127 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Jeff Johnson295189b2012-06-20 16:38:30 -07008128};
8129