blob: 36032c43b548be22d14c4c2a4ccc21a3ef710f74 [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
Leo Chang9056f462013-08-01 19:21:11 -0700506#ifdef WLAN_NL80211_TESTMODE
507enum wlan_hdd_tm_attr
508{
509 WLAN_HDD_TM_ATTR_INVALID = 0,
510 WLAN_HDD_TM_ATTR_CMD = 1,
511 WLAN_HDD_TM_ATTR_DATA = 2,
512 WLAN_HDD_TM_ATTR_TYPE = 3,
513 /* keep last */
514 WLAN_HDD_TM_ATTR_AFTER_LAST,
515 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
516};
517
518enum wlan_hdd_tm_cmd
519{
520 WLAN_HDD_TM_CMD_WLAN_HB = 1,
521};
522
523#define WLAN_HDD_TM_DATA_MAX_LEN 5000
524
525static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
526{
527 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
528 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
529 .len = WLAN_HDD_TM_DATA_MAX_LEN },
530};
531#endif /* WLAN_NL80211_TESTMODE */
532
Jeff Johnson295189b2012-06-20 16:38:30 -0700533/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530534 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530535 * This function is called by hdd_wlan_startup()
536 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530537 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530539struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -0700540{
541 struct wiphy *wiphy;
542 ENTER();
543
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530544 /*
545 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 */
547 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
548
549 if (!wiphy)
550 {
551 /* Print error and jump into err label and free the memory */
552 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
553 return NULL;
554 }
555
556 return wiphy;
557}
558
559/*
560 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530561 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 * private ioctl to change the band value
563 */
564int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
565{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530566 int i, j;
567 eNVChannelEnabledType channelEnabledState;
568
Jeff Johnsone7245742012-09-05 17:12:55 -0700569 ENTER();
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530570 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530572
573 if (NULL == wiphy->bands[i])
574 {
575 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
576 __func__, i);
577 continue;
578 }
579
580 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
581 {
582 struct ieee80211_supported_band *band = wiphy->bands[i];
583
584 channelEnabledState = vos_nv_getChannelEnabledState(
585 band->channels[j].hw_value);
586
587 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
588 {
589 // Enable Social channels for P2P
590 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
591 NV_CHANNEL_ENABLE == channelEnabledState)
592 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
593 else
594 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
595 continue;
596 }
597 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
598 {
599 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
600 continue;
601 }
602
603 if (NV_CHANNEL_DISABLE == channelEnabledState ||
604 NV_CHANNEL_INVALID == channelEnabledState)
605 {
606 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
607 }
608 else if (NV_CHANNEL_DFS == channelEnabledState)
609 {
610 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
611 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
612 }
613 else
614 {
615 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
616 |IEEE80211_CHAN_RADAR);
617 }
618 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 }
620 return 0;
621}
622/*
623 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530624 * This function is called by hdd_wlan_startup()
625 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 * This function is used to initialize and register wiphy structure.
627 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530628int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 struct wiphy *wiphy,
630 hdd_config_t *pCfg
631 )
632{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530633 int i, j;
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530634 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Jeff Johnsone7245742012-09-05 17:12:55 -0700635 ENTER();
636
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 /* Now bind the underlying wlan device with wiphy */
638 set_wiphy_dev(wiphy, dev);
639
640 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530641 if (memcmp(pHddCtx->cfg_ini->crdaDefaultCountryCode,
642 CFG_CRDA_DEFAULT_COUNTRY_CODE_DEFAULT , 2) != 0)
643 {
644 wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
645 }
646 else
647 {
648 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
649 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700650#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700651 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
652 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
653 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700654 | WIPHY_FLAG_OFFCHAN_TX;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700655#endif
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700656#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
657 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800658#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700659 || pCfg->isFastRoamIniFeatureEnabled
660#endif
661#ifdef FEATURE_WLAN_CCX
662 || pCfg->isCcxIniFeatureEnabled
663#endif
664 )
665 {
666 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
667 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800668#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800669#ifdef FEATURE_WLAN_TDLS
670 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
671 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
672#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530673#ifdef FEATURE_WLAN_SCAN_PNO
674 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
675 wiphy->max_sched_scan_ssids = MAX_SCAN_SSID;
676 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
677#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800678
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700679 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
680 driver can still register regulatory callback and
681 it will get CRDA setting in wiphy->band[], but
682 driver need to determine what to do with both
683 regulatory settings */
684 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700685
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530686 wiphy->max_scan_ssids = MAX_SCAN_SSID;
687
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530688 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700689
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530690 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
691
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530693 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700695 | BIT(NL80211_IFTYPE_P2P_CLIENT)
696 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 | BIT(NL80211_IFTYPE_AP);
698
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800699#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800700 if( pCfg->enableMCC )
701 {
702 /* Currently, supports up to two channels */
703 wlan_hdd_iface_combination.num_different_channels = 2;
704
705 if( !pCfg->allowMCCGODiffBI )
706 wlan_hdd_iface_combination.beacon_int_infra_match = true;
707
708 }
709 wiphy->iface_combinations = &wlan_hdd_iface_combination;
710 wiphy->n_iface_combinations = 1;
711#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800712
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 /* Before registering we need to update the ht capabilitied based
714 * on ini values*/
715 if( !pCfg->ShortGI20MhzEnable )
716 {
717 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
718 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
719 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
720 }
721
722 if( !pCfg->ShortGI40MhzEnable )
723 {
724 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
725 }
726
727 if( !pCfg->nChannelBondingMode5GHz )
728 {
729 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
730 }
731
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530732 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
733 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
734
735 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
736 {
737
738 if (NULL == wiphy->bands[i])
739 {
740 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
741 __func__, i);
742 continue;
743 }
744
745 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
746 {
747 struct ieee80211_supported_band *band = wiphy->bands[i];
748
749 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
750 {
751 // Enable social channels for P2P
752 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
753 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
754 else
755 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
756 continue;
757 }
758 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
759 {
760 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
761 continue;
762 }
763 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 }
765 /*Initialise the supported cipher suite details*/
766 wiphy->cipher_suites = hdd_cipher_suites;
767 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
768
769 /*signal strength in mBm (100*dBm) */
770 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
771
772#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 wiphy->max_remain_on_channel_duration = 1000;
774#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700775
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530776 EXIT();
777 return 0;
778}
779
780/* In this function we are registering wiphy. */
781int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
782{
783 ENTER();
784 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700785 if (0 > wiphy_register(wiphy))
786 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530787 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
789 return -EIO;
790 }
791
792 EXIT();
793 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530794}
Jeff Johnson295189b2012-06-20 16:38:30 -0700795
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700796/* In this function we will try to get default country code from crda.
797 If the gCrdaDefaultCountryCode is configured in ini file,
798 we will try to call user space crda to get the regulatory settings for
799 that country. We will timeout if we can't get it from crda.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530800 It's called by hdd_wlan_startup() after wlan_hdd_cfg80211_init.
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700801*/
802int wlan_hdd_get_crda_regd_entry(struct wiphy *wiphy, hdd_config_t *pCfg)
803{
804 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Madan Mohan Koyyalamudi113ac742013-08-06 22:45:43 +0530805 int status;
806
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700807 if (memcmp(pCfg->crdaDefaultCountryCode,
808 CFG_CRDA_DEFAULT_COUNTRY_CODE_DEFAULT , 2) != 0)
809 {
Madan Mohan Koyyalamudi113ac742013-08-06 22:45:43 +0530810 INIT_COMPLETION(pHddCtx->driver_crda_req);
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700811 regulatory_hint(wiphy, pCfg->crdaDefaultCountryCode);
Madan Mohan Koyyalamudi113ac742013-08-06 22:45:43 +0530812 status = wait_for_completion_interruptible_timeout(
813 &pHddCtx->driver_crda_req,
814 msecs_to_jiffies(CRDA_WAIT_TIME));
815 if (!status)
816 {
817 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: timeout waiting for CRDA REQ",
818 __func__);
819 }
820
Yunsen Wange3ba1fb2013-04-05 15:04:43 -0700821 /* if the country is not found from current regulatory.bin,
822 fall back to world domain */
823 if (is_crda_regulatory_entry_valid() == VOS_FALSE)
824 crda_regulatory_entry_default(pCfg->crdaDefaultCountryCode, NUM_REG_DOMAINS-1);
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700825 }
826 return 0;
827}
828
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530829/* In this function we are updating channel list when,
830 regulatory domain is FCC and country code is US.
831 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
832 As per FCC smart phone is not a indoor device.
833 GO should not opeate on indoor channels */
834void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
835{
836 int j;
837 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
838 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
839 //Default counrtycode from NV at the time of wiphy initialization.
840 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
841 &defaultCountryCode[0]))
842 {
843 hddLog(LOGE, FL("%s Failed to get default country code from NV"));
844 }
845 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
846 {
847 /* This will disable updating of NL channels from passive to
848 active if a beacon is received on passive channel.
849 If this flag is not disabled then nl can change passive channel to
850 active channels.
851 */
852 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
853 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
854 {
855 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
856 return;
857 }
858 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
859 {
860 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
861 // Mark UNII -1 band channel as passive
862 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
863 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
864 }
865 }
866}
867
Jeff Johnson295189b2012-06-20 16:38:30 -0700868/* In this function we will do all post VOS start initialization.
869 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530870 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700871*/
872void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
873{
Jeff Johnson295189b2012-06-20 16:38:30 -0700874 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
875 /* Register for all P2P action, public action etc frames */
876 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
877
Jeff Johnsone7245742012-09-05 17:12:55 -0700878 ENTER();
879
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 /* Right now we are registering these frame when driver is getting
881 initialized. Once we will move to 2.6.37 kernel, in which we have
882 frame register ops, we will move this code as a part of that */
883 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530884 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
886
887 /* GAS Initial Response */
888 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
889 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530890
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 /* GAS Comeback Request */
892 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
893 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
894
895 /* GAS Comeback Response */
896 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
897 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
898
899 /* P2P Public Action */
900 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530901 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 P2P_PUBLIC_ACTION_FRAME_SIZE );
903
904 /* P2P Action */
905 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
906 (v_U8_t*)P2P_ACTION_FRAME,
907 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700908
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530909 /* WNM BSS Transition Request frame */
910 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
911 (v_U8_t*)WNM_BSS_ACTION_FRAME,
912 WNM_BSS_ACTION_FRAME_SIZE );
913
Chet Lanctot186b5732013-03-18 10:26:30 -0700914#ifdef WLAN_FEATURE_11W
915 /* SA Query Response Action Frame */
916 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
917 (v_U8_t*)SA_QUERY_FRAME_RSP,
918 SA_QUERY_FRAME_RSP_SIZE );
919#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700920}
921
922void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
923{
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
925 /* Register for all P2P action, public action etc frames */
926 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
927
Jeff Johnsone7245742012-09-05 17:12:55 -0700928 ENTER();
929
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 /* Right now we are registering these frame when driver is getting
931 initialized. Once we will move to 2.6.37 kernel, in which we have
932 frame register ops, we will move this code as a part of that */
933 /* GAS Initial Request */
934
935 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
936 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
937
938 /* GAS Initial Response */
939 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
940 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530941
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 /* GAS Comeback Request */
943 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
944 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
945
946 /* GAS Comeback Response */
947 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
948 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
949
950 /* P2P Public Action */
951 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530952 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 P2P_PUBLIC_ACTION_FRAME_SIZE );
954
955 /* P2P Action */
956 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
957 (v_U8_t*)P2P_ACTION_FRAME,
958 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700959
960#ifdef WLAN_FEATURE_11W
961 /* SA Query Response Action Frame */
962 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
963 (v_U8_t*)SA_QUERY_FRAME_RSP,
964 SA_QUERY_FRAME_RSP_SIZE );
965#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700966}
967
968#ifdef FEATURE_WLAN_WAPI
969void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
970 const u8 *mac_addr, u8 *key , int key_Len)
971{
972 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
973 tCsrRoamSetKey setKey;
974 v_BOOL_t isConnected = TRUE;
975 int status = 0;
976 v_U32_t roamId= 0xFF;
977 tANI_U8 *pKeyPtr = NULL;
978 int n = 0;
979
980 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
981 __func__,pAdapter->device_mode);
982
Gopichand Nakkalae7480202013-02-11 15:24:22 +0530983 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 setKey.keyId = key_index; // Store Key ID
985 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
986 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
987 setKey.paeRole = 0 ; // the PAE role
988 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
989 {
990 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
991 }
992 else
993 {
994 isConnected = hdd_connIsConnected(pHddStaCtx);
995 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
996 }
997 setKey.keyLength = key_Len;
998 pKeyPtr = setKey.Key;
999 memcpy( pKeyPtr, key, key_Len);
1000
1001 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
1002 __func__, key_Len);
1003 for (n = 0 ; n < key_Len; n++)
1004 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
1005 __func__,n,setKey.Key[n]);
1006
1007 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
1008 if ( isConnected )
1009 {
1010 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
1011 pAdapter->sessionId, &setKey, &roamId );
1012 }
1013 if ( status != 0 )
1014 {
1015 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1016 "[%4d] sme_RoamSetKey returned ERROR status= %d",
1017 __LINE__, status );
1018 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1019 }
1020}
1021#endif /* FEATURE_WLAN_WAPI*/
1022
1023#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301024int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 beacon_data_t **ppBeacon,
1026 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001027#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301028int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001029 beacon_data_t **ppBeacon,
1030 struct cfg80211_beacon_data *params,
1031 int dtim_period)
1032#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301033{
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 int size;
1035 beacon_data_t *beacon = NULL;
1036 beacon_data_t *old = NULL;
1037 int head_len,tail_len;
1038
Jeff Johnsone7245742012-09-05 17:12:55 -07001039 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 if (params->head && !params->head_len)
1041 return -EINVAL;
1042
1043 old = pAdapter->sessionCtx.ap.beacon;
1044
1045 if (!params->head && !old)
1046 return -EINVAL;
1047
1048 if (params->tail && !params->tail_len)
1049 return -EINVAL;
1050
1051#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1052 /* Kernel 3.0 is not updating dtim_period for set beacon */
1053 if (!params->dtim_period)
1054 return -EINVAL;
1055#endif
1056
1057 if(params->head)
1058 head_len = params->head_len;
1059 else
1060 head_len = old->head_len;
1061
1062 if(params->tail || !old)
1063 tail_len = params->tail_len;
1064 else
1065 tail_len = old->tail_len;
1066
1067 size = sizeof(beacon_data_t) + head_len + tail_len;
1068
1069 beacon = kzalloc(size, GFP_KERNEL);
1070
1071 if( beacon == NULL )
1072 return -ENOMEM;
1073
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001074#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 if(params->dtim_period || !old )
1076 beacon->dtim_period = params->dtim_period;
1077 else
1078 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001079#else
1080 if(dtim_period || !old )
1081 beacon->dtim_period = dtim_period;
1082 else
1083 beacon->dtim_period = old->dtim_period;
1084#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301085
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1087 beacon->tail = beacon->head + head_len;
1088 beacon->head_len = head_len;
1089 beacon->tail_len = tail_len;
1090
1091 if(params->head) {
1092 memcpy (beacon->head,params->head,beacon->head_len);
1093 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301094 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 if(old)
1096 memcpy (beacon->head,old->head,beacon->head_len);
1097 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301098
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 if(params->tail) {
1100 memcpy (beacon->tail,params->tail,beacon->tail_len);
1101 }
1102 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301103 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 memcpy (beacon->tail,old->tail,beacon->tail_len);
1105 }
1106
1107 *ppBeacon = beacon;
1108
1109 kfree(old);
1110
1111 return 0;
1112
1113}
Jeff Johnson295189b2012-06-20 16:38:30 -07001114
1115v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1116{
1117 int left = length;
1118 v_U8_t *ptr = pIes;
1119 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301120
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301122 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 elem_id = ptr[0];
1124 elem_len = ptr[1];
1125 left -= 2;
1126 if(elem_len > left)
1127 {
1128 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001129 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 eid,elem_len,left);
1131 return NULL;
1132 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301133 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 {
1135 return ptr;
1136 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301137
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 left -= elem_len;
1139 ptr += (elem_len + 2);
1140 }
1141 return NULL;
1142}
1143
Jeff Johnson295189b2012-06-20 16:38:30 -07001144/* Check if rate is 11g rate or not */
1145static int wlan_hdd_rate_is_11g(u8 rate)
1146{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001147 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 u8 i;
1149 for (i = 0; i < 8; i++)
1150 {
1151 if(rate == gRateArray[i])
1152 return TRUE;
1153 }
1154 return FALSE;
1155}
1156
1157/* Check for 11g rate and set proper 11g only mode */
1158static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1159 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1160{
1161 u8 i, num_rates = pIe[0];
1162
1163 pIe += 1;
1164 for ( i = 0; i < num_rates; i++)
1165 {
1166 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1167 {
1168 /* If rate set have 11g rate than change the mode to 11G */
1169 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1170 if (pIe[i] & BASIC_RATE_MASK)
1171 {
1172 /* If we have 11g rate as basic rate, it means mode
1173 is 11g only mode.
1174 */
1175 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1176 *pCheckRatesfor11g = FALSE;
1177 }
1178 }
1179 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1180 {
1181 *require_ht = TRUE;
1182 }
1183 }
1184 return;
1185}
1186
1187static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1188{
1189 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1190 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1191 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1192 u8 checkRatesfor11g = TRUE;
1193 u8 require_ht = FALSE;
1194 u8 *pIe=NULL;
1195
1196 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1197
1198 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1199 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1200 if (pIe != NULL)
1201 {
1202 pIe += 1;
1203 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1204 &pConfig->SapHw_mode);
1205 }
1206
1207 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1208 WLAN_EID_EXT_SUPP_RATES);
1209 if (pIe != NULL)
1210 {
1211
1212 pIe += 1;
1213 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1214 &pConfig->SapHw_mode);
1215 }
1216
1217 if( pConfig->channel > 14 )
1218 {
1219 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1220 }
1221
1222 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1223 WLAN_EID_HT_CAPABILITY);
1224
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301225 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 {
1227 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1228 if(require_ht)
1229 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1230 }
1231}
1232
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301233static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1234 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1235{
1236 v_U8_t ielen = 0;
1237 v_U8_t *pIe = NULL;
1238 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1239
1240 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1241 pBeacon->tail, pBeacon->tail_len);
1242
1243 if (pIe)
1244 {
1245 ielen = pIe[1] + 2;
1246 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1247 {
1248 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1249 }
1250 else
1251 {
1252 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1253 return -EINVAL;
1254 }
1255 *total_ielen += ielen;
1256 }
1257 return 0;
1258}
1259
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001260#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001261static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1262 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001263#else
1264static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1265 struct cfg80211_beacon_data *params)
1266#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001267{
1268 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301269 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001271 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001272
1273 genie = vos_mem_malloc(MAX_GENIE_LEN);
1274
1275 if(genie == NULL) {
1276
1277 return -ENOMEM;
1278 }
1279
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301280 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1281 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301283 ret = -EINVAL;
1284 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001285 }
1286
1287#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301288 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1289 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1290 {
1291 ret = -EINVAL;
1292 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 }
1294#endif
1295
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301296 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1297 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301299 ret = -EINVAL;
1300 goto done;
1301 }
1302
1303 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1304 {
1305 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1306 &total_ielen, SS_OUI_TYPE, SS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301308 ret = -EINVAL;
1309 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001312
1313 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1314 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1315 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1316 {
1317 hddLog(LOGE,
1318 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001319 ret = -EINVAL;
1320 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 }
1322
1323 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1324 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1325 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1326 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1327 ==eHAL_STATUS_FAILURE)
1328 {
1329 hddLog(LOGE,
1330 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001331 ret = -EINVAL;
1332 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 }
1334
1335 // Added for ProResp IE
1336 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1337 {
1338 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1339 u8 probe_rsp_ie_len[3] = {0};
1340 u8 counter = 0;
1341 /* Check Probe Resp Length if it is greater then 255 then Store
1342 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1343 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1344 Store More then 255 bytes into One Variable.
1345 */
1346 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1347 {
1348 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1349 {
1350 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1351 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1352 }
1353 else
1354 {
1355 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1356 rem_probe_resp_ie_len = 0;
1357 }
1358 }
1359
1360 rem_probe_resp_ie_len = 0;
1361
1362 if (probe_rsp_ie_len[0] > 0)
1363 {
1364 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1365 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1366 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1367 probe_rsp_ie_len[0], NULL,
1368 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1369 {
1370 hddLog(LOGE,
1371 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001372 ret = -EINVAL;
1373 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 }
1375 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1376 }
1377
1378 if (probe_rsp_ie_len[1] > 0)
1379 {
1380 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1381 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1382 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1383 probe_rsp_ie_len[1], NULL,
1384 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1385 {
1386 hddLog(LOGE,
1387 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001388 ret = -EINVAL;
1389 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 }
1391 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1392 }
1393
1394 if (probe_rsp_ie_len[2] > 0)
1395 {
1396 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1397 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1398 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1399 probe_rsp_ie_len[2], NULL,
1400 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1401 {
1402 hddLog(LOGE,
1403 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001404 ret = -EINVAL;
1405 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 }
1407 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1408 }
1409
1410 if (probe_rsp_ie_len[1] == 0 )
1411 {
1412 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1413 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1414 eANI_BOOLEAN_FALSE) )
1415 {
1416 hddLog(LOGE,
1417 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1418 }
1419 }
1420
1421 if (probe_rsp_ie_len[2] == 0 )
1422 {
1423 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1424 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1425 eANI_BOOLEAN_FALSE) )
1426 {
1427 hddLog(LOGE,
1428 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1429 }
1430 }
1431
1432 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1433 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1434 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1435 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1436 == eHAL_STATUS_FAILURE)
1437 {
1438 hddLog(LOGE,
1439 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001440 ret = -EINVAL;
1441 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 }
1443 }
1444 else
1445 {
1446 // Reset WNI_CFG_PROBE_RSP Flags
1447 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1448
1449 hddLog(VOS_TRACE_LEVEL_INFO,
1450 "%s: No Probe Response IE received in set beacon",
1451 __func__);
1452 }
1453
1454 // Added for AssocResp IE
1455 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1456 {
1457 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1458 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1459 params->assocresp_ies_len, NULL,
1460 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1461 {
1462 hddLog(LOGE,
1463 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001464 ret = -EINVAL;
1465 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001466 }
1467
1468 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1469 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1470 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1471 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1472 == eHAL_STATUS_FAILURE)
1473 {
1474 hddLog(LOGE,
1475 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001476 ret = -EINVAL;
1477 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 }
1479 }
1480 else
1481 {
1482 hddLog(VOS_TRACE_LEVEL_INFO,
1483 "%s: No Assoc Response IE received in set beacon",
1484 __func__);
1485
1486 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1487 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1488 eANI_BOOLEAN_FALSE) )
1489 {
1490 hddLog(LOGE,
1491 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1492 }
1493 }
1494
Jeff Johnsone7245742012-09-05 17:12:55 -07001495done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301497 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001498}
Jeff Johnson295189b2012-06-20 16:38:30 -07001499
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301500/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 * FUNCTION: wlan_hdd_validate_operation_channel
1502 * called by wlan_hdd_cfg80211_start_bss() and
1503 * wlan_hdd_cfg80211_set_channel()
1504 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301505 * channel list.
1506 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001507VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001508{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301509
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 v_U32_t num_ch = 0;
1511 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1512 u32 indx = 0;
1513 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301514 v_U8_t fValidChannel = FALSE, count = 0;
1515 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301516
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1518
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301519 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001520 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301521 /* Validate the channel */
1522 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301524 if ( channel == rfChannels[count].channelNum )
1525 {
1526 fValidChannel = TRUE;
1527 break;
1528 }
1529 }
1530 if (fValidChannel != TRUE)
1531 {
1532 hddLog(VOS_TRACE_LEVEL_ERROR,
1533 "%s: Invalid Channel [%d]", __func__, channel);
1534 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 }
1536 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301537 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001538 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301539 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1540 valid_ch, &num_ch))
1541 {
1542 hddLog(VOS_TRACE_LEVEL_ERROR,
1543 "%s: failed to get valid channel list", __func__);
1544 return VOS_STATUS_E_FAILURE;
1545 }
1546 for (indx = 0; indx < num_ch; indx++)
1547 {
1548 if (channel == valid_ch[indx])
1549 {
1550 break;
1551 }
1552 }
1553
1554 if (indx >= num_ch)
1555 {
1556 hddLog(VOS_TRACE_LEVEL_ERROR,
1557 "%s: Invalid Channel [%d]", __func__, channel);
1558 return VOS_STATUS_E_FAILURE;
1559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001560 }
1561 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301562
Jeff Johnson295189b2012-06-20 16:38:30 -07001563}
1564
Viral Modi3a32cc52013-02-08 11:14:52 -08001565/**
1566 * FUNCTION: wlan_hdd_cfg80211_set_channel
1567 * This function is used to set the channel number
1568 */
1569static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1570 struct ieee80211_channel *chan,
1571 enum nl80211_channel_type channel_type
1572 )
1573{
1574 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001575 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001576 hdd_adapter_t *pAdapter = NULL;
1577 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301578 hdd_context_t *pHddCtx;
1579 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001580
1581 ENTER();
1582
1583 if( NULL == dev )
1584 {
1585 hddLog(VOS_TRACE_LEVEL_ERROR,
1586 "%s: Called with dev = NULL.\n", __func__);
1587 return -ENODEV;
1588 }
1589 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1590
1591 hddLog(VOS_TRACE_LEVEL_INFO,
1592 "%s: device_mode = %d freq = %d \n",__func__,
1593 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301594
1595 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1596 status = wlan_hdd_validate_context(pHddCtx);
1597
1598 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001599 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301600 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1601 "%s: HDD context is not valid", __func__);
1602 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001603 }
1604
1605 /*
1606 * Do freq to chan conversion
1607 * TODO: for 11a
1608 */
1609
1610 channel = ieee80211_frequency_to_channel(freq);
1611
1612 /* Check freq range */
1613 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1614 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1615 {
1616 hddLog(VOS_TRACE_LEVEL_ERROR,
1617 "%s: Channel [%d] is outside valid range from %d to %d\n",
1618 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1619 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1620 return -EINVAL;
1621 }
1622
1623 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1624
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301625 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1626 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001627 {
1628 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1629 {
1630 hddLog(VOS_TRACE_LEVEL_ERROR,
1631 "%s: Invalid Channel [%d] \n", __func__, channel);
1632 return -EINVAL;
1633 }
1634 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1635 "%s: set channel to [%d] for device mode =%d",
1636 __func__, channel,pAdapter->device_mode);
1637 }
1638 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001639 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001640 )
1641 {
1642 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1643 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1644 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1645
1646 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1647 {
1648 /* Link is up then return cant set channel*/
1649 hddLog( VOS_TRACE_LEVEL_ERROR,
1650 "%s: IBSS Associated, can't set the channel\n", __func__);
1651 return -EINVAL;
1652 }
1653
1654 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1655 pHddStaCtx->conn_info.operationChannel = channel;
1656 pRoamProfile->ChannelInfo.ChannelList =
1657 &pHddStaCtx->conn_info.operationChannel;
1658 }
1659 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001660 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001661 )
1662 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301663 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1664 {
1665 if(VOS_STATUS_SUCCESS !=
1666 wlan_hdd_validate_operation_channel(pAdapter,channel))
1667 {
1668 hddLog(VOS_TRACE_LEVEL_ERROR,
1669 "%s: Invalid Channel [%d] \n", __func__, channel);
1670 return -EINVAL;
1671 }
1672 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1673 }
1674 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001675 {
1676 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1677
1678 /* If auto channel selection is configured as enable/ 1 then ignore
1679 channel set by supplicant
1680 */
1681 if ( cfg_param->apAutoChannelSelection )
1682 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301683 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1684 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001685 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1686 "%s: set channel to auto channel (0) for device mode =%d",
1687 __func__, pAdapter->device_mode);
1688 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301689 else
1690 {
1691 if(VOS_STATUS_SUCCESS !=
1692 wlan_hdd_validate_operation_channel(pAdapter,channel))
1693 {
1694 hddLog(VOS_TRACE_LEVEL_ERROR,
1695 "%s: Invalid Channel [%d] \n", __func__, channel);
1696 return -EINVAL;
1697 }
1698 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1699 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001700 }
1701 }
1702 else
1703 {
1704 hddLog(VOS_TRACE_LEVEL_FATAL,
1705 "%s: Invalid device mode failed to set valid channel", __func__);
1706 return -EINVAL;
1707 }
1708 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301709 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001710}
1711
Jeff Johnson295189b2012-06-20 16:38:30 -07001712#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1713static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1714 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001715#else
1716static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1717 struct cfg80211_beacon_data *params,
1718 const u8 *ssid, size_t ssid_len,
1719 enum nl80211_hidden_ssid hidden_ssid)
1720#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001721{
1722 tsap_Config_t *pConfig;
1723 beacon_data_t *pBeacon = NULL;
1724 struct ieee80211_mgmt *pMgmt_frame;
1725 v_U8_t *pIe=NULL;
1726 v_U16_t capab_info;
1727 eCsrAuthType RSNAuthType;
1728 eCsrEncryptionType RSNEncryptType;
1729 eCsrEncryptionType mcRSNEncryptType;
1730 int status = VOS_STATUS_SUCCESS;
1731 tpWLAN_SAPEventCB pSapEventCallback;
1732 hdd_hostapd_state_t *pHostapdState;
1733 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1734 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301735 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001736 struct qc_mac_acl_entry *acl_entry = NULL;
1737 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001738 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001739
1740 ENTER();
1741
1742 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1743
1744 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1745
1746 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1747
1748 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1749
1750 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1751
1752 //channel is already set in the set_channel Call back
1753 //pConfig->channel = pCommitConfig->channel;
1754
1755 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301756 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001757 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1758
1759 pConfig->dtim_period = pBeacon->dtim_period;
1760
1761 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1762 pConfig->dtim_period);
1763
1764
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001765 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001766 {
1767 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 WLAN_EID_COUNTRY);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001769 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001771 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001772 pConfig->ieee80211d = 1;
1773 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1774 sme_setRegInfo(hHal, pConfig->countryCode);
1775 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001777 else
1778 {
1779 pConfig->ieee80211d = 0;
1780 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301781 /*
1782 * If auto channel is configured i.e. channel is 0,
1783 * so skip channel validation.
1784 */
1785 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1786 {
1787 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1788 {
1789 hddLog(VOS_TRACE_LEVEL_ERROR,
1790 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1791 return -EINVAL;
1792 }
1793 }
1794 else
1795 {
1796 if(1 != pHddCtx->is_dynamic_channel_range_set)
1797 {
1798 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1799 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1800 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1801 }
1802 pHddCtx->is_dynamic_channel_range_set = 0;
1803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001805 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 {
1807 pConfig->ieee80211d = 0;
1808 }
1809 pConfig->authType = eSAP_AUTO_SWITCH;
1810
1811 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301812
1813 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1815
1816 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1817
1818 /*Set wps station to configured*/
1819 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1820
1821 if(pIe)
1822 {
1823 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1824 {
1825 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1826 return -EINVAL;
1827 }
1828 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1829 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001830 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 /* Check 15 bit of WPS IE as it contain information for wps state
1832 * WPS state
1833 */
1834 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1835 {
1836 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1837 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1838 {
1839 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1840 }
1841 }
1842 }
1843 else
1844 {
1845 pConfig->wps_state = SAP_WPS_DISABLED;
1846 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301847 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001848
1849 pConfig->RSNWPAReqIELength = 0;
1850 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301851 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 WLAN_EID_RSN);
1853 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301854 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1856 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1857 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301858 /* The actual processing may eventually be more extensive than
1859 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001860 * by the app.
1861 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301862 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1864 &RSNEncryptType,
1865 &mcRSNEncryptType,
1866 &RSNAuthType,
1867 pConfig->pRSNWPAReqIE[1]+2,
1868 pConfig->pRSNWPAReqIE );
1869
1870 if( VOS_STATUS_SUCCESS == status )
1871 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301872 /* Now copy over all the security attributes you have
1873 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 * */
1875 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1876 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1877 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1878 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301879 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 "EncryptionType = %d mcEncryptionType = %d\n"),
1881 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1882 }
1883 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301884
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1886 pBeacon->tail, pBeacon->tail_len);
1887
1888 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1889 {
1890 if (pConfig->pRSNWPAReqIE)
1891 {
1892 /*Mixed mode WPA/WPA2*/
1893 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1894 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1895 }
1896 else
1897 {
1898 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1899 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1900 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301901 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001902 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1903 &RSNEncryptType,
1904 &mcRSNEncryptType,
1905 &RSNAuthType,
1906 pConfig->pRSNWPAReqIE[1]+2,
1907 pConfig->pRSNWPAReqIE );
1908
1909 if( VOS_STATUS_SUCCESS == status )
1910 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301911 /* Now copy over all the security attributes you have
1912 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 * */
1914 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1915 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1916 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1917 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301918 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 "EncryptionType = %d mcEncryptionType = %d\n"),
1920 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1921 }
1922 }
1923 }
1924
Jeff Johnson4416a782013-03-25 14:17:50 -07001925 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1926 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1927 return -EINVAL;
1928 }
1929
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1931
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001932#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 if (params->ssid != NULL)
1934 {
1935 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1936 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1937 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1938 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1939 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001940#else
1941 if (ssid != NULL)
1942 {
1943 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1944 pConfig->SSIDinfo.ssid.length = ssid_len;
1945 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1946 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1947 }
1948#endif
1949
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301950 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301952
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 /* default value */
1954 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1955 pConfig->num_accept_mac = 0;
1956 pConfig->num_deny_mac = 0;
1957
1958 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1959 pBeacon->tail, pBeacon->tail_len);
1960
1961 /* pIe for black list is following form:
1962 type : 1 byte
1963 length : 1 byte
1964 OUI : 4 bytes
1965 acl type : 1 byte
1966 no of mac addr in black list: 1 byte
1967 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301968 */
1969 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001970 {
1971 pConfig->SapMacaddr_acl = pIe[6];
1972 pConfig->num_deny_mac = pIe[7];
1973 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
1974 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05301975 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
1976 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
1978 for (i = 0; i < pConfig->num_deny_mac; i++)
1979 {
1980 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
1981 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 }
1984 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1985 pBeacon->tail, pBeacon->tail_len);
1986
1987 /* pIe for white list is following form:
1988 type : 1 byte
1989 length : 1 byte
1990 OUI : 4 bytes
1991 acl type : 1 byte
1992 no of mac addr in white list: 1 byte
1993 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301994 */
1995 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001996 {
1997 pConfig->SapMacaddr_acl = pIe[6];
1998 pConfig->num_accept_mac = pIe[7];
1999 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
2000 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302001 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2002 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002003 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2004 for (i = 0; i < pConfig->num_accept_mac; i++)
2005 {
2006 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2007 acl_entry++;
2008 }
2009 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302010
Jeff Johnson295189b2012-06-20 16:38:30 -07002011 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2012
Jeff Johnsone7245742012-09-05 17:12:55 -07002013#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002014 /* Overwrite the hostapd setting for HW mode only for 11ac.
2015 * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini .
2016 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */
2017 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2018 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302019 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002020 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
2021 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002022 {
2023 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002024
2025 /* Disable VHT support in 2.4 GHz band */
2026 if (pConfig->channel <= 14 &&
2027 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2028 {
2029 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2030 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002031 }
2032#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302033
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002034 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2035 {
2036 sme_SelectCBMode(hHal,
2037 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2038 pConfig->channel);
2039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002040 // ht_capab is not what the name conveys,this is used for protection bitmap
2041 pConfig->ht_capab =
2042 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2043
2044 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2045 {
2046 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2047 return -EINVAL;
2048 }
2049
2050 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302051 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2053 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302054 pConfig->obssProtEnabled =
2055 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002056
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302057 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302059 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
2061 (int)pConfig->channel);
2062 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302063 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
2064 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302066 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
2068 pConfig->protEnabled, pConfig->obssProtEnabled);
2069
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302070 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 {
2072 //Bss already started. just return.
2073 //TODO Probably it should update some beacon params.
2074 hddLog( LOGE, "Bss Already started...Ignore the request");
2075 EXIT();
2076 return 0;
2077 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302078
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 pConfig->persona = pHostapdAdapter->device_mode;
2080
2081 pSapEventCallback = hdd_hostapd_SAPEventCB;
2082 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2083 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2084 {
2085 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2086 return -EINVAL;
2087 }
2088
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302089 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2091
2092 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302093
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302095 {
2096 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 ("ERROR: HDD vos wait for single_event failed!!\n"));
2098 VOS_ASSERT(0);
2099 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302100
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 //Succesfully started Bss update the state bit.
2102 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2103
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002104#ifdef WLAN_FEATURE_P2P_DEBUG
2105 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2106 {
2107 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2108 {
2109 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2110 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002111 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002112 }
2113 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2114 {
2115 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2116 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002117 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002118 }
2119 }
2120#endif
2121
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 pHostapdState->bCommit = TRUE;
2123 EXIT();
2124
2125 return 0;
2126}
2127
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002128#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302129static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2130 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 struct beacon_parameters *params)
2132{
2133 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302134 hdd_context_t *pHddCtx;
2135 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002136
2137 ENTER();
2138
2139 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
2140
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302141 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2142 status = wlan_hdd_validate_context(pHddCtx);
2143
2144 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002145 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302146 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2147 "%s: HDD context is not valid", __func__);
2148 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002149 }
2150
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302151 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002152 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 )
2154 {
2155 beacon_data_t *old,*new;
2156
2157 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302158
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 if (old)
2160 return -EALREADY;
2161
2162 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2163
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302164 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 {
2166 hddLog(VOS_TRACE_LEVEL_FATAL,
2167 "%s:Error!!! Allocating the new beacon\n",__func__);
2168 return -EINVAL;
2169 }
2170
2171 pAdapter->sessionCtx.ap.beacon = new;
2172
2173 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2174 }
2175
2176 EXIT();
2177 return status;
2178}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302179
2180static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002181 struct net_device *dev,
2182 struct beacon_parameters *params)
2183{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302184 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302185 hdd_context_t *pHddCtx;
2186 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002187
2188 ENTER();
2189
2190 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2191 __func__,pAdapter->device_mode);
2192
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302193 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2194 status = wlan_hdd_validate_context(pHddCtx);
2195
2196 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002197 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302198 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2199 "%s: HDD context is not valid", __func__);
2200 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002201 }
2202
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302203 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302205 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 {
2207 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302208
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302210
Jeff Johnson295189b2012-06-20 16:38:30 -07002211 if (!old)
2212 return -ENOENT;
2213
2214 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2215
2216 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302217 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 "%s: Error!!! Allocating the new beacon\n",__func__);
2219 return -EINVAL;
2220 }
2221
2222 pAdapter->sessionCtx.ap.beacon = new;
2223
2224 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2225 }
2226
2227 EXIT();
2228 return status;
2229}
2230
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002231#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2232
2233#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002234static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2235 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002236#else
2237static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2238 struct net_device *dev)
2239#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002240{
2241 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002242 hdd_context_t *pHddCtx = NULL;
2243 hdd_scaninfo_t *pScanInfo = NULL;
2244 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302245 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002246
2247 ENTER();
2248
2249 if (NULL == pAdapter)
2250 {
2251 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002252 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 return -ENODEV;
2254 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002255
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302256 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2257 status = wlan_hdd_validate_context(pHddCtx);
2258
2259 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002260 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302261 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2262 "%s: HDD context is not valid", __func__);
2263 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002264 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002265
2266 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2267 if (NULL == staAdapter)
2268 {
2269 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2270 if (NULL == staAdapter)
2271 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302272 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002273 "%s: HDD adapter context is Null", __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002274 return -ENODEV;
2275 }
2276 }
2277
2278 pScanInfo = &pHddCtx->scan_info;
2279
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2281 __func__,pAdapter->device_mode);
2282
Jeff Johnsone7245742012-09-05 17:12:55 -07002283 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
2284 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002285 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Jeff Johnsone7245742012-09-05 17:12:55 -07002286 hdd_abort_mac_scan(staAdapter->pHddCtx);
2287 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002288 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002289 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2290 if (!status)
2291 {
2292 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson902c9832012-12-10 14:28:09 -08002293 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002294 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002295 VOS_ASSERT(pScanInfo->mScanPending);
2296 return 0;
2297 }
2298 }
2299
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002301 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 )
2303 {
2304 beacon_data_t *old;
2305
2306 old = pAdapter->sessionCtx.ap.beacon;
2307
2308 if (!old)
2309 return -ENOENT;
2310
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002312
2313 mutex_lock(&pHddCtx->sap_lock);
2314 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2315 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002316 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 {
2318 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2319
2320 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2321
2322 if (!VOS_IS_STATUS_SUCCESS(status))
2323 {
2324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2325 ("ERROR: HDD vos wait for single_event failed!!\n"));
2326 VOS_ASSERT(0);
2327 }
2328 }
2329 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2330 }
2331 mutex_unlock(&pHddCtx->sap_lock);
2332
2333 if(status != VOS_STATUS_SUCCESS)
2334 {
2335 hddLog(VOS_TRACE_LEVEL_FATAL,
2336 "%s:Error!!! Stopping the BSS\n",__func__);
2337 return -EINVAL;
2338 }
2339
Jeff Johnson4416a782013-03-25 14:17:50 -07002340 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2342 ==eHAL_STATUS_FAILURE)
2343 {
2344 hddLog(LOGE,
2345 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2346 }
2347
Jeff Johnson4416a782013-03-25 14:17:50 -07002348 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2350 eANI_BOOLEAN_FALSE) )
2351 {
2352 hddLog(LOGE,
2353 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2354 }
2355
2356 // Reset WNI_CFG_PROBE_RSP Flags
2357 wlan_hdd_reset_prob_rspies(pAdapter);
2358
2359 pAdapter->sessionCtx.ap.beacon = NULL;
2360 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002361#ifdef WLAN_FEATURE_P2P_DEBUG
2362 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2363 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2364 {
2365 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2366 "GO got removed");
2367 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2368 }
2369#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002370 }
2371 EXIT();
2372 return status;
2373}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002374
2375#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2376
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302377static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2378 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002379 struct cfg80211_ap_settings *params)
2380{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302381 hdd_adapter_t *pAdapter;
2382 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302383 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002384
2385 ENTER();
2386
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302387 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002388 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302389 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302390 "%s: Device is Null", __func__);
2391 return -ENODEV;
2392 }
2393
2394 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2395 if (NULL == pAdapter)
2396 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302397 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302398 "%s: HDD adapter is Null", __func__);
2399 return -ENODEV;
2400 }
2401
2402 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2403 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302404 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302405 "%s: HDD adapter magic is invalid", __func__);
2406 return -ENODEV;
2407 }
2408
2409 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302410 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302411
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302412 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302413 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302414 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2415 "%s: HDD context is not valid", __func__);
2416 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302417 }
2418
2419 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2420 __func__, pAdapter->device_mode);
2421
2422 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002423 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002424 )
2425 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302426 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002427
2428 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302429
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002430 if (old)
2431 return -EALREADY;
2432
2433 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2434
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302435 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002436 {
2437 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302438 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002439 return -EINVAL;
2440 }
2441 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002442#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002443 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2444#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2445 params->channel, params->channel_type);
2446#else
2447 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2448#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002449#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002450 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2451 params->ssid_len, params->hidden_ssid);
Gopichand Nakkala8c0386c2013-07-09 23:31:37 +05302452 if (0 == status)
2453 {
2454 hdd_start_p2p_go_connection_in_progress_timer(pAdapter);
2455 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002456 }
2457
2458 EXIT();
2459 return status;
2460}
2461
2462
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302463static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002464 struct net_device *dev,
2465 struct cfg80211_beacon_data *params)
2466{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302467 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302468 hdd_context_t *pHddCtx;
2469 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002470
2471 ENTER();
2472
2473 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2474 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302475
2476 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2477 status = wlan_hdd_validate_context(pHddCtx);
2478
2479 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002480 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302481 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2482 "%s: HDD context is not valid", __func__);
2483 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002484 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002485
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302486 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002487 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302488 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002489 {
2490 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302491
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002492 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302493
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002494 if (!old)
2495 return -ENOENT;
2496
2497 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2498
2499 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302500 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002501 "%s: Error!!! Allocating the new beacon\n",__func__);
2502 return -EINVAL;
2503 }
2504
2505 pAdapter->sessionCtx.ap.beacon = new;
2506
2507 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2508 }
2509
2510 EXIT();
2511 return status;
2512}
2513
2514#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2515
Jeff Johnson295189b2012-06-20 16:38:30 -07002516
2517static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2518 struct net_device *dev,
2519 struct bss_parameters *params)
2520{
2521 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2522
2523 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302524
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2526 __func__,pAdapter->device_mode);
2527
2528 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002529 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302530 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002531 {
2532 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2533 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302534 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 {
2536 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 }
2539
2540 EXIT();
2541 return 0;
2542}
2543
2544/*
2545 * FUNCTION: wlan_hdd_cfg80211_change_iface
2546 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2547 */
2548int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2549 struct net_device *ndev,
2550 enum nl80211_iftype type,
2551 u32 *flags,
2552 struct vif_params *params
2553 )
2554{
2555 struct wireless_dev *wdev;
2556 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2557 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002558 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 tCsrRoamProfile *pRoamProfile = NULL;
2560 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302561 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 eMib_dot11DesiredBssType connectedBssType;
2563 VOS_STATUS status;
2564
2565 ENTER();
2566
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302567 status = wlan_hdd_validate_context(pHddCtx);
2568
2569 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302571 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2572 "%s: HDD context is not valid", __func__);
2573 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 }
2575
2576 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2577 __func__, pAdapter->device_mode);
2578
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302579 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 wdev = ndev->ieee80211_ptr;
2581
2582#ifdef WLAN_BTAMP_FEATURE
2583 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2584 (NL80211_IFTYPE_ADHOC == type)||
2585 (NL80211_IFTYPE_AP == type)||
2586 (NL80211_IFTYPE_P2P_GO == type))
2587 {
2588 pHddCtx->isAmpAllowed = VOS_FALSE;
2589 // stop AMP traffic
2590 status = WLANBAP_StopAmp();
2591 if(VOS_STATUS_SUCCESS != status )
2592 {
2593 pHddCtx->isAmpAllowed = VOS_TRUE;
2594 hddLog(VOS_TRACE_LEVEL_FATAL,
2595 "%s: Failed to stop AMP", __func__);
2596 return -EINVAL;
2597 }
2598 }
2599#endif //WLAN_BTAMP_FEATURE
2600 /* Reset the current device mode bit mask*/
2601 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2602
2603 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002605 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 )
2607 {
2608 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2609 pRoamProfile = &pWextState->roamProfile;
2610 LastBSSType = pRoamProfile->BSSType;
2611
2612 switch (type)
2613 {
2614 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 hddLog(VOS_TRACE_LEVEL_INFO,
2617 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2618 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002619#ifdef WLAN_FEATURE_11AC
2620 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2621 {
2622 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2623 }
2624#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302625 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002626 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002628 //Check for sub-string p2p to confirm its a p2p interface
2629 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302630 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002631 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2632 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2633 }
2634 else
2635 {
2636 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002638 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302639#ifdef FEATURE_WLAN_TDLS
2640 /* The open adapter for the p2p shall skip initializations in
2641 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2642 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2643 * tdls_init when the change_iface sets the device mode to
2644 * WLAN_HDD_P2P_CLIENT.
2645 */
2646
2647 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2648 {
2649 if (0 != wlan_hdd_tdls_init (pAdapter))
2650 {
2651 return -EINVAL;
2652 }
2653 }
2654#endif
2655
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 break;
2657 case NL80211_IFTYPE_ADHOC:
2658 hddLog(VOS_TRACE_LEVEL_INFO,
2659 "%s: setting interface Type to ADHOC", __func__);
2660 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2661 pRoamProfile->phyMode =
2662 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002663 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002664 wdev->iftype = type;
2665 break;
2666
2667 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 {
2670 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2671 "%s: setting interface Type to %s", __func__,
2672 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2673
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002674 //Cancel any remain on channel for GO mode
2675 if (NL80211_IFTYPE_P2P_GO == type)
2676 {
2677 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2678 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002679 if (NL80211_IFTYPE_AP == type)
2680 {
2681 /* As Loading WLAN Driver one interface being created for p2p device
2682 * address. This will take one HW STA and the max number of clients
2683 * that can connect to softAP will be reduced by one. so while changing
2684 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2685 * interface as it is not required in SoftAP mode.
2686 */
2687
2688 // Get P2P Adapter
2689 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2690
2691 if (pP2pAdapter)
2692 {
2693 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2694 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2695 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2696 }
2697 }
2698
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 //De-init the adapter.
2700 hdd_stop_adapter( pHddCtx, pAdapter );
2701 hdd_deinit_adapter( pHddCtx, pAdapter );
2702 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2704 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002705
2706 //Disable BMPS and IMPS if enabled
2707 //before starting Go
2708 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2709 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302710 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002711 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2712 {
2713 //Fail to Exit BMPS
2714 VOS_ASSERT(0);
2715 }
2716 }
2717
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002718 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2719 (pConfig->apRandomBssidEnabled))
2720 {
2721 /* To meet Android requirements create a randomized
2722 MAC address of the form 02:1A:11:Fx:xx:xx */
2723 get_random_bytes(&ndev->dev_addr[3], 3);
2724 ndev->dev_addr[0] = 0x02;
2725 ndev->dev_addr[1] = 0x1A;
2726 ndev->dev_addr[2] = 0x11;
2727 ndev->dev_addr[3] |= 0xF0;
2728 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2729 VOS_MAC_ADDR_SIZE);
2730 pr_info("wlan: Generated HotSpot BSSID "
2731 "%02x:%02x:%02x:%02x:%02x:%02x\n",
2732 ndev->dev_addr[0],
2733 ndev->dev_addr[1],
2734 ndev->dev_addr[2],
2735 ndev->dev_addr[3],
2736 ndev->dev_addr[4],
2737 ndev->dev_addr[5]);
2738 }
2739
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 hdd_set_ap_ops( pAdapter->dev );
2741
2742 status = hdd_init_ap_mode(pAdapter);
2743 if(status != VOS_STATUS_SUCCESS)
2744 {
2745 hddLog(VOS_TRACE_LEVEL_FATAL,
2746 "%s: Error initializing the ap mode", __func__);
2747 return -EINVAL;
2748 }
2749 hdd_set_conparam(1);
2750
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 /*interface type changed update in wiphy structure*/
2752 if(wdev)
2753 {
2754 wdev->iftype = type;
2755 pHddCtx->change_iface = type;
2756 }
2757 else
2758 {
2759 hddLog(VOS_TRACE_LEVEL_ERROR,
2760 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2761 return -EINVAL;
2762 }
2763 goto done;
2764 }
2765
2766 default:
2767 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2768 __func__);
2769 return -EOPNOTSUPP;
2770 }
2771 }
2772 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 )
2775 {
2776 switch(type)
2777 {
2778 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 case NL80211_IFTYPE_ADHOC:
Jeff Johnson32d95a32012-09-10 13:15:23 -07002781 hdd_stop_adapter( pHddCtx, pAdapter );
2782 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002784 //Check for sub-string p2p to confirm its a p2p interface
2785 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002786 {
2787 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2788 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2789 }
2790 else
2791 {
2792 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002793 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 hdd_set_conparam(0);
2796 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2798 hdd_set_station_ops( pAdapter->dev );
2799 status = hdd_init_station_mode( pAdapter );
2800 if( VOS_STATUS_SUCCESS != status )
2801 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002802 /* In case of JB, for P2P-GO, only change interface will be called,
2803 * This is the right place to enable back bmps_imps()
2804 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302805 if (pHddCtx->hdd_wlan_suspended)
2806 {
2807 hdd_set_pwrparams(pHddCtx);
2808 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002809 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 goto done;
2811 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002813 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2815 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 goto done;
2817 default:
2818 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2819 __func__);
2820 return -EOPNOTSUPP;
2821
2822 }
2823
2824 }
2825 else
2826 {
2827 return -EOPNOTSUPP;
2828 }
2829
2830
2831 if(pRoamProfile)
2832 {
2833 if ( LastBSSType != pRoamProfile->BSSType )
2834 {
2835 /*interface type changed update in wiphy structure*/
2836 wdev->iftype = type;
2837
2838 /*the BSS mode changed, We need to issue disconnect
2839 if connected or in IBSS disconnect state*/
2840 if ( hdd_connGetConnectedBssType(
2841 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2842 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2843 {
2844 /*need to issue a disconnect to CSR.*/
2845 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2846 if( eHAL_STATUS_SUCCESS ==
2847 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2848 pAdapter->sessionId,
2849 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2850 {
2851 wait_for_completion_interruptible_timeout(
2852 &pAdapter->disconnect_comp_var,
2853 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2854 }
2855 }
2856 }
2857 }
2858
2859done:
2860 /*set bitmask based on updated value*/
2861 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002862
2863 /* Only STA mode support TM now
2864 * all other mode, TM feature should be disabled */
2865 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2866 (~VOS_STA & pHddCtx->concurrency_mode) )
2867 {
2868 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2869 }
2870
Jeff Johnson295189b2012-06-20 16:38:30 -07002871#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302872 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2874 {
2875 //we are ok to do AMP
2876 pHddCtx->isAmpAllowed = VOS_TRUE;
2877 }
2878#endif //WLAN_BTAMP_FEATURE
2879 EXIT();
2880 return 0;
2881}
2882
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002883#ifdef FEATURE_WLAN_TDLS
2884static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2885 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2886{
2887 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2888 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2889 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002890 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002891
2892 ENTER();
2893
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302894 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002895 {
2896 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2897 "Invalid arguments");
2898 return -EINVAL;
2899 }
Hoonki Lee27511902013-03-14 18:19:06 -07002900
2901 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
2902 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
2903 {
2904 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2905 "%s: TDLS mode is disabled OR not enabled in FW."
2906 MAC_ADDRESS_STR " Request declined.",
2907 __func__, MAC_ADDR_ARRAY(mac));
2908 return -ENOTSUPP;
2909 }
2910
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002911 if (pHddCtx->isLogpInProgress)
2912 {
2913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2914 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07002915 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002916 return -EBUSY;
2917 }
2918
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002919 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac);
2920
2921 if ( NULL == pTdlsPeer ) {
2922 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2923 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
2924 __func__, MAC_ADDR_ARRAY(mac), update);
2925 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002926 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002927
2928 /* in add station, we accept existing valid staId if there is */
2929 if ((0 == update) &&
2930 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
2931 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002932 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002933 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002934 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002935 " link_status %d. staId %d. add station ignored.",
2936 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
2937 return 0;
2938 }
2939 /* in change station, we accept only when staId is valid */
2940 if ((1 == update) &&
2941 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
2942 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
2943 {
2944 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2945 "%s: " MAC_ADDRESS_STR
2946 " link status %d. staId %d. change station %s.",
2947 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
2948 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
2949 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002950 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002951
2952 /* when others are on-going, we want to change link_status to idle */
Hoonki Leefb8df672013-04-10 18:20:34 -07002953 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002954 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002955 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2956 "%s: " MAC_ADDRESS_STR
2957 " TDLS setup is ongoing. Request declined.",
2958 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07002959 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002960 }
2961
2962 /* first to check if we reached to maximum supported TDLS peer.
2963 TODO: for now, return -EPERM looks working fine,
2964 but need to check if any other errno fit into this category.*/
2965 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
2966 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002967 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2968 "%s: " MAC_ADDRESS_STR
2969 " TDLS Max peer already connected. Request declined.",
2970 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07002971 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002972 }
2973 else
2974 {
2975 hddTdlsPeer_t *pTdlsPeer;
2976 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002977 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002978 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002979 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2980 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
2981 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002982 return -EPERM;
2983 }
2984 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002985 if (0 == update)
2986 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002987
Jeff Johnsond75fe012013-04-06 10:53:06 -07002988 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302989 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002990 {
2991 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2992 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07002993 if(StaParams->htcap_present)
2994 {
2995 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2996 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
2997 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2998 "ht_capa->extended_capabilities: %0x",
2999 StaParams->HTCap.extendedHtCapInfo);
3000 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003001 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3002 "params->capability: %0x",StaParams->capability);
3003 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3004 "params->ext_capab_len: %0x",StaParams->extn_capability);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003005 if(StaParams->vhtcap_present)
3006 {
3007 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3008 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3009 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3010 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3011 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003012 {
3013 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003014 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003015 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3016 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3017 "[%d]: %x ", i, StaParams->supported_rates[i]);
3018 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003019 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303020 else if ((1 == update) && (NULL == StaParams))
3021 {
3022 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3023 "%s : update is true, but staParams is NULL. Error!", __func__);
3024 return -EPERM;
3025 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003026
3027 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3028
3029 if (!update)
3030 {
3031 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3032 pAdapter->sessionId, mac);
3033 }
3034 else
3035 {
3036 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3037 pAdapter->sessionId, mac, StaParams);
3038 }
3039
3040 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
3041 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3042
3043 if (!status)
3044 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003045 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003046 "%s: timeout waiting for tdls add station indication",
3047 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003048 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003049 }
3050 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3051 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003052 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003053 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003054 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003055 }
3056
3057 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003058
3059error:
3060 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3061 return -EPERM;
3062
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003063}
3064#endif
3065
Jeff Johnson295189b2012-06-20 16:38:30 -07003066static int wlan_hdd_change_station(struct wiphy *wiphy,
3067 struct net_device *dev,
3068 u8 *mac,
3069 struct station_parameters *params)
3070{
3071 VOS_STATUS status = VOS_STATUS_SUCCESS;
3072 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303073 hdd_context_t *pHddCtx;
3074 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003075 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003076#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003077 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003078 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003079#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003080 ENTER();
3081
Gopichand Nakkala29149562013-05-10 21:43:41 +05303082 if ((NULL == pAdapter))
3083 {
3084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3085 "invalid adapter ");
3086 return -EINVAL;
3087 }
3088
3089 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3090 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3091
3092 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3093 {
3094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3095 "invalid HDD state or HDD station context");
3096 return -EINVAL;
3097 }
3098
3099 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003100 {
3101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3102 "%s:LOGP in Progress. Ignore!!!", __func__);
3103 return -EAGAIN;
3104 }
3105
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3107
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003108 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3109 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003111 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303113 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 WLANTL_STA_AUTHENTICATED);
3115
Gopichand Nakkala29149562013-05-10 21:43:41 +05303116 if (status != VOS_STATUS_SUCCESS)
3117 {
3118 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3119 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3120 return -EINVAL;
3121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 }
3123 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003124 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3125 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303126#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003127 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3128 StaParams.capability = params->capability;
3129 StaParams.uapsd_queues = params->uapsd_queues;
3130 StaParams.max_sp = params->max_sp;
3131
3132 if (0 != params->ext_capab_len)
3133 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3134 sizeof(StaParams.extn_capability));
3135
3136 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003137 {
3138 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003139 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003140 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003141
3142 StaParams.supported_rates_len = params->supported_rates_len;
3143
3144 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3145 * The supported_rates array , for all the structures propogating till Add Sta
3146 * to the firmware has to be modified , if the supplicant (ieee80211) is
3147 * modified to send more rates.
3148 */
3149
3150 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3151 */
3152 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3153 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3154
3155 if (0 != StaParams.supported_rates_len) {
3156 int i = 0;
3157 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3158 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003159 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003160 "Supported Rates with Length %d", StaParams.supported_rates_len);
3161 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003162 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003163 "[%d]: %0x", i, StaParams.supported_rates[i]);
3164 }
3165
3166 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003167 {
3168 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003169 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003170 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003171
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003172 if (0 != params->ext_capab_len ) {
3173 /*Define A Macro : TODO Sunil*/
3174 if ((1<<4) & StaParams.extn_capability[3]) {
3175 isBufSta = 1;
3176 }
3177 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303178 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3179 params->max_sp, isBufSta);
3180 if (VOS_STATUS_SUCCESS != status) {
3181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3182 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3183 return -EINVAL;
3184 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003185 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3186
3187 if (VOS_STATUS_SUCCESS != status) {
3188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3189 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3190 return -EINVAL;
3191 }
3192 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003193#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303194 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003195 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 return status;
3197}
3198
3199/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 * FUNCTION: wlan_hdd_cfg80211_add_key
3201 * This function is used to initialize the key information
3202 */
3203#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003204static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 struct net_device *ndev,
3206 u8 key_index, bool pairwise,
3207 const u8 *mac_addr,
3208 struct key_params *params
3209 )
3210#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003211static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 struct net_device *ndev,
3213 u8 key_index, const u8 *mac_addr,
3214 struct key_params *params
3215 )
3216#endif
3217{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003218 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 tCsrRoamSetKey setKey;
3220 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303221 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003222 v_U32_t roamId= 0xFF;
3223 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 hdd_hostapd_state_t *pHostapdState;
3225 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003226 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303227 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003228
3229 ENTER();
3230
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303231 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3232 status = wlan_hdd_validate_context(pHddCtx);
3233
3234 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003235 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303236 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3237 "%s: HDD context is not valid", __func__);
3238 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003239 }
3240
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003241 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3242 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003243
3244 if (CSR_MAX_NUM_KEY <= key_index)
3245 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003246 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 key_index);
3248
3249 return -EINVAL;
3250 }
3251
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003252 if (CSR_MAX_KEY_LEN < params->key_len)
3253 {
3254 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3255 params->key_len);
3256
3257 return -EINVAL;
3258 }
3259
3260 hddLog(VOS_TRACE_LEVEL_INFO,
3261 "%s: called with key index = %d & key length %d",
3262 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003263
3264 /*extract key idx, key len and key*/
3265 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3266 setKey.keyId = key_index;
3267 setKey.keyLength = params->key_len;
3268 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3269
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003270 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 {
3272 case WLAN_CIPHER_SUITE_WEP40:
3273 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3274 break;
3275
3276 case WLAN_CIPHER_SUITE_WEP104:
3277 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3278 break;
3279
3280 case WLAN_CIPHER_SUITE_TKIP:
3281 {
3282 u8 *pKey = &setKey.Key[0];
3283 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3284
3285 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3286
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003287 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003288
3289 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003290 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 |--------------|----------|----------|
3292 <---16bytes---><--8bytes--><--8bytes-->
3293
3294 */
3295 /*Sme expects the 32 bytes key to be in the below order
3296
3297 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003298 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 |--------------|----------|----------|
3300 <---16bytes---><--8bytes--><--8bytes-->
3301 */
3302 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003303 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003304
3305 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003306 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003307
3308 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003309 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003310
3311
3312 break;
3313 }
3314
3315 case WLAN_CIPHER_SUITE_CCMP:
3316 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3317 break;
3318
3319#ifdef FEATURE_WLAN_WAPI
3320 case WLAN_CIPHER_SUITE_SMS4:
3321 {
3322 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3323 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3324 params->key, params->key_len);
3325 return 0;
3326 }
3327#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003328
Jeff Johnson295189b2012-06-20 16:38:30 -07003329#ifdef FEATURE_WLAN_CCX
3330 case WLAN_CIPHER_SUITE_KRK:
3331 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3332 break;
3333#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003334
3335#ifdef WLAN_FEATURE_11W
3336 case WLAN_CIPHER_SUITE_AES_CMAC:
3337 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003338 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003339#endif
3340
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 default:
3342 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu",
3343 __func__, params->cipher);
3344 return -EOPNOTSUPP;
3345 }
3346
3347 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3348 __func__, setKey.encType);
3349
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003350 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003351#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3352 (!pairwise)
3353#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003354 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003355#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003356 )
3357 {
3358 /* set group key*/
3359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3360 "%s- %d: setting Broadcast key",
3361 __func__, __LINE__);
3362 setKey.keyDirection = eSIR_RX_ONLY;
3363 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3364 }
3365 else
3366 {
3367 /* set pairwise key*/
3368 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3369 "%s- %d: setting pairwise key",
3370 __func__, __LINE__);
3371 setKey.keyDirection = eSIR_TX_RX;
3372 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3373 }
3374 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3375 {
3376 setKey.keyDirection = eSIR_TX_RX;
3377 /*Set the group key*/
3378 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3379 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003380
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003381 if ( 0 != status )
3382 {
3383 hddLog(VOS_TRACE_LEVEL_ERROR,
3384 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3385 return -EINVAL;
3386 }
3387 /*Save the keys here and call sme_RoamSetKey for setting
3388 the PTK after peer joins the IBSS network*/
3389 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3390 &setKey, sizeof(tCsrRoamSetKey));
3391 return status;
3392 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303393 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3394 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3395 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003397 if( pHostapdState->bssState == BSS_START )
3398 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3400
3401 if ( status != eHAL_STATUS_SUCCESS )
3402 {
3403 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3404 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3405 __LINE__, status );
3406 }
3407 }
3408
3409 /* Saving WEP keys */
3410 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3411 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3412 {
3413 //Save the wep key in ap context. Issue setkey after the BSS is started.
3414 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3415 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3416 }
3417 else
3418 {
3419 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003420 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3422 }
3423 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003424 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3425 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 {
3427 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3428 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3429
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303430#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3431 if (!pairwise)
3432#else
3433 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3434#endif
3435 {
3436 /* set group key*/
3437 if (pHddStaCtx->roam_info.deferKeyComplete)
3438 {
3439 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3440 "%s- %d: Perform Set key Complete",
3441 __func__, __LINE__);
3442 hdd_PerformRoamSetKeyComplete(pAdapter);
3443 }
3444 }
3445
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3447
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003448 pWextState->roamProfile.Keys.defaultIndex = key_index;
3449
3450
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003451 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 params->key, params->key_len);
3453
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303454
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3456
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303457 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303459 __func__, setKey.peerMac[0], setKey.peerMac[1],
3460 setKey.peerMac[2], setKey.peerMac[3],
3461 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 setKey.keyDirection);
3463
3464 vos_status = wlan_hdd_check_ula_done(pAdapter);
3465
3466 if ( vos_status != VOS_STATUS_SUCCESS )
3467 {
3468 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3469 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3470 __LINE__, vos_status );
3471
3472 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3473
3474 return -EINVAL;
3475
3476 }
3477
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003478#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303479 /* The supplicant may attempt to set the PTK once pre-authentication
3480 is done. Save the key in the UMAC and include it in the ADD BSS
3481 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003482 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303483 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003484 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303485 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3486 "%s: Update PreAuth Key success", __func__);
3487 return 0;
3488 }
3489 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3490 {
3491 hddLog(VOS_TRACE_LEVEL_ERROR,
3492 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303493 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003494 }
3495#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003496
3497 /* issue set key request to SME*/
3498 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3499 pAdapter->sessionId, &setKey, &roamId );
3500
3501 if ( 0 != status )
3502 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303503 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3505 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3506 return -EINVAL;
3507 }
3508
3509
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303510 /* in case of IBSS as there was no information available about WEP keys during
3511 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303513 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3514 !( ( IW_AUTH_KEY_MGMT_802_1X
3515 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3517 )
3518 &&
3519 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3520 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3521 )
3522 )
3523 {
3524 setKey.keyDirection = eSIR_RX_ONLY;
3525 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3526
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303527 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303529 __func__, setKey.peerMac[0], setKey.peerMac[1],
3530 setKey.peerMac[2], setKey.peerMac[3],
3531 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 setKey.keyDirection);
3533
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303534 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 pAdapter->sessionId, &setKey, &roamId );
3536
3537 if ( 0 != status )
3538 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303539 hddLog(VOS_TRACE_LEVEL_ERROR,
3540 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 __func__, status);
3542 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3543 return -EINVAL;
3544 }
3545 }
3546 }
3547
3548 return 0;
3549}
3550
3551/*
3552 * FUNCTION: wlan_hdd_cfg80211_get_key
3553 * This function is used to get the key information
3554 */
3555#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303556static int wlan_hdd_cfg80211_get_key(
3557 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303559 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003560 const u8 *mac_addr, void *cookie,
3561 void (*callback)(void *cookie, struct key_params*)
3562 )
3563#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303564static int wlan_hdd_cfg80211_get_key(
3565 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 struct net_device *ndev,
3567 u8 key_index, const u8 *mac_addr, void *cookie,
3568 void (*callback)(void *cookie, struct key_params*)
3569 )
3570#endif
3571{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303572 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3574 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3575 struct key_params params;
3576
3577 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303578
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3580 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303581
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 memset(&params, 0, sizeof(params));
3583
3584 if (CSR_MAX_NUM_KEY <= key_index)
3585 {
3586 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003588
3589 switch(pRoamProfile->EncryptionType.encryptionType[0])
3590 {
3591 case eCSR_ENCRYPT_TYPE_NONE:
3592 params.cipher = IW_AUTH_CIPHER_NONE;
3593 break;
3594
3595 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3596 case eCSR_ENCRYPT_TYPE_WEP40:
3597 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3598 break;
3599
3600 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3601 case eCSR_ENCRYPT_TYPE_WEP104:
3602 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3603 break;
3604
3605 case eCSR_ENCRYPT_TYPE_TKIP:
3606 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3607 break;
3608
3609 case eCSR_ENCRYPT_TYPE_AES:
3610 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3611 break;
3612
3613 default:
3614 params.cipher = IW_AUTH_CIPHER_NONE;
3615 break;
3616 }
3617
3618 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3619 params.seq_len = 0;
3620 params.seq = NULL;
3621 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3622 callback(cookie, &params);
3623 return 0;
3624}
3625
3626/*
3627 * FUNCTION: wlan_hdd_cfg80211_del_key
3628 * This function is used to delete the key information
3629 */
3630#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303631static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303633 u8 key_index,
3634 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003635 const u8 *mac_addr
3636 )
3637#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303638static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 struct net_device *ndev,
3640 u8 key_index,
3641 const u8 *mac_addr
3642 )
3643#endif
3644{
3645 int status = 0;
3646
3647 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303648 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 //it is observed that this is invalidating peer
3650 //key index whenever re-key is done. This is affecting data link.
3651 //It should be ok to ignore del_key.
3652#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303653 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3654 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3656 tCsrRoamSetKey setKey;
3657 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303658
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 ENTER();
3660
3661 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3662 __func__,pAdapter->device_mode);
3663
3664 if (CSR_MAX_NUM_KEY <= key_index)
3665 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303666 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 key_index);
3668
3669 return -EINVAL;
3670 }
3671
3672 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3673 setKey.keyId = key_index;
3674
3675 if (mac_addr)
3676 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3677 else
3678 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3679
3680 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3681
3682 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303684 )
3685 {
3686
3687 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3689 if( pHostapdState->bssState == BSS_START)
3690 {
3691 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303692
Jeff Johnson295189b2012-06-20 16:38:30 -07003693 if ( status != eHAL_STATUS_SUCCESS )
3694 {
3695 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3696 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3697 __LINE__, status );
3698 }
3699 }
3700 }
3701 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303702 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 )
3704 {
3705 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3706
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303707 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3708
3709 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303711 __func__, setKey.peerMac[0], setKey.peerMac[1],
3712 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303714 if(pAdapter->sessionCtx.station.conn_info.connState ==
3715 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303717 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303719
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 if ( 0 != status )
3721 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303722 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 "%s: sme_RoamSetKey failure, returned %d",
3724 __func__, status);
3725 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3726 return -EINVAL;
3727 }
3728 }
3729 }
3730#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003731 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 return status;
3733}
3734
3735/*
3736 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3737 * This function is used to set the default tx key index
3738 */
3739#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3740static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3741 struct net_device *ndev,
3742 u8 key_index,
3743 bool unicast, bool multicast)
3744#else
3745static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3746 struct net_device *ndev,
3747 u8 key_index)
3748#endif
3749{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303750 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303751 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303752 hdd_wext_state_t *pWextState;
3753 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303754 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003755
3756 ENTER();
3757
Gopichand Nakkala29149562013-05-10 21:43:41 +05303758 if ((NULL == pAdapter))
3759 {
3760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3761 "invalid adapter");
3762 return -EINVAL;
3763 }
3764
3765 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3766 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3767
3768 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3769 {
3770 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3771 "invalid Wext state or HDD context");
3772 return -EINVAL;
3773 }
3774
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3776 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303777
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 if (CSR_MAX_NUM_KEY <= key_index)
3779 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303780 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 key_index);
3782
3783 return -EINVAL;
3784 }
3785
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303786 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3787 status = wlan_hdd_validate_context(pHddCtx);
3788
3789 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003790 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3792 "%s: HDD context is not valid", __func__);
3793 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003794 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303795
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303798 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303800 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303802 (eCSR_ENCRYPT_TYPE_AES !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 pWextState->roamProfile.EncryptionType.encryptionType[0])
3804 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303805 {
3806 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003807 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303808
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 tCsrRoamSetKey setKey;
3810 v_U32_t roamId= 0xFF;
3811 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303812
3813 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303815
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 Keys->defaultIndex = (u8)key_index;
3817 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3818 setKey.keyId = key_index;
3819 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303820
3821 vos_mem_copy(&setKey.Key[0],
3822 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303824
Gopichand Nakkala29149562013-05-10 21:43:41 +05303825 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303826
3827 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 &pHddStaCtx->conn_info.bssId[0],
3829 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303830
Gopichand Nakkala29149562013-05-10 21:43:41 +05303831 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3832 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3833 eCSR_ENCRYPT_TYPE_WEP104)
3834 {
3835 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3836 even though ap is configured for WEP-40 encryption. In this canse the key length
3837 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3838 type(104) and switching encryption type to 40*/
3839 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3840 eCSR_ENCRYPT_TYPE_WEP40;
3841 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3842 eCSR_ENCRYPT_TYPE_WEP40;
3843 }
3844
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303845 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303847
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303849 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303851
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 if ( 0 != status )
3853 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303854 hddLog(VOS_TRACE_LEVEL_ERROR,
3855 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 status);
3857 return -EINVAL;
3858 }
3859 }
3860 }
3861
3862 /* In SoftAp mode setting key direction for default mode */
3863 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3864 {
3865 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3866 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3867 (eCSR_ENCRYPT_TYPE_AES !=
3868 pWextState->roamProfile.EncryptionType.encryptionType[0])
3869 )
3870 {
3871 /* Saving key direction for default key index to TX default */
3872 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3873 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3874 }
3875 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303876
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 return status;
3878}
3879
Jeff Johnson295189b2012-06-20 16:38:30 -07003880/*
3881 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3882 * This function is used to inform the BSS details to nl80211 interface.
3883 */
3884static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3885 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3886{
3887 struct net_device *dev = pAdapter->dev;
3888 struct wireless_dev *wdev = dev->ieee80211_ptr;
3889 struct wiphy *wiphy = wdev->wiphy;
3890 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3891 int chan_no;
3892 int ie_length;
3893 const char *ie;
3894 unsigned int freq;
3895 struct ieee80211_channel *chan;
3896 int rssi = 0;
3897 struct cfg80211_bss *bss = NULL;
3898
3899 ENTER();
3900
3901 if( NULL == pBssDesc )
3902 {
3903 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
3904 return bss;
3905 }
3906
3907 chan_no = pBssDesc->channelId;
3908 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
3909 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
3910
3911 if( NULL == ie )
3912 {
3913 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
3914 return bss;
3915 }
3916
3917#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
3918 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
3919 {
3920 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
3921 }
3922 else
3923 {
3924 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
3925 }
3926#else
3927 freq = ieee80211_channel_to_frequency(chan_no);
3928#endif
3929
3930 chan = __ieee80211_get_channel(wiphy, freq);
3931
3932 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
3933 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
3934 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
3935 if (bss == NULL)
3936 {
3937 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
3938
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303939 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
3940 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 pBssDesc->capabilityInfo,
3942 pBssDesc->beaconInterval, ie, ie_length,
3943 rssi, GFP_KERNEL ));
3944}
3945 else
3946 {
3947 return bss;
3948 }
3949}
3950
3951
3952
3953/*
3954 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
3955 * This function is used to inform the BSS details to nl80211 interface.
3956 */
3957struct cfg80211_bss*
3958wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
3959 tSirBssDescription *bss_desc
3960 )
3961{
3962 /*
3963 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
3964 already exists in bss data base of cfg80211 for that particular BSS ID.
3965 Using cfg80211_inform_bss_frame to update the bss entry instead of
3966 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
3967 now there is no possibility to get the mgmt(probe response) frame from PE,
3968 converting bss_desc to ieee80211_mgmt(probe response) and passing to
3969 cfg80211_inform_bss_frame.
3970 */
3971 struct net_device *dev = pAdapter->dev;
3972 struct wireless_dev *wdev = dev->ieee80211_ptr;
3973 struct wiphy *wiphy = wdev->wiphy;
3974 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08003975#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
3976 qcom_ie_age *qie_age = NULL;
3977 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
3978#else
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08003980#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 const char *ie =
3982 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
3983 unsigned int freq;
3984 struct ieee80211_channel *chan;
3985 struct ieee80211_mgmt *mgmt =
3986 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
3987 struct cfg80211_bss *bss_status = NULL;
3988 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
3989 int rssi = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07003990#ifdef WLAN_OPEN_SOURCE
3991 struct timespec ts;
3992#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003993
3994 ENTER();
3995
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07003996 if (!mgmt)
3997 return NULL;
3998
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004000
4001#ifdef WLAN_OPEN_SOURCE
4002 /* Android does not want the timestamp from the frame.
4003 Instead it wants a monotonic increasing value */
4004 get_monotonic_boottime(&ts);
4005 mgmt->u.probe_resp.timestamp =
4006 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4007#else
4008 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4010 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004011
4012#endif
4013
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4015 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004016
4017#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4018 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4019 /* Assuming this is the last IE, copy at the end */
4020 ie_length -=sizeof(qcom_ie_age);
4021 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4022 qie_age->element_id = QCOM_VENDOR_IE_ID;
4023 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4024 qie_age->oui_1 = QCOM_OUI1;
4025 qie_age->oui_2 = QCOM_OUI2;
4026 qie_age->oui_3 = QCOM_OUI3;
4027 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4028 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4029#endif
4030
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304032 if (bss_desc->fProbeRsp)
4033 {
4034 mgmt->frame_control |=
4035 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4036 }
4037 else
4038 {
4039 mgmt->frame_control |=
4040 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004042
4043#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304044 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4046 {
4047 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4048 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304049 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4051
4052 {
4053 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4054 }
4055 else
4056 {
4057 kfree(mgmt);
4058 return NULL;
4059 }
4060#else
4061 freq = ieee80211_channel_to_frequency(chan_no);
4062#endif
4063 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004064 /*when the band is changed on the fly using the GUI, three things are done
4065 * 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)
4066 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4067 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4068 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4069 * and discards the channels correponding to previous band and calls back with zero bss results.
4070 * 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
4071 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4072 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4073 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4074 * So drop the bss and continue to next bss.
4075 */
4076 if(chan == NULL)
4077 {
4078 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004079 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004080 return NULL;
4081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304083 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 * */
4085 if (( eConnectionState_Associated ==
4086 pAdapter->sessionCtx.station.conn_info.connState ) &&
4087 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4088 pAdapter->sessionCtx.station.conn_info.bssId,
4089 WNI_CFG_BSSID_LEN)))
4090 {
4091 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4092 rssi = (pAdapter->rssi * 100);
4093 }
4094 else
4095 {
4096 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4097 }
4098
4099 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4100 frame_len, rssi, GFP_KERNEL);
4101 kfree(mgmt);
4102 return bss_status;
4103}
4104
4105/*
4106 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4107 * This function is used to update the BSS data base of CFG8011
4108 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304109struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 tCsrRoamInfo *pRoamInfo
4111 )
4112{
4113 tCsrRoamConnectedProfile roamProfile;
4114 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4115 struct cfg80211_bss *bss = NULL;
4116
4117 ENTER();
4118
4119 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4120 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4121
4122 if (NULL != roamProfile.pBssDesc)
4123 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304124 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 &roamProfile);
4126
4127 if (NULL == bss)
4128 {
4129 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4130 __func__);
4131 }
4132
4133 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4134 }
4135 else
4136 {
4137 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4138 __func__);
4139 }
4140 return bss;
4141}
4142
4143/*
4144 * FUNCTION: wlan_hdd_cfg80211_update_bss
4145 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304146static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4147 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304149{
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4151 tCsrScanResultInfo *pScanResult;
4152 eHalStatus status = 0;
4153 tScanResultHandle pResult;
4154 struct cfg80211_bss *bss_status = NULL;
4155
4156 ENTER();
4157
4158 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4159 {
4160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
4161 return -EAGAIN;
4162 }
4163
4164 /*
4165 * start getting scan results and populate cgf80211 BSS database
4166 */
4167 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4168
4169 /* no scan results */
4170 if (NULL == pResult)
4171 {
4172 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4173 return status;
4174 }
4175
4176 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4177
4178 while (pScanResult)
4179 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304180 /*
4181 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4182 * entry already exists in bss data base of cfg80211 for that
4183 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4184 * bss entry instead of cfg80211_inform_bss, But this call expects
4185 * mgmt packet as input. As of now there is no possibility to get
4186 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 * ieee80211_mgmt(probe response) and passing to c
4188 * fg80211_inform_bss_frame.
4189 * */
4190
4191 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4192 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304193
Jeff Johnson295189b2012-06-20 16:38:30 -07004194
4195 if (NULL == bss_status)
4196 {
4197 hddLog(VOS_TRACE_LEVEL_INFO,
4198 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4199 }
4200 else
4201 {
Yue Maf49ba872013-08-19 12:04:25 -07004202 cfg80211_put_bss(
4203#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4204 wiphy,
4205#endif
4206 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004207 }
4208
4209 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4210 }
4211
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304212 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004213
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304214 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004215}
4216
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004217void
4218hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4219{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304220 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004221 "%02X:%02X:%02X:%02X:%02X:%02X\n",
4222 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
4223 macAddr[5]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004224} /****** end hddPrintMacAddr() ******/
4225
4226void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004227hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004228{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304229 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004230 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4231 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4232 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4233 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004234} /****** end hddPrintPmkId() ******/
4235
4236//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4237//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4238
4239//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4240//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4241
4242#define dump_bssid(bssid) \
4243 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004244 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4245 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4246 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004247 }
4248
4249#define dump_pmkid(pMac, pmkid) \
4250 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004251 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4252 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4253 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004254 }
4255
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004256#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004257/*
4258 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4259 * This function is used to notify the supplicant of a new PMKSA candidate.
4260 */
4261int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304262 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004263 int index, bool preauth )
4264{
Jeff Johnsone7245742012-09-05 17:12:55 -07004265#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004266 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004267 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004268
4269 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004270 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004271
4272 if( NULL == pRoamInfo )
4273 {
4274 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4275 return -EINVAL;
4276 }
4277
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004278 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4279 {
4280 dump_bssid(pRoamInfo->bssid);
4281 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004282 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004283 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004284#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304285 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004286}
4287#endif //FEATURE_WLAN_LFR
4288
Jeff Johnson295189b2012-06-20 16:38:30 -07004289/*
4290 * FUNCTION: hdd_cfg80211_scan_done_callback
4291 * scanning callback function, called after finishing scan
4292 *
4293 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304294static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4296{
4297 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304298 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004300 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4301 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 struct cfg80211_scan_request *req = NULL;
4303 int ret = 0;
4304
4305 ENTER();
4306
4307 hddLog(VOS_TRACE_LEVEL_INFO,
4308 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304309 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 __func__, halHandle, pContext, (int) scanId, (int) status);
4311
4312 //Block on scan req completion variable. Can't wait forever though.
4313 ret = wait_for_completion_interruptible_timeout(
4314 &pScanInfo->scan_req_completion_event,
4315 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4316 if (!ret)
4317 {
4318 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004319 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004320 }
4321
4322 if(pScanInfo->mScanPending != VOS_TRUE)
4323 {
4324 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004325 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 }
4327
4328 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304329 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 {
4331 hddLog(VOS_TRACE_LEVEL_INFO,
4332 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304333 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 (int) scanId);
4335 }
4336
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304337 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 pAdapter);
4339
4340 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304341 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004342
4343
4344 /* If any client wait scan result through WEXT
4345 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004346 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004347 {
4348 /* The other scan request waiting for current scan finish
4349 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004350 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004352 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 }
4354 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004355 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 {
4357 struct net_device *dev = pAdapter->dev;
4358 union iwreq_data wrqu;
4359 int we_event;
4360 char *msg;
4361
4362 memset(&wrqu, '\0', sizeof(wrqu));
4363 we_event = SIOCGIWSCAN;
4364 msg = NULL;
4365 wireless_send_event(dev, we_event, &wrqu, msg);
4366 }
4367 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004368 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004369
4370 /* Get the Scan Req */
4371 req = pAdapter->request;
4372
4373 if (!req)
4374 {
4375 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004376 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004377 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 }
4379
4380 /*
4381 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304382 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 req->n_ssids = 0;
4384 req->n_channels = 0;
4385 req->ie = 0;
4386
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004388 /* Scan is no longer pending */
4389 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004390
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004391 /*
4392 * cfg80211_scan_done informing NL80211 about completion
4393 * of scanning
4394 */
4395 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004396 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004397
Jeff Johnsone7245742012-09-05 17:12:55 -07004398allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004399 /* release the wake lock at the end of the scan*/
4400 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004401
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004402 /* Acquire wakelock to handle the case where APP's tries to suspend
4403 * immediatly after the driver gets connect request(i.e after scan)
4404 * from supplicant, this result in app's is suspending and not able
4405 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004406 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004407
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004408#ifdef FEATURE_WLAN_TDLS
4409 wlan_hdd_tdls_scan_done_callback(pAdapter);
4410#endif
4411
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 EXIT();
4413 return 0;
4414}
4415
4416/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004417 * FUNCTION: hdd_isScanAllowed
4418 * Go through each adapter and check if scan allowed
4419 *
4420 */
4421v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4422{
4423 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4424 hdd_station_ctx_t *pHddStaCtx = NULL;
4425 hdd_adapter_t *pAdapter = NULL;
4426 VOS_STATUS status = 0;
4427 v_U8_t staId = 0;
4428 v_U8_t *staMac = NULL;
4429
Gopichand Nakkala8c0386c2013-07-09 23:31:37 +05304430 if (VOS_TIMER_STATE_RUNNING ==
4431 vos_timer_getCurrentState(&pHddCtx->hdd_p2p_go_conn_is_in_progress))
4432 {
4433 hddLog(VOS_TRACE_LEVEL_INFO,
4434 "%s: Connection is in progress, Do not allow the scan", __func__);
4435 return VOS_FALSE;
4436 }
4437
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004438 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4439
4440 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4441 {
4442 pAdapter = pAdapterNode->pAdapter;
4443
4444 if( pAdapter )
4445 {
4446 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304447 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004448 __func__, pAdapter->device_mode);
4449 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4450 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4451 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4452 {
4453 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4454 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4455 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4456 {
4457 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4458 hddLog(VOS_TRACE_LEVEL_ERROR,
4459 "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304460 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004461 staMac[0], staMac[1], staMac[2],
4462 staMac[3], staMac[4], staMac[5]);
4463 return VOS_FALSE;
4464 }
4465 }
4466 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4467 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4468 {
4469 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4470 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304471 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004472 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4473 {
4474 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4475
4476 hddLog(VOS_TRACE_LEVEL_ERROR,
4477 "%s: client %02x:%02x:%02x:%02x:%02x:%02x of SoftAP/P2P-GO is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304478 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004479 staMac[0], staMac[1], staMac[2],
4480 staMac[3], staMac[4], staMac[5]);
4481 return VOS_FALSE;
4482 }
4483 }
4484 }
4485 }
4486 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4487 pAdapterNode = pNext;
4488 }
4489 hddLog(VOS_TRACE_LEVEL_INFO,
4490 "%s: Scan allowed", __func__);
4491 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304492}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004493
4494/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 * FUNCTION: wlan_hdd_cfg80211_scan
4496 * this scan respond to scan trigger and update cfg80211 scan database
4497 * later, scan dump command can be used to recieve scan results
4498 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004499int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4500#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4501 struct net_device *dev,
4502#endif
4503 struct cfg80211_scan_request *request)
4504{
4505#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4506 struct net_device *dev = request->wdev->netdev;
4507#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304508 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4510 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304511 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 tCsrScanRequest scanRequest;
4513 tANI_U8 *channelList = NULL, i;
4514 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304515 int status;
4516 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004518
4519 ENTER();
4520
4521 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4522 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004523
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304524 status = wlan_hdd_validate_context(pHddCtx);
4525
4526 if (0 != status)
4527 {
4528 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4529 "%s: HDD context is not valid", __func__);
4530 return status;
4531 }
4532
4533 cfg_param = pHddCtx->cfg_ini;
4534 pScanInfo = &pHddCtx->scan_info;
4535
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004536 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004537 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004538 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004539 {
4540 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004541 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4542 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004543 return -EBUSY;
4544 }
4545
Jeff Johnson295189b2012-06-20 16:38:30 -07004546#ifdef WLAN_BTAMP_FEATURE
4547 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004548 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004550 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 "%s: No scanning when AMP is on", __func__);
4552 return -EOPNOTSUPP;
4553 }
4554#endif
4555 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004556 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004558 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 "%s: Not scanning on device_mode = %d",
4560 __func__, pAdapter->device_mode);
4561 return -EOPNOTSUPP;
4562 }
4563
4564 if (TRUE == pScanInfo->mScanPending)
4565 {
4566 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004567 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 }
4569
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304570 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004571 //Channel and action frame is pending
4572 //Otherwise Cancel Remain On Channel and allow Scan
4573 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004574 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004575 {
4576 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__);
4577 return -EBUSY;
4578 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004579#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004580 /* if tdls disagree scan right now, return immediately.
4581 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4582 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4583 */
4584 status = wlan_hdd_tdls_scan_callback (pAdapter,
4585 wiphy,
4586#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4587 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004588#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004589 request);
4590 if(status <= 0)
4591 {
4592 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4593 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004594 }
4595#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004596
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4598 {
4599 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004600 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4604 {
4605 hddLog(VOS_TRACE_LEVEL_WARN,
4606 "%s: MAX TM Level Scan not allowed", __func__);
4607 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304608 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 }
4610 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4611
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004612 /* Check if scan is allowed at this point of time.
4613 */
4614 if (!hdd_isScanAllowed(pHddCtx))
4615 {
4616 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4617 return -EBUSY;
4618 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304619
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4621
4622 if (NULL != request)
4623 {
4624 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304625 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004626
4627 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4628 * Becasue of this, driver is assuming that this is not wildcard scan and so
4629 * is not aging out the scan results.
4630 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004631 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 {
4633 request->n_ssids = 0;
4634 }
4635
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004636 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 {
4638 tCsrSSIDInfo *SsidInfo;
4639 int j;
4640 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4641 /* Allocate num_ssid tCsrSSIDInfo structure */
4642 SsidInfo = scanRequest.SSIDs.SSIDList =
4643 ( tCsrSSIDInfo *)vos_mem_malloc(
4644 request->n_ssids*sizeof(tCsrSSIDInfo));
4645
4646 if(NULL == scanRequest.SSIDs.SSIDList)
4647 {
4648 hddLog(VOS_TRACE_LEVEL_ERROR,
4649 "memory alloc failed SSIDInfo buffer");
4650 return -ENOMEM;
4651 }
4652
4653 /* copy all the ssid's and their length */
4654 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4655 {
4656 /* get the ssid length */
4657 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4658 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4659 SsidInfo->SSID.length);
4660 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4661 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4662 j, SsidInfo->SSID.ssId);
4663 }
4664 /* set the scan type to active */
4665 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4666 }
4667 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4668 {
4669 /* set the scan type to active */
4670 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4671 }
4672 else
4673 {
4674 /*Set the scan type to default type, in this case it is ACTIVE*/
4675 scanRequest.scanType = pScanInfo->scan_mode;
4676 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304677 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4679 }
4680 else
4681 {
4682 /* set the scan type to active */
4683 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4684 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4685
4686 /* set min and max channel time to zero */
4687 scanRequest.minChnTime = 0;
4688 scanRequest.maxChnTime = 0;
4689 }
4690
4691 /* set BSSType to default type */
4692 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4693
4694 /*TODO: scan the requested channels only*/
4695
4696 /*Right now scanning all the channels */
4697 if( request )
4698 {
4699 if( request->n_channels )
4700 {
4701 channelList = vos_mem_malloc( request->n_channels );
4702 if( NULL == channelList )
4703 {
4704 status = -ENOMEM;
4705 goto free_mem;
4706 }
4707
4708 for( i = 0 ; i < request->n_channels ; i++ )
4709 channelList[i] = request->channels[i]->hw_value;
4710 }
4711
4712 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4713 scanRequest.ChannelInfo.ChannelList = channelList;
4714
4715 /* set requestType to full scan */
4716 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304717
4718 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004719 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304720 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004721 */
4722
4723 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304724 * and in that case driver shoudnt flush scan results. If
4725 * driver flushes the scan results here and unfortunately if
4726 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004727 * fails which is not desired
4728 */
4729
4730 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4731 {
4732 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4733 pAdapter->sessionId );
4734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004735
4736 if( request->ie_len )
4737 {
4738 /* save this for future association (join requires this) */
4739 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4740 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4741 pScanInfo->scanAddIE.length = request->ie_len;
4742
4743 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07004744 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4745 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 )
4747 {
4748 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
4749 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
4750 }
4751
4752 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
4753 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
4754
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
4756 request->ie_len);
4757 if (pP2pIe != NULL)
4758 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07004759#ifdef WLAN_FEATURE_P2P_DEBUG
4760 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
4761 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
4762 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4763 {
4764 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
4765 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4766 "Go nego completed to Connection is started");
4767 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4768 "for 8way Handshake");
4769 }
4770 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
4771 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4772 {
4773 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
4774 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4775 "Disconnected state to Connection is started");
4776 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4777 "for 4way Handshake");
4778 }
4779#endif
4780
Jeff Johnsone7245742012-09-05 17:12:55 -07004781 /* no_cck will be set during p2p find to disable 11b rates */
4782 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004784 hddLog(VOS_TRACE_LEVEL_INFO,
4785 "%s: This is a P2P Search", __func__);
4786 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07004787
Jeff Johnsone7245742012-09-05 17:12:55 -07004788 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
4789 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07004790 /* set requestType to P2P Discovery */
4791 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07004792 }
4793
4794 /*
4795 Skip Dfs Channel in case of P2P Search
4796 if it is set in ini file
4797 */
4798 if(cfg_param->skipDfsChnlInP2pSearch)
4799 {
4800 scanRequest.skipDfsChnlInP2pSearch = 1;
4801 }
4802 else
4803 {
4804 scanRequest.skipDfsChnlInP2pSearch = 0;
4805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004806
Jeff Johnson295189b2012-06-20 16:38:30 -07004807 }
4808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 }
4810 }
4811
4812 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
4813
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004814 /* acquire the wakelock to avoid the apps suspend during the scan. To
4815 * address the following issues.
4816 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
4817 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
4818 * for long time, this result in apps running at full power for long time.
4819 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
4820 * be stuck in full power because of resume BMPS
4821 */
4822 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004823
4824 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 pAdapter->sessionId, &scanRequest, &scanId,
4826 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07004827
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 if (eHAL_STATUS_SUCCESS != status)
4829 {
4830 hddLog(VOS_TRACE_LEVEL_ERROR,
4831 "%s: sme_ScanRequest returned error %d", __func__, status);
4832 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07004833 if(eHAL_STATUS_RESOURCES == status)
4834 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07004835 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 -07004836 status = -EBUSY;
4837 } else {
4838 status = -EIO;
4839 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004840 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07004841 goto free_mem;
4842 }
4843
4844 pScanInfo->mScanPending = TRUE;
4845 pAdapter->request = request;
4846 pScanInfo->scanId = scanId;
4847
4848 complete(&pScanInfo->scan_req_completion_event);
4849
4850free_mem:
4851 if( scanRequest.SSIDs.SSIDList )
4852 {
4853 vos_mem_free(scanRequest.SSIDs.SSIDList);
4854 }
4855
4856 if( channelList )
4857 vos_mem_free( channelList );
4858
4859 EXIT();
4860
4861 return status;
4862}
4863
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004864
4865void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
4866{
4867 v_U8_t iniDot11Mode =
4868 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
4869 eHddDot11Mode hddDot11Mode = iniDot11Mode;
4870
4871 switch ( iniDot11Mode )
4872 {
4873 case eHDD_DOT11_MODE_AUTO:
4874 case eHDD_DOT11_MODE_11ac:
4875 case eHDD_DOT11_MODE_11ac_ONLY:
4876#ifdef WLAN_FEATURE_11AC
4877 hddDot11Mode = eHDD_DOT11_MODE_11ac;
4878#else
4879 hddDot11Mode = eHDD_DOT11_MODE_11n;
4880#endif
4881 break;
4882 case eHDD_DOT11_MODE_11n:
4883 case eHDD_DOT11_MODE_11n_ONLY:
4884 hddDot11Mode = eHDD_DOT11_MODE_11n;
4885 break;
4886 default:
4887 hddDot11Mode = iniDot11Mode;
4888 break;
4889 }
4890 /* This call decides required channel bonding mode */
4891 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
4892 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
4893 operationChannel);
4894}
4895
Jeff Johnson295189b2012-06-20 16:38:30 -07004896/*
4897 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304898 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304900int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004901 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07004902{
4903 int status = 0;
4904 hdd_wext_state_t *pWextState;
4905 v_U32_t roamId;
4906 tCsrRoamProfile *pRoamProfile;
4907 eMib_dot11DesiredBssType connectedBssType;
4908 eCsrAuthType RSNAuthType;
4909
4910 ENTER();
4911
4912 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304913
Jeff Johnson295189b2012-06-20 16:38:30 -07004914 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
4915 {
4916 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
4917 return -EINVAL;
4918 }
4919
4920 pRoamProfile = &pWextState->roamProfile;
4921
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304922 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004924 int ret = 0;
4925 hdd_station_ctx_t *pHddStaCtx;
4926 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4927 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
4928
4929 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
4930 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
4931 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 {
4933 /* Issue disconnect to CSR */
4934 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304935 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
4937 pAdapter->sessionId,
4938 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
4939 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004940 ret = wait_for_completion_interruptible_timeout(
4941 &pAdapter->disconnect_comp_var,
4942 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4943 if (0 == ret)
4944 {
4945 VOS_ASSERT(0);
4946 }
4947 }
4948 }
4949 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
4950 {
4951 ret = wait_for_completion_interruptible_timeout(
4952 &pAdapter->disconnect_comp_var,
4953 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4954 if (0 == ret)
4955 {
4956 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 }
4958 }
4959
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304960 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
4962 {
4963 /*QoS not enabled in cfg file*/
4964 pRoamProfile->uapsd_mask = 0;
4965 }
4966 else
4967 {
4968 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304969 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07004970 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
4971 }
4972
4973 pRoamProfile->SSIDs.numOfSSIDs = 1;
4974 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
4975 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304976 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
4978 ssid, ssid_len);
4979
4980 if (bssid)
4981 {
4982 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
4983 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
4984 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304985 /* Save BSSID in seperate variable as well, as RoamProfile
4986 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 case of join failure we should send valid BSSID to supplicant
4988 */
4989 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
4990 WNI_CFG_BSSID_LEN);
4991 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004992 else
4993 {
4994 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
4995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004996
4997 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
4998 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304999 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 /*set gen ie*/
5001 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5002 /*set auth*/
5003 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005005#ifdef FEATURE_WLAN_WAPI
5006 if (pAdapter->wapi_info.nWapiMode)
5007 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005008 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005009 switch (pAdapter->wapi_info.wapiAuthMode)
5010 {
5011 case WAPI_AUTH_MODE_PSK:
5012 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005013 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 pAdapter->wapi_info.wapiAuthMode);
5015 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5016 break;
5017 }
5018 case WAPI_AUTH_MODE_CERT:
5019 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005020 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 pAdapter->wapi_info.wapiAuthMode);
5022 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5023 break;
5024 }
5025 } // End of switch
5026 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5027 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5028 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005029 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005030 pRoamProfile->AuthType.numEntries = 1;
5031 pRoamProfile->EncryptionType.numEntries = 1;
5032 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5033 pRoamProfile->mcEncryptionType.numEntries = 1;
5034 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5035 }
5036 }
5037#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305038#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305039 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305040 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5041 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5042 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305043 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5044 sizeof (tSirGtkOffloadParams));
5045 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305046 }
5047#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 pRoamProfile->csrPersona = pAdapter->device_mode;
5049
Jeff Johnson32d95a32012-09-10 13:15:23 -07005050 if( operatingChannel )
5051 {
5052 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5053 pRoamProfile->ChannelInfo.numOfChannels = 1;
5054 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005055 else
5056 {
5057 pRoamProfile->ChannelInfo.ChannelList = NULL;
5058 pRoamProfile->ChannelInfo.numOfChannels = 0;
5059 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005060 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5061 {
5062 hdd_select_cbmode(pAdapter,operatingChannel);
5063 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005064 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5065 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305066 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005067 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005068 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5069 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305070 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5071 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005072 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5073 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305074
5075 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 pAdapter->sessionId, pRoamProfile, &roamId);
5077
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305078 if ((eHAL_STATUS_SUCCESS != status) &&
5079 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5080 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305081
5082 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005083 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5084 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5085 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305086 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005087 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305088 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005089
5090 pRoamProfile->ChannelInfo.ChannelList = NULL;
5091 pRoamProfile->ChannelInfo.numOfChannels = 0;
5092
Jeff Johnson295189b2012-06-20 16:38:30 -07005093 }
5094 else
5095 {
5096 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5097 return -EINVAL;
5098 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005099 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 return status;
5101}
5102
5103/*
5104 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5105 * This function is used to set the authentication type (OPEN/SHARED).
5106 *
5107 */
5108static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5109 enum nl80211_auth_type auth_type)
5110{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305111 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005112 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5113
5114 ENTER();
5115
5116 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305117 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305120 hddLog(VOS_TRACE_LEVEL_INFO,
5121 "%s: set authentication type to AUTOSWITCH", __func__);
5122 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5123 break;
5124
5125 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005126#ifdef WLAN_FEATURE_VOWIFI_11R
5127 case NL80211_AUTHTYPE_FT:
5128#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305129 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 "%s: set authentication type to OPEN", __func__);
5131 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5132 break;
5133
5134 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305135 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005136 "%s: set authentication type to SHARED", __func__);
5137 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5138 break;
5139#ifdef FEATURE_WLAN_CCX
5140 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305141 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 "%s: set authentication type to CCKM WPA", __func__);
5143 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5144 break;
5145#endif
5146
5147
5148 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305149 hddLog(VOS_TRACE_LEVEL_ERROR,
5150 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005151 auth_type);
5152 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5153 return -EINVAL;
5154 }
5155
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305156 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005157 pHddStaCtx->conn_info.authType;
5158 return 0;
5159}
5160
5161/*
5162 * FUNCTION: wlan_hdd_set_akm_suite
5163 * This function is used to set the key mgmt type(PSK/8021x).
5164 *
5165 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305166static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 u32 key_mgmt
5168 )
5169{
5170 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5171 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305172
Jeff Johnson295189b2012-06-20 16:38:30 -07005173 /*set key mgmt type*/
5174 switch(key_mgmt)
5175 {
5176 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305177#ifdef WLAN_FEATURE_VOWIFI_11R
5178 case WLAN_AKM_SUITE_FT_PSK:
5179#endif
5180 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005181 __func__);
5182 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5183 break;
5184
5185 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305186#ifdef WLAN_FEATURE_VOWIFI_11R
5187 case WLAN_AKM_SUITE_FT_8021X:
5188#endif
5189 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 __func__);
5191 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5192 break;
5193#ifdef FEATURE_WLAN_CCX
5194#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5195#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5196 case WLAN_AKM_SUITE_CCKM:
5197 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5198 __func__);
5199 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5200 break;
5201#endif
5202
5203 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305204 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 __func__, key_mgmt);
5206 return -EINVAL;
5207
5208 }
5209 return 0;
5210}
5211
5212/*
5213 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305214 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 * (NONE/WEP40/WEP104/TKIP/CCMP).
5216 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305217static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5218 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 bool ucast
5220 )
5221{
5222 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305223 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5225
5226 ENTER();
5227
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305228 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305230 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 __func__, cipher);
5232 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5233 }
5234 else
5235 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305236
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305238 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005239 {
5240 case IW_AUTH_CIPHER_NONE:
5241 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5242 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305243
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305245 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005246 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305247
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305249 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005250 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305251
Jeff Johnson295189b2012-06-20 16:38:30 -07005252 case WLAN_CIPHER_SUITE_TKIP:
5253 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5254 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305255
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 case WLAN_CIPHER_SUITE_CCMP:
5257 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5258 break;
5259#ifdef FEATURE_WLAN_WAPI
5260 case WLAN_CIPHER_SUITE_SMS4:
5261 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5262 break;
5263#endif
5264
5265#ifdef FEATURE_WLAN_CCX
5266 case WLAN_CIPHER_SUITE_KRK:
5267 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5268 break;
5269#endif
5270 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305271 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005272 __func__, cipher);
5273 return -EOPNOTSUPP;
5274 }
5275 }
5276
5277 if (ucast)
5278 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305279 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005280 __func__, encryptionType);
5281 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5282 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305283 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 encryptionType;
5285 }
5286 else
5287 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305288 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 __func__, encryptionType);
5290 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5291 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5292 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5293 }
5294
5295 return 0;
5296}
5297
5298
5299/*
5300 * FUNCTION: wlan_hdd_cfg80211_set_ie
5301 * This function is used to parse WPA/RSN IE's.
5302 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305303int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5304 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005305 size_t ie_len
5306 )
5307{
5308 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5309 u8 *genie = ie;
5310 v_U16_t remLen = ie_len;
5311#ifdef FEATURE_WLAN_WAPI
5312 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5313 u16 *tmp;
5314 v_U16_t akmsuiteCount;
5315 int *akmlist;
5316#endif
5317 ENTER();
5318
5319 /* clear previous assocAddIE */
5320 pWextState->assocAddIE.length = 0;
5321 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5322
5323 while (remLen >= 2)
5324 {
5325 v_U16_t eLen = 0;
5326 v_U8_t elementId;
5327 elementId = *genie++;
5328 eLen = *genie++;
5329 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305330
5331 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305333
5334 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005335 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305336 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005337 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 -07005338 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305339 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 "%s: Invalid WPA IE", __func__);
5341 return -EINVAL;
5342 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305343 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 {
5345 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305346 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305348
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5350 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005351 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5352 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 VOS_ASSERT(0);
5354 return -ENOMEM;
5355 }
5356 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5357 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5358 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305359
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5361 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5362 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5363 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305364 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5365 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5367 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5368 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5369 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5370 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5371 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305372 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
5373 P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005374 /*Consider P2P IE, only for P2P Client */
5375 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5376 {
5377 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305378 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305380
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5382 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005383 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5384 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 VOS_ASSERT(0);
5386 return -ENOMEM;
5387 }
5388 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5389 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5390 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305391
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5393 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005395#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305396 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5397 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005398 /*Consider WFD IE, only for P2P Client */
5399 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5400 {
5401 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305402 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305404
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5406 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005407 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5408 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005409 VOS_ASSERT(0);
5410 return -ENOMEM;
5411 }
5412 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5413 // WPS IE + P2P IE + WFD IE
5414 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5415 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305416
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5418 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5419 }
5420#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005421 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305422 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005423 HS20_OUI_TYPE_SIZE)) )
5424 {
5425 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305426 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005427 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005428
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005429 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5430 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005431 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5432 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005433 VOS_ASSERT(0);
5434 return -ENOMEM;
5435 }
5436 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5437 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005438
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005439 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5440 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5441 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005442
Jeff Johnson295189b2012-06-20 16:38:30 -07005443 break;
5444 case DOT11F_EID_RSN:
5445 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5446 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5447 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5448 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5449 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5450 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005451 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5452 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305453 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005454 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305455 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005456 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305457
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005458 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5459 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005460 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5461 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005462 VOS_ASSERT(0);
5463 return -ENOMEM;
5464 }
5465 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5466 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305467
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005468 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5469 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5470 break;
5471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005472#ifdef FEATURE_WLAN_WAPI
5473 case WLAN_EID_WAPI:
5474 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
5475 hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n",
5476 pAdapter->wapi_info.nWapiMode);
5477 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305478 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 akmsuiteCount = WPA_GET_LE16(tmp);
5480 tmp = tmp + 1;
5481 akmlist = (int *)(tmp);
5482 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5483 {
5484 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5485 }
5486 else
5487 {
5488 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5489 VOS_ASSERT(0);
5490 return -EINVAL;
5491 }
5492
5493 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5494 {
5495 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005496 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305500 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005501 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005502 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5504 }
5505 break;
5506#endif
5507 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305508 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005510 /* when Unknown IE is received we should break and continue
5511 * to the next IE in the buffer instead we were returning
5512 * so changing this to break */
5513 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 }
5515 genie += eLen;
5516 remLen -= eLen;
5517 }
5518 EXIT();
5519 return 0;
5520}
5521
5522/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305523 * FUNCTION: hdd_isWPAIEPresent
5524 * Parse the received IE to find the WPA IE
5525 *
5526 */
5527static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5528{
5529 v_U8_t eLen = 0;
5530 v_U16_t remLen = ie_len;
5531 v_U8_t elementId = 0;
5532
5533 while (remLen >= 2)
5534 {
5535 elementId = *ie++;
5536 eLen = *ie++;
5537 remLen -= 2;
5538 if (eLen > remLen)
5539 {
5540 hddLog(VOS_TRACE_LEVEL_ERROR,
5541 "%s: IE length is wrong %d", __func__, eLen);
5542 return FALSE;
5543 }
5544 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5545 {
5546 /* OUI - 0x00 0X50 0XF2
5547 WPA Information Element - 0x01
5548 WPA version - 0x01*/
5549 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5550 return TRUE;
5551 }
5552 ie += eLen;
5553 remLen -= eLen;
5554 }
5555 return FALSE;
5556}
5557
5558/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305560 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 * parameters during connect operation.
5562 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305563int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 struct cfg80211_connect_params *req
5565 )
5566{
5567 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305568 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005569 ENTER();
5570
5571 /*set wpa version*/
5572 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5573
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305574 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005575 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305576 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005577 {
5578 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5579 }
5580 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5581 {
5582 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5583 }
5584 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305585
5586 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005587 pWextState->wpaVersion);
5588
5589 /*set authentication type*/
5590 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5591
5592 if (0 > status)
5593 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305594 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 "%s: failed to set authentication type ", __func__);
5596 return status;
5597 }
5598
5599 /*set key mgmt type*/
5600 if (req->crypto.n_akm_suites)
5601 {
5602 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5603 if (0 > status)
5604 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305605 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005606 __func__);
5607 return status;
5608 }
5609 }
5610
5611 /*set pairwise cipher type*/
5612 if (req->crypto.n_ciphers_pairwise)
5613 {
5614 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5615 req->crypto.ciphers_pairwise[0], true);
5616 if (0 > status)
5617 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305618 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 "%s: failed to set unicast cipher type", __func__);
5620 return status;
5621 }
5622 }
5623 else
5624 {
5625 /*Reset previous cipher suite to none*/
5626 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5627 if (0 > status)
5628 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305629 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 "%s: failed to set unicast cipher type", __func__);
5631 return status;
5632 }
5633 }
5634
5635 /*set group cipher type*/
5636 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
5637 false);
5638
5639 if (0 > status)
5640 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305641 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 __func__);
5643 return status;
5644 }
5645
Chet Lanctot186b5732013-03-18 10:26:30 -07005646#ifdef WLAN_FEATURE_11W
5647 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
5648#endif
5649
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
5651 if (req->ie_len)
5652 {
5653 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
5654 if ( 0 > status)
5655 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305656 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 __func__);
5658 return status;
5659 }
5660 }
5661
5662 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305663 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 {
5665 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
5666 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
5667 )
5668 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305669 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5671 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305672 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07005673 __func__);
5674 return -EOPNOTSUPP;
5675 }
5676 else
5677 {
5678 u8 key_len = req->key_len;
5679 u8 key_idx = req->key_idx;
5680
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305681 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005682 && (CSR_MAX_NUM_KEY > key_idx)
5683 )
5684 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305685 hddLog(VOS_TRACE_LEVEL_INFO,
5686 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005687 __func__, key_idx, key_len);
5688 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305689 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305691 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 (u8)key_len;
5693 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
5694 }
5695 }
5696 }
5697 }
5698
5699 return status;
5700}
5701
5702/*
5703 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305704 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 * parameters during connect operation.
5706 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305707static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005708 struct net_device *ndev,
5709 struct cfg80211_connect_params *req
5710 )
5711{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305712 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305713 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
5715 hdd_context_t *pHddCtx = NULL;
5716
5717 ENTER();
5718
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305719 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
5721
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305722 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5723 status = wlan_hdd_validate_context(pHddCtx);
5724
5725 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305727 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5728 "%s: HDD context is not valid", __func__);
5729 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 }
5731
5732#ifdef WLAN_BTAMP_FEATURE
5733 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305734 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305736 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005737 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08005738 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 }
5740#endif
5741 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305742 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07005743
5744 if ( 0 > status)
5745 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305746 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 __func__);
5748 return status;
5749 }
5750
5751 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005752 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07005753 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
5754 (vos_concurrent_sessions_running()))
5755 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305756 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 }
5758
Mohit Khanna765234a2012-09-11 15:08:35 -07005759 if ( req->channel )
5760 {
5761 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
5762 req->ssid_len, req->bssid,
5763 req->channel->hw_value);
5764 }
5765 else
5766 {
5767 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305768 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07005769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005770
5771 if (0 > status)
5772 {
5773 //ReEnable BMPS if disabled
5774 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
5775 (NULL != pHddCtx))
5776 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05305777 if (pHddCtx->hdd_wlan_suspended)
5778 {
5779 hdd_set_pwrparams(pHddCtx);
5780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 //ReEnable Bmps and Imps back
5782 hdd_enable_bmps_imps(pHddCtx);
5783 }
5784
5785 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
5786 return status;
5787 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305788 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 EXIT();
5790 return status;
5791}
5792
5793
5794/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305795 * FUNCTION: wlan_hdd_disconnect
5796 * This function is used to issue a disconnect request to SME
5797 */
5798int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
5799{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305800 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305801 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305802 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5803
5804 status = wlan_hdd_validate_context(pHddCtx);
5805
5806 if (0 != status)
5807 {
5808 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5809 "%s: HDD context is not valid", __func__);
5810 return status;
5811 }
5812
5813 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305814 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305815 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305816
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305817 /*issue disconnect*/
5818 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5819 pAdapter->sessionId, reason);
5820
5821 if ( 0 != status )
5822 {
5823 hddLog(VOS_TRACE_LEVEL_ERROR,
5824 "%s csrRoamDisconnect failure, returned %d \n",
5825 __func__, (int)status );
5826 return -EINVAL;
5827 }
5828 wait_for_completion_interruptible_timeout(
5829 &pAdapter->disconnect_comp_var,
5830 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5831 /*stop tx queues*/
5832 netif_tx_disable(pAdapter->dev);
5833 netif_carrier_off(pAdapter->dev);
5834 return status;
5835}
5836
5837
5838/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 * FUNCTION: wlan_hdd_cfg80211_disconnect
5840 * This function is used to issue a disconnect request to SME
5841 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305842static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 struct net_device *dev,
5844 u16 reason
5845 )
5846{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305847 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
5848 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305850 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005852 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05305853#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005854 tANI_U8 staIdx;
5855#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305856
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305858
5859 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 __func__,pAdapter->device_mode);
5861
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305862 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
5863 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005864
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305865 status = wlan_hdd_validate_context(pHddCtx);
5866
5867 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305869 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5870 "%s: HDD context is not valid", __func__);
5871 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305873
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 if (NULL != pRoamProfile)
5875 {
5876 /*issue disconnect request to SME, if station is in connected state*/
5877 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
5878 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305879 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05305881 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 switch(reason)
5883 {
5884 case WLAN_REASON_MIC_FAILURE:
5885 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
5886 break;
5887
5888 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
5889 case WLAN_REASON_DISASSOC_AP_BUSY:
5890 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
5891 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
5892 break;
5893
5894 case WLAN_REASON_PREV_AUTH_NOT_VALID:
5895 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
5896 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
5897 break;
5898
5899 case WLAN_REASON_DEAUTH_LEAVING:
5900 default:
5901 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5902 break;
5903 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05305904 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
5905 pScanInfo = &pHddCtx->scan_info;
5906 if (pScanInfo->mScanPending)
5907 {
5908 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
5909 "Aborting Scan");
5910 hdd_abort_mac_scan(pHddCtx);
5911 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005912
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005913#ifdef FEATURE_WLAN_TDLS
5914 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005915 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005916 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005917 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
5918 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005919 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08005920 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005921 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08005922 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07005923 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005924 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07005925 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005926 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005927 pAdapter->sessionId,
5928 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005929 }
5930 }
5931#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305932 status = wlan_hdd_disconnect(pAdapter, reasonCode);
5933 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 {
5935 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305936 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 __func__, (int)status );
5938 return -EINVAL;
5939 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 }
5941 }
5942 else
5943 {
5944 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
5945 }
5946
5947 return status;
5948}
5949
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305950
Jeff Johnson295189b2012-06-20 16:38:30 -07005951/*
5952 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305953 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 * settings in IBSS mode.
5955 */
5956static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305957 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 struct cfg80211_ibss_params *params
5959 )
5960{
5961 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305962 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5964 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305965
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 ENTER();
5967
5968 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5969
5970 if (params->ie_len && ( NULL != params->ie) )
5971 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005972 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
5973 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005974 {
5975 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5976 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5977 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005978 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005980 tDot11fIEWPA dot11WPAIE;
5981 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005982 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005983
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005984 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
5985 params->ie_len, DOT11F_EID_WPA);
5986 if ( NULL != ie )
5987 {
5988 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5989 // Unpack the WPA IE
5990 //Skip past the EID byte and length byte - and four byte WiFi OUI
5991 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
5992 &ie[2+4],
5993 ie[1] - 4,
5994 &dot11WPAIE);
5995 /*Extract the multicast cipher, the encType for unicast
5996 cipher for wpa-none is none*/
5997 encryptionType =
5998 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
5999 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006001
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6003
6004 if (0 > status)
6005 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306006 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006007 __func__);
6008 return status;
6009 }
6010 }
6011
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306012 pWextState->roamProfile.AuthType.authType[0] =
6013 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6015
6016 if (params->privacy)
6017 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306018 /* Security enabled IBSS, At this time there is no information available
6019 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006020 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306021 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306023 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 *enable privacy bit in beacons */
6025
6026 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6027 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006028 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6029 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6031 pWextState->roamProfile.EncryptionType.numEntries = 1;
6032 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 return status;
6034}
6035
6036/*
6037 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306038 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006039 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306040static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 struct net_device *dev,
6042 struct cfg80211_ibss_params *params
6043 )
6044{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306045 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6047 tCsrRoamProfile *pRoamProfile;
6048 int status;
6049 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306050 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006051
6052 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306053
6054 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6056
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306057 status = wlan_hdd_validate_context(pHddCtx);
6058
6059 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306061 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6062 "%s: HDD context is not valid", __func__);
6063 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 }
6065
6066 if (NULL == pWextState)
6067 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306068 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 __func__);
6070 return -EIO;
6071 }
6072
6073 pRoamProfile = &pWextState->roamProfile;
6074
6075 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6076 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306077 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 "%s Interface type is not set to IBSS \n", __func__);
6079 return -EINVAL;
6080 }
6081
6082 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006083 if (NULL !=
6084#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6085 params->chandef.chan)
6086#else
6087 params->channel)
6088#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 {
6090 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006091 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6092 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6093 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6094 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006095
6096 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306097 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006098 ieee80211_frequency_to_channel(
6099#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6100 params->chandef.chan->center_freq);
6101#else
6102 params->channel->center_freq);
6103#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006104
6105 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6106 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006108 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6109 __func__);
6110 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006112
6113 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006114 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006115 if (channelNum == validChan[indx])
6116 {
6117 break;
6118 }
6119 }
6120 if (indx >= numChans)
6121 {
6122 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 __func__, channelNum);
6124 return -EINVAL;
6125 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006126 /* Set the Operational Channel */
6127 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6128 channelNum);
6129 pRoamProfile->ChannelInfo.numOfChannels = 1;
6130 pHddStaCtx->conn_info.operationChannel = channelNum;
6131 pRoamProfile->ChannelInfo.ChannelList =
6132 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 }
6134
6135 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306136 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006137 if (status < 0)
6138 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306139 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 __func__);
6141 return status;
6142 }
6143
6144 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306145 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006146 params->ssid_len, params->bssid,
6147 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006148
6149 if (0 > status)
6150 {
6151 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6152 return status;
6153 }
6154
6155 return 0;
6156}
6157
6158/*
6159 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306160 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306162static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 struct net_device *dev
6164 )
6165{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306166 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6168 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306169 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6170 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006171
6172 ENTER();
6173
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306174 status = wlan_hdd_validate_context(pHddCtx);
6175
6176 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006177 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306178 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6179 "%s: HDD context is not valid", __func__);
6180 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006181 }
6182
Jeff Johnson295189b2012-06-20 16:38:30 -07006183 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6184 if (NULL == pWextState)
6185 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306186 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 __func__);
6188 return -EIO;
6189 }
6190
6191 pRoamProfile = &pWextState->roamProfile;
6192
6193 /* Issue disconnect only if interface type is set to IBSS */
6194 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6195 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306196 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 __func__);
6198 return -EINVAL;
6199 }
6200
6201 /* Issue Disconnect request */
6202 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6203 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6204 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6205
6206 return 0;
6207}
6208
6209/*
6210 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6211 * This function is used to set the phy parameters
6212 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6213 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306214static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006215 u32 changed)
6216{
6217 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6218 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306219 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006220
6221 ENTER();
6222
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306223 status = wlan_hdd_validate_context(pHddCtx);
6224
6225 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006226 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306227 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6228 "%s: HDD context is not valid", __func__);
6229 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006230 }
6231
Jeff Johnson295189b2012-06-20 16:38:30 -07006232 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6233 {
6234 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6235 WNI_CFG_RTS_THRESHOLD_STAMAX :
6236 wiphy->rts_threshold;
6237
6238 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306239 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306241 hddLog(VOS_TRACE_LEVEL_ERROR,
6242 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 __func__, rts_threshold);
6244 return -EINVAL;
6245 }
6246
6247 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6248 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306249 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006250 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306251 hddLog(VOS_TRACE_LEVEL_ERROR,
6252 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 __func__, rts_threshold);
6254 return -EIO;
6255 }
6256
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306257 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006258 rts_threshold);
6259 }
6260
6261 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6262 {
6263 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6264 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6265 wiphy->frag_threshold;
6266
6267 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306268 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306270 hddLog(VOS_TRACE_LEVEL_ERROR,
6271 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 frag_threshold);
6273 return -EINVAL;
6274 }
6275
6276 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6277 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306278 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306280 hddLog(VOS_TRACE_LEVEL_ERROR,
6281 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 __func__, frag_threshold);
6283 return -EIO;
6284 }
6285
6286 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6287 frag_threshold);
6288 }
6289
6290 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6291 || (changed & WIPHY_PARAM_RETRY_LONG))
6292 {
6293 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6294 wiphy->retry_short :
6295 wiphy->retry_long;
6296
6297 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6298 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6299 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306300 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 __func__, retry_value);
6302 return -EINVAL;
6303 }
6304
6305 if (changed & WIPHY_PARAM_RETRY_SHORT)
6306 {
6307 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6308 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306309 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306311 hddLog(VOS_TRACE_LEVEL_ERROR,
6312 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 __func__, retry_value);
6314 return -EIO;
6315 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306316 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006317 __func__, retry_value);
6318 }
6319 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6320 {
6321 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6322 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306323 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306325 hddLog(VOS_TRACE_LEVEL_ERROR,
6326 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 __func__, retry_value);
6328 return -EIO;
6329 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306330 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 __func__, retry_value);
6332 }
6333 }
6334
6335 return 0;
6336}
6337
6338/*
6339 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6340 * This function is used to set the txpower
6341 */
6342static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006343#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6344 struct wireless_dev *wdev,
6345#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006346#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306347 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006348#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306349 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006350#endif
6351 int dbm)
6352{
6353 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306354 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006355 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6356 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306357 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006358
6359 ENTER();
6360
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306361 status = wlan_hdd_validate_context(pHddCtx);
6362
6363 if (0 != status)
6364 {
6365 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6366 "%s: HDD context is not valid", __func__);
6367 return status;
6368 }
6369
6370 hHal = pHddCtx->hHal;
6371
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306372 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6373 dbm, ccmCfgSetCallback,
6374 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306376 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6378 return -EIO;
6379 }
6380
6381 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6382 dbm);
6383
6384 switch(type)
6385 {
6386 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6387 /* Fall through */
6388 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6389 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6390 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306391 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6392 __func__);
6393 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006394 }
6395 break;
6396 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306397 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 __func__);
6399 return -EOPNOTSUPP;
6400 break;
6401 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306402 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6403 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 return -EIO;
6405 }
6406
6407 return 0;
6408}
6409
6410/*
6411 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6412 * This function is used to read the txpower
6413 */
Yue Maf49ba872013-08-19 12:04:25 -07006414static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6415#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6416 struct wireless_dev *wdev,
6417#endif
6418 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006419{
6420
6421 hdd_adapter_t *pAdapter;
6422 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306423 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006424
Jeff Johnsone7245742012-09-05 17:12:55 -07006425 ENTER();
6426
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306427 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006428
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306429 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006430 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306431 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6432 "%s: HDD context is not valid", __func__);
6433 *dbm = 0;
6434 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006435 }
6436
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6438 if (NULL == pAdapter)
6439 {
6440 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6441 return -ENOENT;
6442 }
6443
6444 wlan_hdd_get_classAstats(pAdapter);
6445 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6446
Jeff Johnsone7245742012-09-05 17:12:55 -07006447 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 return 0;
6449}
6450
6451static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6452 u8* mac, struct station_info *sinfo)
6453{
6454 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6455 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6456 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6457 tANI_U8 rate_flags;
6458
6459 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6460 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006461
6462 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6463 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6464 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6465 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6466 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6467 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6468 tANI_U16 maxRate = 0;
6469 tANI_U16 myRate;
6470 tANI_U16 currentRate = 0;
6471 tANI_U8 maxSpeedMCS = 0;
6472 tANI_U8 maxMCSIdx = 0;
6473 tANI_U8 rateFlag = 1;
6474 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006475 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306476 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006477
Leo Chang6f8870f2013-03-26 18:11:36 -07006478#ifdef WLAN_FEATURE_11AC
6479 tANI_U32 vht_mcs_map;
6480 eDataRate11ACMaxMcs vhtMaxMcs;
6481#endif /* WLAN_FEATURE_11AC */
6482
Jeff Johnsone7245742012-09-05 17:12:55 -07006483 ENTER();
6484
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6486 (0 == ssidlen))
6487 {
6488 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6489 " Invalid ssidlen, %d", __func__, ssidlen);
6490 /*To keep GUI happy*/
6491 return 0;
6492 }
6493
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306494 status = wlan_hdd_validate_context(pHddCtx);
6495
6496 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006497 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306498 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6499 "%s: HDD context is not valid", __func__);
6500 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006501 }
6502
Jeff Johnson295189b2012-06-20 16:38:30 -07006503 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6504 sinfo->filled |= STATION_INFO_SIGNAL;
6505
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006506 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6508
6509 //convert to the UI units of 100kbps
6510 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6511
6512#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006513 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 -07006514 sinfo->signal,
6515 pCfg->reportMaxLinkSpeed,
6516 myRate,
6517 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006518 (int) pCfg->linkSpeedRssiMid,
6519 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006520 (int) rate_flags,
6521 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006522#endif //LINKSPEED_DEBUG_ENABLED
6523
6524 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6525 {
6526 // we do not want to necessarily report the current speed
6527 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6528 {
6529 // report the max possible speed
6530 rssidx = 0;
6531 }
6532 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6533 {
6534 // report the max possible speed with RSSI scaling
6535 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6536 {
6537 // report the max possible speed
6538 rssidx = 0;
6539 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006540 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006541 {
6542 // report middle speed
6543 rssidx = 1;
6544 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006545 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6546 {
6547 // report middle speed
6548 rssidx = 2;
6549 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006550 else
6551 {
6552 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006553 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006554 }
6555 }
6556 else
6557 {
6558 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6559 hddLog(VOS_TRACE_LEVEL_ERROR,
6560 "%s: Invalid value for reportMaxLinkSpeed: %u",
6561 __func__, pCfg->reportMaxLinkSpeed);
6562 rssidx = 0;
6563 }
6564
6565 maxRate = 0;
6566
6567 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306568 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6569 OperationalRates, &ORLeng))
6570 {
6571 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6572 /*To keep GUI happy*/
6573 return 0;
6574 }
6575
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 for (i = 0; i < ORLeng; i++)
6577 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006578 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 {
6580 /* Validate Rate Set */
6581 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6582 {
6583 currentRate = supported_data_rate[j].supported_rate[rssidx];
6584 break;
6585 }
6586 }
6587 /* Update MAX rate */
6588 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6589 }
6590
6591 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306592 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
6593 ExtendedRates, &ERLeng))
6594 {
6595 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6596 /*To keep GUI happy*/
6597 return 0;
6598 }
6599
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 for (i = 0; i < ERLeng; i++)
6601 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006602 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006603 {
6604 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
6605 {
6606 currentRate = supported_data_rate[j].supported_rate[rssidx];
6607 break;
6608 }
6609 }
6610 /* Update MAX rate */
6611 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006613 /* Get MCS Rate Set -- but only if we are connected at MCS
6614 rates or if we are always reporting max speed or if we have
6615 good rssi */
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006616 if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306618 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
6619 MCSRates, &MCSLeng))
6620 {
6621 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6622 /*To keep GUI happy*/
6623 return 0;
6624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07006626#ifdef WLAN_FEATURE_11AC
6627 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306628 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006630 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306631 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07006632 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006634 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006636 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07006637 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006638 maxMCSIdx = 7;
6639 }
6640 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
6641 {
6642 maxMCSIdx = 8;
6643 }
6644 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
6645 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306646 //VHT20 is supporting 0~8
6647 if (rate_flags & eHAL_TX_RATE_VHT20)
6648 maxMCSIdx = 8;
6649 else
6650 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07006651 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306652
6653 if (rate_flags & eHAL_TX_RATE_VHT80)
6654 {
6655 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
6656 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
6657 }
6658 else if (rate_flags & eHAL_TX_RATE_VHT40)
6659 {
6660 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
6661 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
6662 }
6663 else if (rate_flags & eHAL_TX_RATE_VHT20)
6664 {
6665 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
6666 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
6667 }
6668
Leo Chang6f8870f2013-03-26 18:11:36 -07006669 maxSpeedMCS = 1;
6670 if (currentRate > maxRate)
6671 {
6672 maxRate = currentRate;
6673 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306674
Leo Chang6f8870f2013-03-26 18:11:36 -07006675 }
6676 else
6677#endif /* WLAN_FEATURE_11AC */
6678 {
6679 if (rate_flags & eHAL_TX_RATE_HT40)
6680 {
6681 rateFlag |= 1;
6682 }
6683 if (rate_flags & eHAL_TX_RATE_SGI)
6684 {
6685 rateFlag |= 2;
6686 }
6687
6688 for (i = 0; i < MCSLeng; i++)
6689 {
6690 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
6691 for (j = 0; j < temp; j++)
6692 {
6693 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
6694 {
6695 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
6696 break;
6697 }
6698 }
6699 if ((j < temp) && (currentRate > maxRate))
6700 {
6701 maxRate = currentRate;
6702 maxSpeedMCS = 1;
6703 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
6704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 }
6706 }
6707 }
6708
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306709 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
6710 {
6711 maxRate = myRate;
6712 maxSpeedMCS = 1;
6713 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6714 }
6715
Jeff Johnson295189b2012-06-20 16:38:30 -07006716 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006717 if (((maxRate < myRate) && (0 == rssidx)) ||
6718 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 {
6720 maxRate = myRate;
6721 if (rate_flags & eHAL_TX_RATE_LEGACY)
6722 {
6723 maxSpeedMCS = 0;
6724 }
6725 else
6726 {
6727 maxSpeedMCS = 1;
6728 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6729 }
6730 }
6731
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306732 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 {
6734 sinfo->txrate.legacy = maxRate;
6735#ifdef LINKSPEED_DEBUG_ENABLED
6736 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
6737#endif //LINKSPEED_DEBUG_ENABLED
6738 }
6739 else
6740 {
6741 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07006742#ifdef WLAN_FEATURE_11AC
6743 sinfo->txrate.nss = 1;
6744 if (rate_flags & eHAL_TX_RATE_VHT80)
6745 {
6746 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306747 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07006748 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306749 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07006750 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306751 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6752 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6753 }
6754 else if (rate_flags & eHAL_TX_RATE_VHT20)
6755 {
6756 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6757 }
6758#endif /* WLAN_FEATURE_11AC */
6759 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
6760 {
6761 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
6762 if (rate_flags & eHAL_TX_RATE_HT40)
6763 {
6764 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6765 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006766 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006767 if (rate_flags & eHAL_TX_RATE_SGI)
6768 {
6769 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
6770 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306771
Jeff Johnson295189b2012-06-20 16:38:30 -07006772#ifdef LINKSPEED_DEBUG_ENABLED
6773 pr_info("Reporting MCS rate %d flags %x\n",
6774 sinfo->txrate.mcs,
6775 sinfo->txrate.flags );
6776#endif //LINKSPEED_DEBUG_ENABLED
6777 }
6778 }
6779 else
6780 {
6781 // report current rate instead of max rate
6782
6783 if (rate_flags & eHAL_TX_RATE_LEGACY)
6784 {
6785 //provide to the UI in units of 100kbps
6786 sinfo->txrate.legacy = myRate;
6787#ifdef LINKSPEED_DEBUG_ENABLED
6788 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
6789#endif //LINKSPEED_DEBUG_ENABLED
6790 }
6791 else
6792 {
6793 //must be MCS
6794 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07006795#ifdef WLAN_FEATURE_11AC
6796 sinfo->txrate.nss = 1;
6797 if (rate_flags & eHAL_TX_RATE_VHT80)
6798 {
6799 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6800 }
6801 else
6802#endif /* WLAN_FEATURE_11AC */
6803 {
6804 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
6805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 if (rate_flags & eHAL_TX_RATE_SGI)
6807 {
6808 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
6809 }
6810 if (rate_flags & eHAL_TX_RATE_HT40)
6811 {
6812 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6813 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006814#ifdef WLAN_FEATURE_11AC
6815 else if (rate_flags & eHAL_TX_RATE_VHT80)
6816 {
6817 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
6818 }
6819#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07006820#ifdef LINKSPEED_DEBUG_ENABLED
6821 pr_info("Reporting actual MCS rate %d flags %x\n",
6822 sinfo->txrate.mcs,
6823 sinfo->txrate.flags );
6824#endif //LINKSPEED_DEBUG_ENABLED
6825 }
6826 }
6827 sinfo->filled |= STATION_INFO_TX_BITRATE;
6828
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006829 sinfo->tx_packets =
6830 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
6831 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
6832 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
6833 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
6834
6835 sinfo->tx_retries =
6836 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
6837 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
6838 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
6839 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
6840
6841 sinfo->tx_failed =
6842 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
6843 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
6844 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
6845 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
6846
6847 sinfo->filled |=
6848 STATION_INFO_TX_PACKETS |
6849 STATION_INFO_TX_RETRIES |
6850 STATION_INFO_TX_FAILED;
6851
6852 EXIT();
6853 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006854}
6855
6856static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07006857 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07006858{
6859 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306860 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006861 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306862 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006863
Jeff Johnsone7245742012-09-05 17:12:55 -07006864 ENTER();
6865
Jeff Johnson295189b2012-06-20 16:38:30 -07006866 if (NULL == pAdapter)
6867 {
6868 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
6869 return -ENODEV;
6870 }
6871
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306872 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306873 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306874
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306875 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306876 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306877 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6878 "%s: HDD context is not valid", __func__);
6879 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306880 }
6881
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306882 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
6883 (TRUE == pHddCtx->hdd_wlan_suspended) &&
6884 (pHddCtx->cfg_ini->fhostArpOffload) &&
6885 (eConnectionState_Associated ==
6886 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6887 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306888 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306889 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6890 {
6891 hddLog(VOS_TRACE_LEVEL_INFO,
6892 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
6893 __func__, vos_status);
6894 }
6895 }
6896
Jeff Johnson295189b2012-06-20 16:38:30 -07006897 /**The get power cmd from the supplicant gets updated by the nl only
6898 *on successful execution of the function call
6899 *we are oppositely mapped w.r.t mode in the driver
6900 **/
6901 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
6902
Jeff Johnsone7245742012-09-05 17:12:55 -07006903 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 if (VOS_STATUS_E_FAILURE == vos_status)
6905 {
6906 return -EINVAL;
6907 }
6908 return 0;
6909}
6910
6911
6912#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
6913static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
6914 struct net_device *netdev,
6915 u8 key_index)
6916{
Jeff Johnsone7245742012-09-05 17:12:55 -07006917 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 return 0;
6919}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306920#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07006921
6922#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
6923static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
6924 struct net_device *dev,
6925 struct ieee80211_txq_params *params)
6926{
Jeff Johnsone7245742012-09-05 17:12:55 -07006927 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 return 0;
6929}
6930#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
6931static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
6932 struct ieee80211_txq_params *params)
6933{
Jeff Johnsone7245742012-09-05 17:12:55 -07006934 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 return 0;
6936}
6937#endif //LINUX_VERSION_CODE
6938
6939static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
6940 struct net_device *dev, u8 *mac)
6941{
6942 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306943 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006944 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306945 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006946 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006947
Jeff Johnsone7245742012-09-05 17:12:55 -07006948 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306949 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07006950 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306951 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 return -EINVAL;
6953 }
6954
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306955 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6956 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006957
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306958 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006959 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306960 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6961 "%s: HDD context is not valid", __func__);
6962 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006963 }
6964
Jeff Johnson295189b2012-06-20 16:38:30 -07006965 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07006966 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 )
6968 {
6969 if( NULL == mac )
6970 {
6971 v_U16_t i;
6972 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
6973 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07006974 if ((pAdapter->aStaInfo[i].isUsed) &&
6975 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07006976 {
6977 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
6978 hddLog(VOS_TRACE_LEVEL_INFO,
6979 "%s: Delete STA with MAC::"
6980 "%02x:%02x:%02x:%02x:%02x:%02x",
6981 __func__,
6982 macAddr[0], macAddr[1], macAddr[2],
6983 macAddr[3], macAddr[4], macAddr[5]);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07006984 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
6985 if (VOS_IS_STATUS_SUCCESS(vos_status))
6986 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006987 }
6988 }
6989 }
6990 else
6991 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006992
6993 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
6994 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6995 {
6996 hddLog(VOS_TRACE_LEVEL_INFO,
6997 "%s: Skip this DEL STA as this is not used::"
6998 "%02x:%02x:%02x:%02x:%02x:%02x",
6999 __func__,
7000 mac[0], mac[1], mac[2],
7001 mac[3], mac[4], mac[5]);
7002 return -ENOENT;
7003 }
7004
7005 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7006 {
7007 hddLog(VOS_TRACE_LEVEL_INFO,
7008 "%s: Skip this DEL STA as deauth is in progress::"
7009 "%02x:%02x:%02x:%02x:%02x:%02x",
7010 __func__,
7011 mac[0], mac[1], mac[2],
7012 mac[3], mac[4], mac[5]);
7013 return -ENOENT;
7014 }
7015
7016 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7017
Jeff Johnson295189b2012-06-20 16:38:30 -07007018 hddLog(VOS_TRACE_LEVEL_INFO,
7019 "%s: Delete STA with MAC::"
7020 "%02x:%02x:%02x:%02x:%02x:%02x",
7021 __func__,
7022 mac[0], mac[1], mac[2],
7023 mac[3], mac[4], mac[5]);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007024
7025 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7026 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7027 {
7028 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7029 hddLog(VOS_TRACE_LEVEL_INFO,
7030 "%s: STA removal failed for ::"
7031 "%02x:%02x:%02x:%02x:%02x:%02x",
7032 __func__,
7033 mac[0], mac[1], mac[2],
7034 mac[3], mac[4], mac[5]);
7035 return -ENOENT;
7036 }
7037
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 }
7039 }
7040
7041 EXIT();
7042
7043 return 0;
7044}
7045
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007046static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7047 struct net_device *dev, u8 *mac, struct station_parameters *params)
7048{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007049 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007050#ifdef FEATURE_WLAN_TDLS
7051 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007052 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007053 mask = params->sta_flags_mask;
7054
7055 set = params->sta_flags_set;
7056
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007057#ifdef WLAN_FEATURE_TDLS_DEBUG
7058 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7059 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7060 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7061#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007062
7063 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7064 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007065 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007066 }
7067 }
7068#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007069 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007070}
7071
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007072
7073#ifdef FEATURE_WLAN_LFR
7074static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007075 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007076{
7077#define MAX_PMKSAIDS_IN_CACHE 8
7078 static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307079 static tANI_U32 i; // HDD Local Cache index
7080 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007081 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7082 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307083 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307084 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007085 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307086 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307087
Jeff Johnsone7245742012-09-05 17:12:55 -07007088 ENTER();
7089
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307090 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307091 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007092 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307093 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007094 return -EINVAL;
7095 }
7096
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307097 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7098 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007099
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307100 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007101 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307102 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7103 "%s: HDD context is not valid", __func__);
7104 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007105 }
7106
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307107 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007108 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7109
7110 for (j = 0; j < i; j++)
7111 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307112 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007113 pmksa->bssid, WNI_CFG_BSSID_LEN))
7114 {
7115 /* BSSID matched previous entry. Overwrite it. */
7116 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307117 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007118 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307119 vos_mem_copy(PMKIDCache[j].PMKID,
7120 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007121 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307122 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007123 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007124 dump_bssid(pmksa->bssid);
7125 dump_pmkid(halHandle, pmksa->pmkid);
7126 break;
7127 }
7128 }
7129
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007130 /* Check we compared all entries,if then take the first slot now */
7131 if(j == MAX_PMKSAIDS_IN_CACHE) i=0;
7132
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007133 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307134 {
7135 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
7136 vos_mem_copy(PMKIDCache[i].BSSID,
7137 pmksa->bssid, ETHER_ADDR_LEN);
7138 vos_mem_copy(PMKIDCache[i].PMKID,
7139 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007140 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307141 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007142 __func__, i );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007143 dump_bssid(pmksa->bssid);
7144 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307145 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007146 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307147 if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007148 }
7149
7150
7151 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307152 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007153 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307154 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007155 __func__, i );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007156 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307157 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7158 PMKIDCache,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007159 i );
7160 return 0;
7161}
7162
7163
7164static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007165 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007166{
Jeff Johnsone7245742012-09-05 17:12:55 -07007167 ENTER();
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007168 // TODO: Implement this later.
7169 return 0;
7170}
7171
7172static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7173{
Jeff Johnsone7245742012-09-05 17:12:55 -07007174 ENTER();
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007175 // TODO: Implement this later.
7176 return 0;
7177}
7178#endif
7179
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007180#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307181static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007182 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7183{
7184 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7185 hdd_station_ctx_t *pHddStaCtx;
7186
7187 if (NULL == pAdapter)
7188 {
7189 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7190 return -ENODEV;
7191 }
7192
7193 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7194
7195 // Added for debug on reception of Re-assoc Req.
7196 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7197 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307198 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007199 ftie->ie_len);
7200 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7201 }
7202
7203#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307204 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007205 ftie->ie_len);
7206#endif
7207
7208 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307209 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7210 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007211 ftie->ie_len);
7212 return 0;
7213}
7214#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007215
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307216#ifdef FEATURE_WLAN_SCAN_PNO
7217
7218void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7219 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7220{
7221 int ret;
7222 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7223 hdd_context_t *pHddCtx;
7224
7225 if (NULL == pAdapter)
7226 {
7227 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7228 "%s: HDD adapter is Null", __func__);
7229 return ;
7230 }
7231
7232 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7233 if (NULL == pHddCtx)
7234 {
7235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7236 "%s: HDD context is Null!!!", __func__);
7237 return ;
7238 }
7239
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307240 spin_lock(&pHddCtx->schedScan_lock);
7241 if (TRUE == pHddCtx->isWiphySuspended)
7242 {
7243 pHddCtx->isSchedScanUpdatePending = TRUE;
7244 spin_unlock(&pHddCtx->schedScan_lock);
7245 hddLog(VOS_TRACE_LEVEL_INFO,
7246 "%s: Update cfg80211 scan database after it resume", __func__);
7247 return ;
7248 }
7249 spin_unlock(&pHddCtx->schedScan_lock);
7250
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307251 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7252
7253 if (0 > ret)
7254 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7255
7256 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307257 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7258 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307259}
7260
7261/*
7262 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7263 * NL interface to enable PNO
7264 */
7265static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7266 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7267{
7268 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7269 tpSirPNOScanReq pPnoRequest = NULL;
7270 hdd_context_t *pHddCtx;
7271 tHalHandle hHal;
7272 v_U32_t i, indx, num_ch;
7273 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7274 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7275 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7276 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307277 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307278
7279 if (NULL == pAdapter)
7280 {
7281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7282 "%s: HDD adapter is Null", __func__);
7283 return -ENODEV;
7284 }
7285
7286 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307287 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307288
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307289 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307290 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307291 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7292 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307293 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307294 }
7295
7296 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7297 if (NULL == hHal)
7298 {
7299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7300 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307301 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307302 }
7303
7304 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7305 if (NULL == pPnoRequest)
7306 {
7307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7308 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307309 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307310 }
7311
7312 pPnoRequest->enable = 1; /*Enable PNO */
7313 pPnoRequest->ucNetworksCount = request->n_match_sets;
7314
7315 if (( !pPnoRequest->ucNetworksCount ) ||
7316 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7317 {
7318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7319 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307320 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307321 goto error;
7322 }
7323
7324 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7325 {
7326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7327 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307328 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307329 goto error;
7330 }
7331
7332 /* Framework provides one set of channels(all)
7333 * common for all saved profile */
7334 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7335 channels_allowed, &num_channels_allowed))
7336 {
7337 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7338 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307339 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307340 goto error;
7341 }
7342 /* Checking each channel against allowed channel list */
7343 num_ch = 0;
7344 for (i = 0; i < request->n_channels; i++)
7345 {
7346 for (indx = 0; indx < num_channels_allowed; indx++)
7347 {
7348 if (request->channels[i]->hw_value == channels_allowed[indx])
7349 {
7350 valid_ch[num_ch++] = request->channels[i]->hw_value;
7351 break ;
7352 }
7353 }
7354 }
7355
7356 /* Filling per profile params */
7357 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7358 {
7359 pPnoRequest->aNetworks[i].ssId.length =
7360 request->match_sets[i].ssid.ssid_len;
7361
7362 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7363 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7364 {
7365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7366 "SSID Len %d is not correct for network %d",
7367 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307368 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307369 goto error;
7370 }
7371
7372 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7373 request->match_sets[i].ssid.ssid,
7374 request->match_sets[i].ssid.ssid_len);
7375 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7376 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7377 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7378
7379 /*Copying list of valid channel into request */
7380 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7381 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7382
7383 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7384 }
7385
7386 /* framework provides interval in ms */
7387 pPnoRequest->scanTimers.ucScanTimersCount = 1;
7388 pPnoRequest->scanTimers.aTimerValues[0].uTimerValue =
7389 (request->interval)/1000;
7390 pPnoRequest->scanTimers.aTimerValues[0].uTimerRepeat = 0;
7391 pPnoRequest->modePNO = SIR_PNO_MODE_ON_SUSPEND;
7392
7393 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7394 pPnoRequest, pAdapter->sessionId,
7395 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7396 if (eHAL_STATUS_SUCCESS != status)
7397 {
7398 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7399 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307400 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307401 goto error;
7402 }
7403
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7405 "PNO scanRequest offloaded");
7406
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307407error:
7408 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307409 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307410}
7411
7412/*
7413 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
7414 * NL interface to disable PNO
7415 */
7416static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
7417 struct net_device *dev)
7418{
7419 eHalStatus status = eHAL_STATUS_FAILURE;
7420 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7421 hdd_context_t *pHddCtx;
7422 tHalHandle hHal;
7423 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307424 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307425
7426 ENTER();
7427
7428 if (NULL == pAdapter)
7429 {
7430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7431 "%s: HDD adapter is Null", __func__);
7432 return -ENODEV;
7433 }
7434
7435 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307436
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307437 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307438 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307439 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307440 "%s: HDD context is Null", __func__);
7441 return -ENODEV;
7442 }
7443
7444 /* The return 0 is intentional when isLogpInProgress and
7445 * isLoadUnloadInProgress. We did observe a crash due to a return of
7446 * failure in sched_scan_stop , especially for a case where the unload
7447 * of the happens at the same time. The function __cfg80211_stop_sched_scan
7448 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
7449 * success. If it returns a failure , then its next invocation due to the
7450 * clean up of the second interface will have the dev pointer corresponding
7451 * to the first one leading to a crash.
7452 */
7453 if (pHddCtx->isLogpInProgress)
7454 {
7455 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7456 "%s: LOGP in Progress. Ignore!!!", __func__);
7457 return ret;
7458 }
7459
7460 if (pHddCtx->isLoadUnloadInProgress)
7461 {
7462 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7463 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
7464 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307465 }
7466
7467 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7468 if (NULL == hHal)
7469 {
7470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7471 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307472 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307473 }
7474
7475 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7476 if (NULL == pPnoRequest)
7477 {
7478 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7479 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307480 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307481 }
7482
7483 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
7484 pPnoRequest->enable = 0; /* Disable PNO */
7485 pPnoRequest->ucNetworksCount = 0;
7486
7487 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
7488 pAdapter->sessionId,
7489 NULL, pAdapter);
7490 if (eHAL_STATUS_SUCCESS != status)
7491 {
7492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7493 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307494 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307495 }
7496
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307497 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7498 "%s: PNO scan disabled", __func__);
7499
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307500 vos_mem_free(pPnoRequest);
7501
7502 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307503 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307504}
7505
7506#endif /*FEATURE_WLAN_SCAN_PNO*/
7507
7508
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007509#ifdef FEATURE_WLAN_TDLS
7510static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
7511 u8 *peer, u8 action_code, u8 dialog_token,
7512 u16 status_code, const u8 *buf, size_t len)
7513{
7514
7515 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7516 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007517 u8 peerMac[6];
7518 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007519 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08007520 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007521 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007522
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007523 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007524 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307525 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007526 "Invalid arguments");
7527 return -EINVAL;
7528 }
7529
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007530 if (pHddCtx->isLogpInProgress)
7531 {
7532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7533 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007534 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007535 return -EBUSY;
7536 }
7537
Hoonki Lee27511902013-03-14 18:19:06 -07007538 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007539 {
Hoonki Lee27511902013-03-14 18:19:06 -07007540 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7541 "%s: TDLS mode is disabled OR not enabled in FW."
7542 MAC_ADDRESS_STR " action %d declined.",
7543 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007544 return -ENOTSUPP;
7545 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08007546
Hoonki Lee27511902013-03-14 18:19:06 -07007547 /* other than teardown frame, other mgmt frames are not sent if disabled */
7548 if (SIR_MAC_TDLS_TEARDOWN != action_code)
7549 {
7550 /* if tdls_mode is disabled to respond to peer's request */
7551 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
7552 {
7553 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7554 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007555 " TDLS mode is disabled. action %d declined.",
7556 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07007557
7558 return -ENOTSUPP;
7559 }
7560 }
7561
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007562 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
7563 {
Hoonki Leefb8df672013-04-10 18:20:34 -07007564 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007565 {
7566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007567 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007568 " TDLS setup is ongoing. action %d declined.",
7569 __func__, MAC_ADDR_ARRAY(peer), action_code);
7570 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007571 }
7572 }
7573
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007574 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
7575 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08007576 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007577 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08007578 {
7579 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
7580 we return error code at 'add_station()'. Hence we have this
7581 check again in addtion to add_station().
7582 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007583 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08007584 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007585 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7586 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007587 " TDLS Max peer already connected. action %d declined.",
7588 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007589 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08007590 }
7591 else
7592 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007593 /* maximum reached. tweak to send error code to peer and return
7594 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08007595 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007596 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7597 "%s: " MAC_ADDRESS_STR
7598 " TDLS Max peer already connected send response status %d",
7599 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007600 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007601 /* fall through to send setup resp with failure status
7602 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08007603 }
7604 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007605 else
7606 {
7607 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007608 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007609 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007610 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007611 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007612 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
7613 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007614 return -EPERM;
7615 }
7616 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08007617 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007618 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007619
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007620#ifdef WLAN_FEATURE_TDLS_DEBUG
7621 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007622 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
7623 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
7624 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007625#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007626
Hoonki Leea34dd892013-02-05 22:56:02 -08007627 /*Except teardown responder will not be used so just make 0*/
7628 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007629 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08007630 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007631
7632 hddTdlsPeer_t *pTdlsPeer;
7633 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac);
7634
7635 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
7636 responder = pTdlsPeer->is_responder;
7637 else
Hoonki Leea34dd892013-02-05 22:56:02 -08007638 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007639 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7640 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
7641 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
7642 dialog_token, status_code, len);
7643 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08007644 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007645 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007646
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307647 /* For explicit trigger of DIS_REQ come out of BMPS for
7648 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07007649 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307650 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
7651 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07007652 {
7653 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7654 {
7655 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307656 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07007657 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
7658 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307659 if (SIR_MAC_TDLS_DIS_REQ != action_code)
7660 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07007661 }
7662
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007663 /* make sure doesn't call send_mgmt() while it is pending */
7664 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
7665 {
7666 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7667 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
7668 __func__, MAC_ADDR_ARRAY(peer), action_code);
7669 return -EBUSY;
7670 }
7671
7672 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007673 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
7674
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007675 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08007676 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007677
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007678 if (VOS_STATUS_SUCCESS != status)
7679 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007680 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7681 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007682 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07007683 wlan_hdd_tdls_check_bmps(pAdapter);
7684 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007685 }
7686
Hoonki Leed37cbb32013-04-20 00:31:14 -07007687 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
7688 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
7689
7690 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007691 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07007692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7693 "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu",
7694 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007695 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007696 wlan_hdd_tdls_check_bmps(pAdapter);
7697 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007698 }
7699
Gopichand Nakkala05922802013-03-14 12:23:19 -07007700 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07007701 {
7702 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007703 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07007704 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007705
Hoonki Leea34dd892013-02-05 22:56:02 -08007706 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
7707 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007708 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08007709 }
7710 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
7711 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007712 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08007713 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007714
7715 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007716error:
7717 /* max_sta_failed ; we didn't set to CONNECTING for this case,
7718 because we already know that this transaction will be failed,
7719 but we weren't sure if supplicant call DISABLE_LINK or not. So,
7720 to be safe, do not change the state mahine.
7721 */
7722 if(max_sta_failed == 0 &&
7723 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
7724 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
7725 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007726}
7727
7728static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
7729 u8 *peer, enum nl80211_tdls_operation oper)
7730{
7731 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7732 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307733 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05307734#ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP
7735 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05307736 tANI_U8 staIdx;
7737#endif
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007738#ifdef WLAN_FEATURE_TDLS_DEBUG
7739 const char *tdls_oper_str[]= {
7740 "NL80211_TDLS_DISCOVERY_REQ",
7741 "NL80211_TDLS_SETUP",
7742 "NL80211_TDLS_TEARDOWN",
7743 "NL80211_TDLS_ENABLE_LINK",
7744 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05307745 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007746#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007747 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007748
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307749 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007750 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007751 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07007752 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007753 return -EINVAL;
7754 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007755
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307756 status = wlan_hdd_validate_context(pHddCtx);
7757
7758 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007759 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7761 "%s: HDD context is not valid", __func__);
7762 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007763 }
7764
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007765 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer);
7766
7767 if ( NULL == pTdlsPeer ) {
7768 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
7769 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
7770 return -EINVAL;
7771 }
7772
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007773#ifdef WLAN_FEATURE_TDLS_DEBUG
7774 if((int)oper > 4)
7775 oper = 5;
7776
7777 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007778 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
7779 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007780 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007781#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007782
7783 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007784 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007785 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007786 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07007787 "TDLS Disabled in INI OR not enabled in FW. "
7788 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007789 return -ENOTSUPP;
7790 }
7791
7792 switch (oper) {
7793 case NL80211_TDLS_ENABLE_LINK:
7794 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007795 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307796 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007797
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07007798 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
7799 {
7800 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
7801 MAC_ADDRESS_STR " failed",
7802 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
7803 return -EINVAL;
7804 }
7805
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007806 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007807 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307808 long ret;
7809
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307810 if (0 != wlan_hdd_tdls_get_link_establish_params(pAdapter, peer,&tdlsLinkEstablishParams)) {
7811 return -EINVAL;
7812 }
7813 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
7814
7815 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
7816 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
7817 /* Send TDLS peer UAPSD capabilities to the firmware and
7818 * register with the TL on after the response for this operation
7819 * is received .
7820 */
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307821 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_link_establish_req_comp,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307822 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307823 if (ret <= 0)
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307824 {
7825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7826 "%s: Link Establish Request Faled Status %ld",
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307827 __func__, ret);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307828 return -EINVAL;
7829 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007830 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05307831 /* Mark TDLS client Authenticated .*/
7832 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
7833 pTdlsPeer->staId,
7834 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007835 if (VOS_STATUS_SUCCESS == status)
7836 {
Hoonki Lee14621352013-04-16 17:51:19 -07007837 if (pTdlsPeer->is_responder == 0)
7838 {
7839 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
7840
7841 wlan_hdd_tdls_timer_restart(pAdapter,
7842 &pTdlsPeer->initiatorWaitTimeoutTimer,
7843 WAIT_TIME_TDLS_INITIATOR);
7844 /* suspend initiator TX until it receives direct packet from the
7845 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
7846 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
7847 &staId, NULL);
7848 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007849 wlan_hdd_tdls_increment_peer_count(pAdapter);
7850 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007851 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307852
7853 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307854 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
7855 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307856 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307857 int ac;
7858 uint8 ucAc[4] = { WLANTL_AC_VO,
7859 WLANTL_AC_VI,
7860 WLANTL_AC_BK,
7861 WLANTL_AC_BE };
7862 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
7863 for(ac=0; ac < 4; ac++)
7864 {
7865 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
7866 pTdlsPeer->staId, ucAc[ac],
7867 tlTid[ac], tlTid[ac], 0, 0,
7868 WLANTL_BI_DIR );
7869 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307870 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007871 }
7872
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007873 }
7874 break;
7875 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08007876 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007877 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08007878 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007879 long status;
7880
7881 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
7882
Lee Hoonkic1262f22013-01-24 21:59:00 -08007883 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
7884 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007885
7886 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
7887 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
7888 if (status <= 0)
7889 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007890 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7892 "%s: Del station failed status %ld",
7893 __func__, status);
7894 return -EPERM;
7895 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007896 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08007897 }
7898 else
7899 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007900 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7901 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08007902 }
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05307903#ifdef FEATURE_WLAN_TDLS_OXYGEN_DISAPPEAR_AP
7904 if (pHddTdlsCtx->defer_link_lost_indication)
7905 {
7906 if (( TRUE == pHddCtx->cfg_ini->fEnableTDLSOxygenSupport ) &&
7907 (wlan_hdd_tdlsConnectedPeers(pAdapter) == 0))
7908 {
7909 status = wlan_hdd_disconnect(pAdapter, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7910 if ( 0 != status)
7911 {
7912 hddLog(VOS_TRACE_LEVEL_ERROR,
7913 "%s wlan_hdd_disconnect failure, returned %d \n",
7914 __func__, (int)status );
7915 return -EINVAL;
7916 }
7917 }
7918 }
7919#endif
Lee Hoonkic1262f22013-01-24 21:59:00 -08007920 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007921 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007922 case NL80211_TDLS_TEARDOWN:
7923 case NL80211_TDLS_SETUP:
7924 case NL80211_TDLS_DISCOVERY_REQ:
7925 /* We don't support in-driver setup/teardown/discovery */
7926 return -ENOTSUPP;
7927 default:
7928 return -ENOTSUPP;
7929 }
7930 return 0;
7931}
Chilam NG571c65a2013-01-19 12:27:36 +05307932
7933int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
7934 struct net_device *dev, u8 *peer)
7935{
7936 hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x",
7937 peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]);
7938
7939 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
7940 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
7941}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007942#endif
7943
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307944#ifdef WLAN_FEATURE_GTK_OFFLOAD
7945/*
7946 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
7947 * Callback rountine called upon receiving response for
7948 * get offload info
7949 */
7950void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
7951 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
7952{
7953
7954 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307955 tANI_U8 tempReplayCounter[8];
7956 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307957
7958 ENTER();
7959
7960 if (NULL == pAdapter)
7961 {
7962 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7963 "%s: HDD adapter is Null", __func__);
7964 return ;
7965 }
7966
7967 if (NULL == pGtkOffloadGetInfoRsp)
7968 {
7969 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7970 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
7971 return ;
7972 }
7973
7974 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
7975 {
7976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7977 "%s: wlan Failed to get replay counter value",
7978 __func__);
7979 return ;
7980 }
7981
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307982 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7983 /* Update replay counter */
7984 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
7985 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
7986
7987 {
7988 /* changing from little to big endian since supplicant
7989 * works on big endian format
7990 */
7991 int i;
7992 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
7993
7994 for (i = 0; i < 8; i++)
7995 {
7996 tempReplayCounter[7-i] = (tANI_U8)p[i];
7997 }
7998 }
7999
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308000 /* Update replay counter to NL */
8001 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308002 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308003}
8004
8005/*
8006 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
8007 * This function is used to offload GTK rekeying job to the firmware.
8008 */
8009int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
8010 struct cfg80211_gtk_rekey_data *data)
8011{
8012 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8013 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8014 hdd_station_ctx_t *pHddStaCtx;
8015 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308016 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308017 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308018 eHalStatus status = eHAL_STATUS_FAILURE;
8019
8020 ENTER();
8021
8022 if (NULL == pAdapter)
8023 {
8024 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8025 "%s: HDD adapter is Null", __func__);
8026 return -ENODEV;
8027 }
8028
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308029 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308030
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308031 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308032 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308033 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8034 "%s: HDD context is not valid", __func__);
8035 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308036 }
8037
8038 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8039 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8040 if (NULL == hHal)
8041 {
8042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8043 "%s: HAL context is Null!!!", __func__);
8044 return -EAGAIN;
8045 }
8046
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308047 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8048 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8049 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8050 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308051 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308052 {
8053 /* changing from big to little endian since driver
8054 * works on little endian format
8055 */
8056 tANI_U8 *p =
8057 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8058 int i;
8059
8060 for (i = 0; i < 8; i++)
8061 {
8062 p[7-i] = data->replay_ctr[i];
8063 }
8064 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308065
8066 if (TRUE == pHddCtx->hdd_wlan_suspended)
8067 {
8068 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308069 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8070 sizeof (tSirGtkOffloadParams));
8071 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308072 pAdapter->sessionId);
8073
8074 if (eHAL_STATUS_SUCCESS != status)
8075 {
8076 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8077 "%s: sme_SetGTKOffload failed, returned %d",
8078 __func__, status);
8079 return status;
8080 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8082 "%s: sme_SetGTKOffload successfull", __func__);
8083 }
8084 else
8085 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308086 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8087 "%s: wlan not suspended GTKOffload request is stored",
8088 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308089 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308090
8091 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308092}
8093#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8094
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308095/*
8096 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8097 * This function is used to set access control policy
8098 */
8099static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8100 struct net_device *dev, const struct cfg80211_acl_data *params)
8101{
8102 int i;
8103 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8104 hdd_hostapd_state_t *pHostapdState;
8105 tsap_Config_t *pConfig;
8106 v_CONTEXT_t pVosContext = NULL;
8107 hdd_context_t *pHddCtx;
8108 int status;
8109
8110 ENTER();
8111
8112 if (NULL == pAdapter)
8113 {
8114 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8115 "%s: HDD adapter is Null", __func__);
8116 return -ENODEV;
8117 }
8118
8119 if (NULL == params)
8120 {
8121 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8122 "%s: params is Null", __func__);
8123 return -EINVAL;
8124 }
8125
8126 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8127 status = wlan_hdd_validate_context(pHddCtx);
8128
8129 if (0 != status)
8130 {
8131 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8132 "%s: HDD context is not valid", __func__);
8133 return status;
8134 }
8135
8136 pVosContext = pHddCtx->pvosContext;
8137 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8138
8139 if (NULL == pHostapdState)
8140 {
8141 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8142 "%s: pHostapdState is Null", __func__);
8143 return -EINVAL;
8144 }
8145
8146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8147 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8148
8149 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8150 {
8151 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8152
8153 /* default value */
8154 pConfig->num_accept_mac = 0;
8155 pConfig->num_deny_mac = 0;
8156
8157 /**
8158 * access control policy
8159 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8160 * listed in hostapd.deny file.
8161 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8162 * listed in hostapd.accept file.
8163 */
8164 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8165 {
8166 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8167 }
8168 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8169 {
8170 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8171 }
8172 else
8173 {
8174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8175 "%s:Acl Policy : %d is not supported",
8176 __func__, params->acl_policy);
8177 return -ENOTSUPP;
8178 }
8179
8180 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8181 {
8182 pConfig->num_accept_mac = params->n_acl_entries;
8183 for (i = 0; i < params->n_acl_entries; i++)
8184 {
8185 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8186 "** Add ACL MAC entry %i in WhiletList :"
8187 MAC_ADDRESS_STR, i,
8188 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8189
8190 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8191 sizeof(qcmacaddr));
8192 }
8193 }
8194 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8195 {
8196 pConfig->num_deny_mac = params->n_acl_entries;
8197 for (i = 0; i < params->n_acl_entries; i++)
8198 {
8199 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8200 "** Add ACL MAC entry %i in BlackList :"
8201 MAC_ADDRESS_STR, i,
8202 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8203
8204 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8205 sizeof(qcmacaddr));
8206 }
8207 }
8208
8209 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8210 {
8211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8212 "%s: SAP Set Mac Acl fail", __func__);
8213 return -EINVAL;
8214 }
8215 }
8216 else
8217 {
8218 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8219 "%s: Invalid device_mode = %d",
8220 __func__, pAdapter->device_mode);
8221 return -EINVAL;
8222 }
8223
8224 return 0;
8225}
8226
Leo Chang9056f462013-08-01 19:21:11 -07008227#ifdef WLAN_NL80211_TESTMODE
8228#ifdef FEATURE_WLAN_LPHB
8229static void wlan_hdd_cfg80211_lphb_wait_timeout_ind_handler
8230(
8231 void *pAdapter,
8232 void *indCont
8233)
8234{
8235 tSirLPHBTimeoutInd *lphbTimeoutInd;
8236 struct sk_buff *skb;
8237
8238 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8239 "LPHB wait timeout indication arrived");
8240
8241 if (NULL == indCont)
8242 {
8243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8244 "LPHB timeout, invalid argument");
8245 return;
8246 }
8247
8248 lphbTimeoutInd = (tSirLPHBTimeoutInd *)indCont;
8249 skb = cfg80211_testmode_alloc_event_skb(
8250 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
8251 sizeof(tSirLPHBTimeoutInd),
8252 GFP_ATOMIC);
8253 if (!skb)
8254 {
8255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8256 "LPHB timeout, NL buffer alloc fail");
8257 return;
8258 }
8259
8260 NLA_PUT_U32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB);
8261 NLA_PUT_U32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbTimeoutInd->protocolType);
8262 NLA_PUT(skb, WLAN_HDD_TM_ATTR_DATA,
8263 sizeof(tSirLPHBTimeoutInd), lphbTimeoutInd);
8264 cfg80211_testmode_event(skb, GFP_ATOMIC);
8265 return;
8266
8267nla_put_failure:
8268 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8269 "NLA Put fail");
8270 kfree_skb(skb);
8271
8272 return;
8273}
8274#endif /* FEATURE_WLAN_LPHB */
8275
8276static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8277{
8278 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8279 int err = 0;
8280#ifdef FEATURE_WLAN_LPHB
8281 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8282#endif /* FEATURE_WLAN_LPHB */
8283
8284 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8285 if (err)
8286 {
8287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8288 "%s Testmode INV ATTR", __func__);
8289 return err;
8290 }
8291
8292 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8293 {
8294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8295 "%s Testmode INV CMD", __func__);
8296 return -EINVAL;
8297 }
8298
8299 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8300 {
8301#ifdef FEATURE_WLAN_LPHB
8302 /* Low Power Heartbeat configuration request */
8303 case WLAN_HDD_TM_CMD_WLAN_HB:
8304 {
8305 int buf_len;
8306 void *buf;
8307 tSirLPHBReq *hb_params = NULL;
8308
8309 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8310 {
8311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8312 "%s Testmode INV DATA", __func__);
8313 return -EINVAL;
8314 }
8315
8316 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8317 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8318 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8319 if (NULL == hb_params)
8320 {
8321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8322 "%s Request Buffer Alloc Fail", __func__);
8323 return -EINVAL;
8324 }
8325
8326 vos_mem_copy(hb_params, buf, buf_len);
8327
8328 /* LPHB enable and disable request will send to FW
8329 * when host suspend and resume
8330 * host suspend -> enable LPHB
8331 * host resume -> disable LPHB
8332 * if host is not suspend, cache into HDD context
8333 * and when host goes to suspend, send request to FW */
8334 if ((LPHB_SET_EN_PARAMS_INDID == hb_params->cmd) &&
8335 (!pHddCtx->hdd_wlan_suspended))
8336 {
8337 /* Feature enable command cache into HDD context,
8338 * if WLAN is not suspend
8339 * When WLAN goes into suspend, send enable command to FW */
8340 pHddCtx->lphbEnableReq.enable =
8341 hb_params->params.lphbEnableReq.enable;
8342 pHddCtx->lphbEnableReq.item =
8343 hb_params->params.lphbEnableReq.item;
8344 pHddCtx->lphbEnableReq.session =
8345 hb_params->params.lphbEnableReq.session;
8346 vos_mem_free(hb_params);
8347 }
8348 else
8349 {
8350 eHalStatus smeStatus;
8351
8352 /* If WLAN is suspend state, send enable command immediately */
8353 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8354 hb_params,
8355 wlan_hdd_cfg80211_lphb_wait_timeout_ind_handler);
8356 if (eHAL_STATUS_SUCCESS != smeStatus)
8357 {
8358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8359 "LPHB Config Fail, disable");
8360 pHddCtx->lphbEnableReq.enable = 0;
8361 vos_mem_free(hb_params);
8362 }
8363 }
8364 return 0;
8365 }
8366#endif /* FEATURE_WLAN_LPHB */
8367 default:
8368 return -EOPNOTSUPP;
8369 }
8370
8371 return err;
8372}
8373#endif /* CONFIG_NL80211_TESTMODE */
8374
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308375static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8376 struct net_device *dev,
8377 int idx, struct survey_info *survey)
8378{
8379 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8380 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308381 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308382 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308383 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308384 v_S7_t snr,rssi;
8385 int status, i, j, filled = 0;
8386
8387 ENTER();
8388
8389
8390 if (NULL == pAdapter)
8391 {
8392 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8393 "%s: HDD adapter is Null", __func__);
8394 return -ENODEV;
8395 }
8396
8397 if (NULL == wiphy)
8398 {
8399 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8400 "%s: wiphy is Null", __func__);
8401 return -ENODEV;
8402 }
8403
8404 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8405 status = wlan_hdd_validate_context(pHddCtx);
8406
8407 if (0 != status)
8408 {
8409 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8410 "%s: HDD context is not valid", __func__);
8411 return status;
8412 }
8413
Mihir Sheted9072e02013-08-21 17:02:29 +05308414 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8415
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308416 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308417 0 != pAdapter->survey_idx ||
8418 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308419 {
8420 /* The survey dump ops when implemented completely is expected to
8421 * return a survey of all channels and the ops is called by the
8422 * kernel with incremental values of the argument 'idx' till it
8423 * returns -ENONET. But we can only support the survey for the
8424 * operating channel for now. survey_idx is used to track
8425 * that the ops is called only once and then return -ENONET for
8426 * the next iteration
8427 */
8428 pAdapter->survey_idx = 0;
8429 return -ENONET;
8430 }
8431
8432 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8433
8434 wlan_hdd_get_snr(pAdapter, &snr);
8435 wlan_hdd_get_rssi(pAdapter, &rssi);
8436
8437 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
8438 hdd_wlan_get_freq(channel, &freq);
8439
8440
8441 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8442 {
8443 if (NULL == wiphy->bands[i])
8444 {
8445 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
8446 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
8447 continue;
8448 }
8449
8450 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8451 {
8452 struct ieee80211_supported_band *band = wiphy->bands[i];
8453
8454 if (band->channels[j].center_freq == (v_U16_t)freq)
8455 {
8456 survey->channel = &band->channels[j];
8457 /* The Rx BDs contain SNR values in dB for the received frames
8458 * while the supplicant expects noise. So we calculate and
8459 * return the value of noise (dBm)
8460 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
8461 */
8462 survey->noise = rssi - snr;
8463 survey->filled = SURVEY_INFO_NOISE_DBM;
8464 filled = 1;
8465 }
8466 }
8467 }
8468
8469 if (filled)
8470 pAdapter->survey_idx = 1;
8471 else
8472 {
8473 pAdapter->survey_idx = 0;
8474 return -ENONET;
8475 }
8476
8477 return 0;
8478}
8479
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308480/*
8481 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
8482 * this is called when cfg80211 driver resume
8483 * driver updates latest sched_scan scan result(if any) to cfg80211 database
8484 */
8485int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
8486{
8487 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8488 hdd_adapter_t *pAdapter;
8489 hdd_adapter_list_node_t *pAdapterNode, *pNext;
8490 VOS_STATUS status = VOS_STATUS_SUCCESS;
8491
8492 ENTER();
8493
8494 if ( NULL == pHddCtx )
8495 {
8496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8497 "%s: HddCtx validation failed", __func__);
8498 return 0;
8499 }
8500
8501 if (pHddCtx->isLogpInProgress)
8502 {
8503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8504 "%s: LOGP in Progress. Ignore!!!", __func__);
8505 return 0;
8506 }
8507
8508 if (pHddCtx->isLoadUnloadInProgress)
8509 {
8510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8511 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8512 return 0;
8513 }
8514
8515 spin_lock(&pHddCtx->schedScan_lock);
8516 pHddCtx->isWiphySuspended = FALSE;
8517 if (TRUE != pHddCtx->isSchedScanUpdatePending)
8518 {
8519 spin_unlock(&pHddCtx->schedScan_lock);
8520 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8521 "%s: Return resume is not due to PNO indication", __func__);
8522 return 0;
8523 }
8524 // Reset flag to avoid updatating cfg80211 data old results again
8525 pHddCtx->isSchedScanUpdatePending = FALSE;
8526 spin_unlock(&pHddCtx->schedScan_lock);
8527
8528 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8529
8530 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8531 {
8532 pAdapter = pAdapterNode->pAdapter;
8533 if ( (NULL != pAdapter) &&
8534 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
8535 {
8536 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
8537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8538 "%s: NO SCAN result", __func__);
8539 else
8540 cfg80211_sched_scan_results(pHddCtx->wiphy);
8541
8542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8543 "%s : cfg80211 scan result database updated", __func__);
8544
8545 return 0;
8546
8547 }
8548 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8549 pAdapterNode = pNext;
8550 }
8551
8552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8553 "%s: Failed to find Adapter", __func__);
8554 return 0;
8555}
8556
8557/*
8558 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
8559 * this is called when cfg80211 driver suspends
8560 */
8561int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
8562 struct cfg80211_wowlan *wow)
8563{
8564 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8565
8566 ENTER();
8567 if (NULL == pHddCtx)
8568 {
8569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8570 "%s: HddCtx validation failed", __func__);
8571 return 0;
8572 }
8573
8574 pHddCtx->isWiphySuspended = TRUE;
8575
8576 EXIT();
8577
8578 return 0;
8579}
8580
Jeff Johnson295189b2012-06-20 16:38:30 -07008581/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308582static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07008583{
8584 .add_virtual_intf = wlan_hdd_add_virtual_intf,
8585 .del_virtual_intf = wlan_hdd_del_virtual_intf,
8586 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
8587 .change_station = wlan_hdd_change_station,
8588#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8589 .add_beacon = wlan_hdd_cfg80211_add_beacon,
8590 .del_beacon = wlan_hdd_cfg80211_del_beacon,
8591 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008592#else
8593 .start_ap = wlan_hdd_cfg80211_start_ap,
8594 .change_beacon = wlan_hdd_cfg80211_change_beacon,
8595 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07008596#endif
8597 .change_bss = wlan_hdd_cfg80211_change_bss,
8598 .add_key = wlan_hdd_cfg80211_add_key,
8599 .get_key = wlan_hdd_cfg80211_get_key,
8600 .del_key = wlan_hdd_cfg80211_del_key,
8601 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08008602#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08008604#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008605 .scan = wlan_hdd_cfg80211_scan,
8606 .connect = wlan_hdd_cfg80211_connect,
8607 .disconnect = wlan_hdd_cfg80211_disconnect,
8608 .join_ibss = wlan_hdd_cfg80211_join_ibss,
8609 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
8610 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
8611 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
8612 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07008613 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
8614 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
8615 .mgmt_tx = wlan_hdd_action,
8616#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8617 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
8618 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
8619 .set_txq_params = wlan_hdd_set_txq_params,
8620#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008621 .get_station = wlan_hdd_cfg80211_get_station,
8622 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
8623 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008624 .add_station = wlan_hdd_cfg80211_add_station,
8625#ifdef FEATURE_WLAN_LFR
8626 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
8627 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
8628 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
8629#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008630#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
8631 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
8632#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008633#ifdef FEATURE_WLAN_TDLS
8634 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
8635 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
8636#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308637#ifdef WLAN_FEATURE_GTK_OFFLOAD
8638 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
8639#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308640#ifdef FEATURE_WLAN_SCAN_PNO
8641 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
8642 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
8643#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308644 .resume = wlan_hdd_cfg80211_resume_wlan,
8645 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308646 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07008647#ifdef WLAN_NL80211_TESTMODE
8648 .testmode_cmd = wlan_hdd_cfg80211_testmode,
8649#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308650 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07008651};
8652