blob: 6d80f66611cd3f5ef729b09c4b0cb62e886cbd76 [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 {
Madan Mohan Koyyalamudi99ba3582013-05-16 12:52:48 +0530648 /* This will disable updating of NL channels from passive to
649 * active if a beacon is received on passive channel. */
650 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530651 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
652 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700653#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700654 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
655 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
656 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700657 | WIPHY_FLAG_OFFCHAN_TX;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700658#endif
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700659#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
660 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800661#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700662 || pCfg->isFastRoamIniFeatureEnabled
663#endif
664#ifdef FEATURE_WLAN_CCX
665 || pCfg->isCcxIniFeatureEnabled
666#endif
667 )
668 {
669 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
670 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800671#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800672#ifdef FEATURE_WLAN_TDLS
673 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
674 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
675#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530676#ifdef FEATURE_WLAN_SCAN_PNO
677 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
678 wiphy->max_sched_scan_ssids = MAX_SCAN_SSID;
679 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
680#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800681
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700682 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
683 driver can still register regulatory callback and
684 it will get CRDA setting in wiphy->band[], but
685 driver need to determine what to do with both
686 regulatory settings */
687 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700688
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530689 wiphy->max_scan_ssids = MAX_SCAN_SSID;
690
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530691 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700692
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530693 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
694
Jeff Johnson295189b2012-06-20 16:38:30 -0700695 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530696 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 | BIT(NL80211_IFTYPE_P2P_CLIENT)
699 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 | BIT(NL80211_IFTYPE_AP);
701
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800702#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800703 if( pCfg->enableMCC )
704 {
705 /* Currently, supports up to two channels */
706 wlan_hdd_iface_combination.num_different_channels = 2;
707
708 if( !pCfg->allowMCCGODiffBI )
709 wlan_hdd_iface_combination.beacon_int_infra_match = true;
710
711 }
712 wiphy->iface_combinations = &wlan_hdd_iface_combination;
713 wiphy->n_iface_combinations = 1;
714#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800715
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 /* Before registering we need to update the ht capabilitied based
717 * on ini values*/
718 if( !pCfg->ShortGI20MhzEnable )
719 {
720 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
721 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
722 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
723 }
724
725 if( !pCfg->ShortGI40MhzEnable )
726 {
727 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
728 }
729
730 if( !pCfg->nChannelBondingMode5GHz )
731 {
732 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
733 }
734
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530735 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
736 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
737
738 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
739 {
740
741 if (NULL == wiphy->bands[i])
742 {
743 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
744 __func__, i);
745 continue;
746 }
747
748 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
749 {
750 struct ieee80211_supported_band *band = wiphy->bands[i];
751
752 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
753 {
754 // Enable social channels for P2P
755 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
756 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
757 else
758 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
759 continue;
760 }
761 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
762 {
763 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
764 continue;
765 }
766 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 }
768 /*Initialise the supported cipher suite details*/
769 wiphy->cipher_suites = hdd_cipher_suites;
770 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
771
772 /*signal strength in mBm (100*dBm) */
773 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
774
775#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 wiphy->max_remain_on_channel_duration = 1000;
777#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700778
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530779 EXIT();
780 return 0;
781}
782
783/* In this function we are registering wiphy. */
784int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
785{
786 ENTER();
787 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 if (0 > wiphy_register(wiphy))
789 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530790 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
792 return -EIO;
793 }
794
795 EXIT();
796 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530797}
Jeff Johnson295189b2012-06-20 16:38:30 -0700798
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700799/* In this function we will try to get default country code from crda.
800 If the gCrdaDefaultCountryCode is configured in ini file,
801 we will try to call user space crda to get the regulatory settings for
802 that country. We will timeout if we can't get it from crda.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530803 It's called by hdd_wlan_startup() after wlan_hdd_cfg80211_init.
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700804*/
805int wlan_hdd_get_crda_regd_entry(struct wiphy *wiphy, hdd_config_t *pCfg)
806{
807 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Madan Mohan Koyyalamudi113ac742013-08-06 22:45:43 +0530808 int status;
809
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700810 if (memcmp(pCfg->crdaDefaultCountryCode,
811 CFG_CRDA_DEFAULT_COUNTRY_CODE_DEFAULT , 2) != 0)
812 {
Madan Mohan Koyyalamudi113ac742013-08-06 22:45:43 +0530813 INIT_COMPLETION(pHddCtx->driver_crda_req);
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700814 regulatory_hint(wiphy, pCfg->crdaDefaultCountryCode);
Madan Mohan Koyyalamudi113ac742013-08-06 22:45:43 +0530815 status = wait_for_completion_interruptible_timeout(
816 &pHddCtx->driver_crda_req,
817 msecs_to_jiffies(CRDA_WAIT_TIME));
818 if (!status)
819 {
820 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: timeout waiting for CRDA REQ",
821 __func__);
822 }
823
Yunsen Wange3ba1fb2013-04-05 15:04:43 -0700824 /* if the country is not found from current regulatory.bin,
825 fall back to world domain */
826 if (is_crda_regulatory_entry_valid() == VOS_FALSE)
827 crda_regulatory_entry_default(pCfg->crdaDefaultCountryCode, NUM_REG_DOMAINS-1);
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700828 }
829 return 0;
830}
831
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530832/* In this function we are updating channel list when,
833 regulatory domain is FCC and country code is US.
834 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
835 As per FCC smart phone is not a indoor device.
836 GO should not opeate on indoor channels */
837void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
838{
839 int j;
840 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
841 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
842 //Default counrtycode from NV at the time of wiphy initialization.
843 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
844 &defaultCountryCode[0]))
845 {
846 hddLog(LOGE, FL("%s Failed to get default country code from NV"));
847 }
848 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
849 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530850 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
851 {
852 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
853 return;
854 }
855 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
856 {
857 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
858 // Mark UNII -1 band channel as passive
859 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
860 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
861 }
862 }
863}
864
Jeff Johnson295189b2012-06-20 16:38:30 -0700865/* In this function we will do all post VOS start initialization.
866 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530867 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700868*/
869void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
870{
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
872 /* Register for all P2P action, public action etc frames */
873 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
874
Jeff Johnsone7245742012-09-05 17:12:55 -0700875 ENTER();
876
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 /* Right now we are registering these frame when driver is getting
878 initialized. Once we will move to 2.6.37 kernel, in which we have
879 frame register ops, we will move this code as a part of that */
880 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530881 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
883
884 /* GAS Initial Response */
885 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
886 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530887
Jeff Johnson295189b2012-06-20 16:38:30 -0700888 /* GAS Comeback Request */
889 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
890 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
891
892 /* GAS Comeback Response */
893 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
894 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
895
896 /* P2P Public Action */
897 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530898 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700899 P2P_PUBLIC_ACTION_FRAME_SIZE );
900
901 /* P2P Action */
902 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
903 (v_U8_t*)P2P_ACTION_FRAME,
904 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700905
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530906 /* WNM BSS Transition Request frame */
907 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
908 (v_U8_t*)WNM_BSS_ACTION_FRAME,
909 WNM_BSS_ACTION_FRAME_SIZE );
910
Chet Lanctot186b5732013-03-18 10:26:30 -0700911#ifdef WLAN_FEATURE_11W
912 /* SA Query Response Action Frame */
913 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
914 (v_U8_t*)SA_QUERY_FRAME_RSP,
915 SA_QUERY_FRAME_RSP_SIZE );
916#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700917}
918
919void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
920{
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
922 /* Register for all P2P action, public action etc frames */
923 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
924
Jeff Johnsone7245742012-09-05 17:12:55 -0700925 ENTER();
926
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 /* Right now we are registering these frame when driver is getting
928 initialized. Once we will move to 2.6.37 kernel, in which we have
929 frame register ops, we will move this code as a part of that */
930 /* GAS Initial Request */
931
932 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
933 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
934
935 /* GAS Initial Response */
936 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
937 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530938
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 /* GAS Comeback Request */
940 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
941 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
942
943 /* GAS Comeback Response */
944 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
945 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
946
947 /* P2P Public Action */
948 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530949 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700950 P2P_PUBLIC_ACTION_FRAME_SIZE );
951
952 /* P2P Action */
953 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
954 (v_U8_t*)P2P_ACTION_FRAME,
955 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700956
957#ifdef WLAN_FEATURE_11W
958 /* SA Query Response Action Frame */
959 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
960 (v_U8_t*)SA_QUERY_FRAME_RSP,
961 SA_QUERY_FRAME_RSP_SIZE );
962#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700963}
964
965#ifdef FEATURE_WLAN_WAPI
966void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
967 const u8 *mac_addr, u8 *key , int key_Len)
968{
969 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
970 tCsrRoamSetKey setKey;
971 v_BOOL_t isConnected = TRUE;
972 int status = 0;
973 v_U32_t roamId= 0xFF;
974 tANI_U8 *pKeyPtr = NULL;
975 int n = 0;
976
977 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
978 __func__,pAdapter->device_mode);
979
Gopichand Nakkalae7480202013-02-11 15:24:22 +0530980 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 setKey.keyId = key_index; // Store Key ID
982 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
983 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
984 setKey.paeRole = 0 ; // the PAE role
985 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
986 {
987 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
988 }
989 else
990 {
991 isConnected = hdd_connIsConnected(pHddStaCtx);
992 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
993 }
994 setKey.keyLength = key_Len;
995 pKeyPtr = setKey.Key;
996 memcpy( pKeyPtr, key, key_Len);
997
998 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
999 __func__, key_Len);
1000 for (n = 0 ; n < key_Len; n++)
1001 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
1002 __func__,n,setKey.Key[n]);
1003
1004 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
1005 if ( isConnected )
1006 {
1007 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
1008 pAdapter->sessionId, &setKey, &roamId );
1009 }
1010 if ( status != 0 )
1011 {
1012 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1013 "[%4d] sme_RoamSetKey returned ERROR status= %d",
1014 __LINE__, status );
1015 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1016 }
1017}
1018#endif /* FEATURE_WLAN_WAPI*/
1019
1020#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301021int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001022 beacon_data_t **ppBeacon,
1023 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001024#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301025int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001026 beacon_data_t **ppBeacon,
1027 struct cfg80211_beacon_data *params,
1028 int dtim_period)
1029#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301030{
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 int size;
1032 beacon_data_t *beacon = NULL;
1033 beacon_data_t *old = NULL;
1034 int head_len,tail_len;
1035
Jeff Johnsone7245742012-09-05 17:12:55 -07001036 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 if (params->head && !params->head_len)
1038 return -EINVAL;
1039
1040 old = pAdapter->sessionCtx.ap.beacon;
1041
1042 if (!params->head && !old)
1043 return -EINVAL;
1044
1045 if (params->tail && !params->tail_len)
1046 return -EINVAL;
1047
1048#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1049 /* Kernel 3.0 is not updating dtim_period for set beacon */
1050 if (!params->dtim_period)
1051 return -EINVAL;
1052#endif
1053
1054 if(params->head)
1055 head_len = params->head_len;
1056 else
1057 head_len = old->head_len;
1058
1059 if(params->tail || !old)
1060 tail_len = params->tail_len;
1061 else
1062 tail_len = old->tail_len;
1063
1064 size = sizeof(beacon_data_t) + head_len + tail_len;
1065
1066 beacon = kzalloc(size, GFP_KERNEL);
1067
1068 if( beacon == NULL )
1069 return -ENOMEM;
1070
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001071#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001072 if(params->dtim_period || !old )
1073 beacon->dtim_period = params->dtim_period;
1074 else
1075 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001076#else
1077 if(dtim_period || !old )
1078 beacon->dtim_period = dtim_period;
1079 else
1080 beacon->dtim_period = old->dtim_period;
1081#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301082
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1084 beacon->tail = beacon->head + head_len;
1085 beacon->head_len = head_len;
1086 beacon->tail_len = tail_len;
1087
1088 if(params->head) {
1089 memcpy (beacon->head,params->head,beacon->head_len);
1090 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301091 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 if(old)
1093 memcpy (beacon->head,old->head,beacon->head_len);
1094 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301095
Jeff Johnson295189b2012-06-20 16:38:30 -07001096 if(params->tail) {
1097 memcpy (beacon->tail,params->tail,beacon->tail_len);
1098 }
1099 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301100 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 memcpy (beacon->tail,old->tail,beacon->tail_len);
1102 }
1103
1104 *ppBeacon = beacon;
1105
1106 kfree(old);
1107
1108 return 0;
1109
1110}
Jeff Johnson295189b2012-06-20 16:38:30 -07001111
1112v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1113{
1114 int left = length;
1115 v_U8_t *ptr = pIes;
1116 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301117
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301119 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001120 elem_id = ptr[0];
1121 elem_len = ptr[1];
1122 left -= 2;
1123 if(elem_len > left)
1124 {
1125 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001126 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 eid,elem_len,left);
1128 return NULL;
1129 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301130 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 {
1132 return ptr;
1133 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301134
Jeff Johnson295189b2012-06-20 16:38:30 -07001135 left -= elem_len;
1136 ptr += (elem_len + 2);
1137 }
1138 return NULL;
1139}
1140
Jeff Johnson295189b2012-06-20 16:38:30 -07001141/* Check if rate is 11g rate or not */
1142static int wlan_hdd_rate_is_11g(u8 rate)
1143{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001144 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 u8 i;
1146 for (i = 0; i < 8; i++)
1147 {
1148 if(rate == gRateArray[i])
1149 return TRUE;
1150 }
1151 return FALSE;
1152}
1153
1154/* Check for 11g rate and set proper 11g only mode */
1155static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1156 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1157{
1158 u8 i, num_rates = pIe[0];
1159
1160 pIe += 1;
1161 for ( i = 0; i < num_rates; i++)
1162 {
1163 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1164 {
1165 /* If rate set have 11g rate than change the mode to 11G */
1166 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1167 if (pIe[i] & BASIC_RATE_MASK)
1168 {
1169 /* If we have 11g rate as basic rate, it means mode
1170 is 11g only mode.
1171 */
1172 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1173 *pCheckRatesfor11g = FALSE;
1174 }
1175 }
1176 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1177 {
1178 *require_ht = TRUE;
1179 }
1180 }
1181 return;
1182}
1183
1184static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1185{
1186 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1187 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1188 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1189 u8 checkRatesfor11g = TRUE;
1190 u8 require_ht = FALSE;
1191 u8 *pIe=NULL;
1192
1193 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1194
1195 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1196 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1197 if (pIe != NULL)
1198 {
1199 pIe += 1;
1200 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1201 &pConfig->SapHw_mode);
1202 }
1203
1204 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1205 WLAN_EID_EXT_SUPP_RATES);
1206 if (pIe != NULL)
1207 {
1208
1209 pIe += 1;
1210 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1211 &pConfig->SapHw_mode);
1212 }
1213
1214 if( pConfig->channel > 14 )
1215 {
1216 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1217 }
1218
1219 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1220 WLAN_EID_HT_CAPABILITY);
1221
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301222 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 {
1224 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1225 if(require_ht)
1226 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1227 }
1228}
1229
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301230static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1231 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1232{
1233 v_U8_t ielen = 0;
1234 v_U8_t *pIe = NULL;
1235 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1236
1237 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1238 pBeacon->tail, pBeacon->tail_len);
1239
1240 if (pIe)
1241 {
1242 ielen = pIe[1] + 2;
1243 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1244 {
1245 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1246 }
1247 else
1248 {
1249 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1250 return -EINVAL;
1251 }
1252 *total_ielen += ielen;
1253 }
1254 return 0;
1255}
1256
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001257#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001258static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1259 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001260#else
1261static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1262 struct cfg80211_beacon_data *params)
1263#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001264{
1265 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301266 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001268 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001269
1270 genie = vos_mem_malloc(MAX_GENIE_LEN);
1271
1272 if(genie == NULL) {
1273
1274 return -ENOMEM;
1275 }
1276
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301277 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1278 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301280 ret = -EINVAL;
1281 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 }
1283
1284#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301285 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1286 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1287 {
1288 ret = -EINVAL;
1289 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001290 }
1291#endif
1292
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301293 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1294 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301296 ret = -EINVAL;
1297 goto done;
1298 }
1299
1300 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1301 {
1302 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1303 &total_ielen, SS_OUI_TYPE, SS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301305 ret = -EINVAL;
1306 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001307 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001309
1310 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1311 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1312 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1313 {
1314 hddLog(LOGE,
1315 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001316 ret = -EINVAL;
1317 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 }
1319
1320 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1321 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1322 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1323 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1324 ==eHAL_STATUS_FAILURE)
1325 {
1326 hddLog(LOGE,
1327 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001328 ret = -EINVAL;
1329 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 }
1331
1332 // Added for ProResp IE
1333 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1334 {
1335 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1336 u8 probe_rsp_ie_len[3] = {0};
1337 u8 counter = 0;
1338 /* Check Probe Resp Length if it is greater then 255 then Store
1339 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1340 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1341 Store More then 255 bytes into One Variable.
1342 */
1343 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1344 {
1345 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1346 {
1347 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1348 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1349 }
1350 else
1351 {
1352 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1353 rem_probe_resp_ie_len = 0;
1354 }
1355 }
1356
1357 rem_probe_resp_ie_len = 0;
1358
1359 if (probe_rsp_ie_len[0] > 0)
1360 {
1361 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1362 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1363 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1364 probe_rsp_ie_len[0], NULL,
1365 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1366 {
1367 hddLog(LOGE,
1368 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001369 ret = -EINVAL;
1370 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 }
1372 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1373 }
1374
1375 if (probe_rsp_ie_len[1] > 0)
1376 {
1377 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1378 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1379 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1380 probe_rsp_ie_len[1], NULL,
1381 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1382 {
1383 hddLog(LOGE,
1384 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001385 ret = -EINVAL;
1386 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 }
1388 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1389 }
1390
1391 if (probe_rsp_ie_len[2] > 0)
1392 {
1393 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1394 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1395 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1396 probe_rsp_ie_len[2], NULL,
1397 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1398 {
1399 hddLog(LOGE,
1400 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001401 ret = -EINVAL;
1402 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 }
1404 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1405 }
1406
1407 if (probe_rsp_ie_len[1] == 0 )
1408 {
1409 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1410 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1411 eANI_BOOLEAN_FALSE) )
1412 {
1413 hddLog(LOGE,
1414 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1415 }
1416 }
1417
1418 if (probe_rsp_ie_len[2] == 0 )
1419 {
1420 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1421 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1422 eANI_BOOLEAN_FALSE) )
1423 {
1424 hddLog(LOGE,
1425 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1426 }
1427 }
1428
1429 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1430 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1431 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1432 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1433 == eHAL_STATUS_FAILURE)
1434 {
1435 hddLog(LOGE,
1436 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001437 ret = -EINVAL;
1438 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 }
1440 }
1441 else
1442 {
1443 // Reset WNI_CFG_PROBE_RSP Flags
1444 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1445
1446 hddLog(VOS_TRACE_LEVEL_INFO,
1447 "%s: No Probe Response IE received in set beacon",
1448 __func__);
1449 }
1450
1451 // Added for AssocResp IE
1452 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1453 {
1454 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1455 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1456 params->assocresp_ies_len, NULL,
1457 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1458 {
1459 hddLog(LOGE,
1460 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001461 ret = -EINVAL;
1462 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 }
1464
1465 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1466 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1467 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1468 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1469 == eHAL_STATUS_FAILURE)
1470 {
1471 hddLog(LOGE,
1472 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001473 ret = -EINVAL;
1474 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 }
1476 }
1477 else
1478 {
1479 hddLog(VOS_TRACE_LEVEL_INFO,
1480 "%s: No Assoc Response IE received in set beacon",
1481 __func__);
1482
1483 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1484 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1485 eANI_BOOLEAN_FALSE) )
1486 {
1487 hddLog(LOGE,
1488 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1489 }
1490 }
1491
Jeff Johnsone7245742012-09-05 17:12:55 -07001492done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301494 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001495}
Jeff Johnson295189b2012-06-20 16:38:30 -07001496
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301497/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 * FUNCTION: wlan_hdd_validate_operation_channel
1499 * called by wlan_hdd_cfg80211_start_bss() and
1500 * wlan_hdd_cfg80211_set_channel()
1501 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301502 * channel list.
1503 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001504VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001505{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301506
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 v_U32_t num_ch = 0;
1508 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1509 u32 indx = 0;
1510 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301511 v_U8_t fValidChannel = FALSE, count = 0;
1512 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301513
Jeff Johnson295189b2012-06-20 16:38:30 -07001514 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1515
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301516 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301518 /* Validate the channel */
1519 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001520 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301521 if ( channel == rfChannels[count].channelNum )
1522 {
1523 fValidChannel = TRUE;
1524 break;
1525 }
1526 }
1527 if (fValidChannel != TRUE)
1528 {
1529 hddLog(VOS_TRACE_LEVEL_ERROR,
1530 "%s: Invalid Channel [%d]", __func__, channel);
1531 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001532 }
1533 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301534 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301536 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1537 valid_ch, &num_ch))
1538 {
1539 hddLog(VOS_TRACE_LEVEL_ERROR,
1540 "%s: failed to get valid channel list", __func__);
1541 return VOS_STATUS_E_FAILURE;
1542 }
1543 for (indx = 0; indx < num_ch; indx++)
1544 {
1545 if (channel == valid_ch[indx])
1546 {
1547 break;
1548 }
1549 }
1550
1551 if (indx >= num_ch)
1552 {
1553 hddLog(VOS_TRACE_LEVEL_ERROR,
1554 "%s: Invalid Channel [%d]", __func__, channel);
1555 return VOS_STATUS_E_FAILURE;
1556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 }
1558 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301559
Jeff Johnson295189b2012-06-20 16:38:30 -07001560}
1561
Viral Modi3a32cc52013-02-08 11:14:52 -08001562/**
1563 * FUNCTION: wlan_hdd_cfg80211_set_channel
1564 * This function is used to set the channel number
1565 */
1566static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1567 struct ieee80211_channel *chan,
1568 enum nl80211_channel_type channel_type
1569 )
1570{
1571 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001572 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001573 hdd_adapter_t *pAdapter = NULL;
1574 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301575 hdd_context_t *pHddCtx;
1576 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001577
1578 ENTER();
1579
1580 if( NULL == dev )
1581 {
1582 hddLog(VOS_TRACE_LEVEL_ERROR,
1583 "%s: Called with dev = NULL.\n", __func__);
1584 return -ENODEV;
1585 }
1586 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1587
1588 hddLog(VOS_TRACE_LEVEL_INFO,
1589 "%s: device_mode = %d freq = %d \n",__func__,
1590 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301591
1592 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1593 status = wlan_hdd_validate_context(pHddCtx);
1594
1595 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001596 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301597 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1598 "%s: HDD context is not valid", __func__);
1599 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001600 }
1601
1602 /*
1603 * Do freq to chan conversion
1604 * TODO: for 11a
1605 */
1606
1607 channel = ieee80211_frequency_to_channel(freq);
1608
1609 /* Check freq range */
1610 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1611 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1612 {
1613 hddLog(VOS_TRACE_LEVEL_ERROR,
1614 "%s: Channel [%d] is outside valid range from %d to %d\n",
1615 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1616 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1617 return -EINVAL;
1618 }
1619
1620 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1621
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301622 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1623 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001624 {
1625 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1626 {
1627 hddLog(VOS_TRACE_LEVEL_ERROR,
1628 "%s: Invalid Channel [%d] \n", __func__, channel);
1629 return -EINVAL;
1630 }
1631 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1632 "%s: set channel to [%d] for device mode =%d",
1633 __func__, channel,pAdapter->device_mode);
1634 }
1635 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001636 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001637 )
1638 {
1639 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1640 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1641 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1642
1643 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1644 {
1645 /* Link is up then return cant set channel*/
1646 hddLog( VOS_TRACE_LEVEL_ERROR,
1647 "%s: IBSS Associated, can't set the channel\n", __func__);
1648 return -EINVAL;
1649 }
1650
1651 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1652 pHddStaCtx->conn_info.operationChannel = channel;
1653 pRoamProfile->ChannelInfo.ChannelList =
1654 &pHddStaCtx->conn_info.operationChannel;
1655 }
1656 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001657 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001658 )
1659 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301660 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1661 {
1662 if(VOS_STATUS_SUCCESS !=
1663 wlan_hdd_validate_operation_channel(pAdapter,channel))
1664 {
1665 hddLog(VOS_TRACE_LEVEL_ERROR,
1666 "%s: Invalid Channel [%d] \n", __func__, channel);
1667 return -EINVAL;
1668 }
1669 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1670 }
1671 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001672 {
1673 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1674
1675 /* If auto channel selection is configured as enable/ 1 then ignore
1676 channel set by supplicant
1677 */
1678 if ( cfg_param->apAutoChannelSelection )
1679 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301680 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1681 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001682 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1683 "%s: set channel to auto channel (0) for device mode =%d",
1684 __func__, pAdapter->device_mode);
1685 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301686 else
1687 {
1688 if(VOS_STATUS_SUCCESS !=
1689 wlan_hdd_validate_operation_channel(pAdapter,channel))
1690 {
1691 hddLog(VOS_TRACE_LEVEL_ERROR,
1692 "%s: Invalid Channel [%d] \n", __func__, channel);
1693 return -EINVAL;
1694 }
1695 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1696 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001697 }
1698 }
1699 else
1700 {
1701 hddLog(VOS_TRACE_LEVEL_FATAL,
1702 "%s: Invalid device mode failed to set valid channel", __func__);
1703 return -EINVAL;
1704 }
1705 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301706 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001707}
1708
Jeff Johnson295189b2012-06-20 16:38:30 -07001709#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1710static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1711 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001712#else
1713static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1714 struct cfg80211_beacon_data *params,
1715 const u8 *ssid, size_t ssid_len,
1716 enum nl80211_hidden_ssid hidden_ssid)
1717#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001718{
1719 tsap_Config_t *pConfig;
1720 beacon_data_t *pBeacon = NULL;
1721 struct ieee80211_mgmt *pMgmt_frame;
1722 v_U8_t *pIe=NULL;
1723 v_U16_t capab_info;
1724 eCsrAuthType RSNAuthType;
1725 eCsrEncryptionType RSNEncryptType;
1726 eCsrEncryptionType mcRSNEncryptType;
1727 int status = VOS_STATUS_SUCCESS;
1728 tpWLAN_SAPEventCB pSapEventCallback;
1729 hdd_hostapd_state_t *pHostapdState;
1730 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1731 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301732 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 struct qc_mac_acl_entry *acl_entry = NULL;
1734 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001735 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001736
1737 ENTER();
1738
1739 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1740
1741 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1742
1743 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1744
1745 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1746
1747 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1748
1749 //channel is already set in the set_channel Call back
1750 //pConfig->channel = pCommitConfig->channel;
1751
1752 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301753 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1755
1756 pConfig->dtim_period = pBeacon->dtim_period;
1757
1758 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1759 pConfig->dtim_period);
1760
1761
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001762 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001763 {
1764 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001765 WLAN_EID_COUNTRY);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001766 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001768 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001769 pConfig->ieee80211d = 1;
1770 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1771 sme_setRegInfo(hHal, pConfig->countryCode);
1772 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001774 else
1775 {
1776 pConfig->ieee80211d = 0;
1777 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301778 /*
1779 * If auto channel is configured i.e. channel is 0,
1780 * so skip channel validation.
1781 */
1782 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1783 {
1784 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1785 {
1786 hddLog(VOS_TRACE_LEVEL_ERROR,
1787 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1788 return -EINVAL;
1789 }
1790 }
1791 else
1792 {
1793 if(1 != pHddCtx->is_dynamic_channel_range_set)
1794 {
1795 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1796 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1797 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1798 }
1799 pHddCtx->is_dynamic_channel_range_set = 0;
1800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001801 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001802 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 {
1804 pConfig->ieee80211d = 0;
1805 }
1806 pConfig->authType = eSAP_AUTO_SWITCH;
1807
1808 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301809
1810 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001811 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1812
1813 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1814
1815 /*Set wps station to configured*/
1816 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1817
1818 if(pIe)
1819 {
1820 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1821 {
1822 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1823 return -EINVAL;
1824 }
1825 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1826 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001827 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 /* Check 15 bit of WPS IE as it contain information for wps state
1829 * WPS state
1830 */
1831 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1832 {
1833 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1834 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1835 {
1836 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1837 }
1838 }
1839 }
1840 else
1841 {
1842 pConfig->wps_state = SAP_WPS_DISABLED;
1843 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301844 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001845
1846 pConfig->RSNWPAReqIELength = 0;
1847 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301848 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 WLAN_EID_RSN);
1850 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301851 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1853 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1854 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301855 /* The actual processing may eventually be more extensive than
1856 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 * by the app.
1858 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301859 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001860 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1861 &RSNEncryptType,
1862 &mcRSNEncryptType,
1863 &RSNAuthType,
1864 pConfig->pRSNWPAReqIE[1]+2,
1865 pConfig->pRSNWPAReqIE );
1866
1867 if( VOS_STATUS_SUCCESS == status )
1868 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301869 /* Now copy over all the security attributes you have
1870 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 * */
1872 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1873 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1874 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1875 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301876 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 "EncryptionType = %d mcEncryptionType = %d\n"),
1878 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1879 }
1880 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301881
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1883 pBeacon->tail, pBeacon->tail_len);
1884
1885 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1886 {
1887 if (pConfig->pRSNWPAReqIE)
1888 {
1889 /*Mixed mode WPA/WPA2*/
1890 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1891 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1892 }
1893 else
1894 {
1895 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1896 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1897 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301898 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1900 &RSNEncryptType,
1901 &mcRSNEncryptType,
1902 &RSNAuthType,
1903 pConfig->pRSNWPAReqIE[1]+2,
1904 pConfig->pRSNWPAReqIE );
1905
1906 if( VOS_STATUS_SUCCESS == status )
1907 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301908 /* Now copy over all the security attributes you have
1909 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 * */
1911 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1912 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1913 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1914 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301915 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 "EncryptionType = %d mcEncryptionType = %d\n"),
1917 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1918 }
1919 }
1920 }
1921
Jeff Johnson4416a782013-03-25 14:17:50 -07001922 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1923 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1924 return -EINVAL;
1925 }
1926
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1928
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001929#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 if (params->ssid != NULL)
1931 {
1932 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1933 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1934 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1935 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1936 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001937#else
1938 if (ssid != NULL)
1939 {
1940 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1941 pConfig->SSIDinfo.ssid.length = ssid_len;
1942 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1943 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1944 }
1945#endif
1946
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301947 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301949
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 /* default value */
1951 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1952 pConfig->num_accept_mac = 0;
1953 pConfig->num_deny_mac = 0;
1954
1955 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1956 pBeacon->tail, pBeacon->tail_len);
1957
1958 /* pIe for black list is following form:
1959 type : 1 byte
1960 length : 1 byte
1961 OUI : 4 bytes
1962 acl type : 1 byte
1963 no of mac addr in black list: 1 byte
1964 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301965 */
1966 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001967 {
1968 pConfig->SapMacaddr_acl = pIe[6];
1969 pConfig->num_deny_mac = pIe[7];
1970 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
1971 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05301972 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
1973 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001974 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
1975 for (i = 0; i < pConfig->num_deny_mac; i++)
1976 {
1977 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
1978 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 }
1981 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1982 pBeacon->tail, pBeacon->tail_len);
1983
1984 /* pIe for white list is following form:
1985 type : 1 byte
1986 length : 1 byte
1987 OUI : 4 bytes
1988 acl type : 1 byte
1989 no of mac addr in white list: 1 byte
1990 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301991 */
1992 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 {
1994 pConfig->SapMacaddr_acl = pIe[6];
1995 pConfig->num_accept_mac = pIe[7];
1996 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
1997 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05301998 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
1999 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002000 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2001 for (i = 0; i < pConfig->num_accept_mac; i++)
2002 {
2003 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2004 acl_entry++;
2005 }
2006 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302007
Jeff Johnson295189b2012-06-20 16:38:30 -07002008 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2009
Jeff Johnsone7245742012-09-05 17:12:55 -07002010#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002011 /* Overwrite the hostapd setting for HW mode only for 11ac.
2012 * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini .
2013 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */
2014 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2015 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302016 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002017 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
2018 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002019 {
2020 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002021
2022 /* Disable VHT support in 2.4 GHz band */
2023 if (pConfig->channel <= 14 &&
2024 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2025 {
2026 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2027 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002028 }
2029#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302030
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002031 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2032 {
2033 sme_SelectCBMode(hHal,
2034 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2035 pConfig->channel);
2036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002037 // ht_capab is not what the name conveys,this is used for protection bitmap
2038 pConfig->ht_capab =
2039 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2040
2041 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2042 {
2043 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2044 return -EINVAL;
2045 }
2046
2047 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302048 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2050 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302051 pConfig->obssProtEnabled =
2052 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002053
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302054 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302056 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
2058 (int)pConfig->channel);
2059 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302060 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
2061 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302063 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002064 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
2065 pConfig->protEnabled, pConfig->obssProtEnabled);
2066
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302067 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002068 {
2069 //Bss already started. just return.
2070 //TODO Probably it should update some beacon params.
2071 hddLog( LOGE, "Bss Already started...Ignore the request");
2072 EXIT();
2073 return 0;
2074 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302075
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 pConfig->persona = pHostapdAdapter->device_mode;
2077
2078 pSapEventCallback = hdd_hostapd_SAPEventCB;
2079 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2080 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2081 {
2082 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2083 return -EINVAL;
2084 }
2085
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302086 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2088
2089 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302090
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302092 {
2093 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 ("ERROR: HDD vos wait for single_event failed!!\n"));
2095 VOS_ASSERT(0);
2096 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302097
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 //Succesfully started Bss update the state bit.
2099 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2100
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002101#ifdef WLAN_FEATURE_P2P_DEBUG
2102 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2103 {
2104 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2105 {
2106 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2107 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002108 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002109 }
2110 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2111 {
2112 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2113 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002114 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002115 }
2116 }
2117#endif
2118
Jeff Johnson295189b2012-06-20 16:38:30 -07002119 pHostapdState->bCommit = TRUE;
2120 EXIT();
2121
2122 return 0;
2123}
2124
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002125#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302126static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2127 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 struct beacon_parameters *params)
2129{
2130 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302131 hdd_context_t *pHddCtx;
2132 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002133
2134 ENTER();
2135
2136 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
2137
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302138 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2139 status = wlan_hdd_validate_context(pHddCtx);
2140
2141 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002142 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302143 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2144 "%s: HDD context is not valid", __func__);
2145 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002146 }
2147
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302148 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 )
2151 {
2152 beacon_data_t *old,*new;
2153
2154 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302155
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 if (old)
2157 return -EALREADY;
2158
2159 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2160
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302161 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 {
2163 hddLog(VOS_TRACE_LEVEL_FATAL,
2164 "%s:Error!!! Allocating the new beacon\n",__func__);
2165 return -EINVAL;
2166 }
2167
2168 pAdapter->sessionCtx.ap.beacon = new;
2169
2170 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2171 }
2172
2173 EXIT();
2174 return status;
2175}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302176
2177static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002178 struct net_device *dev,
2179 struct beacon_parameters *params)
2180{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302181 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302182 hdd_context_t *pHddCtx;
2183 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002184
2185 ENTER();
2186
2187 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2188 __func__,pAdapter->device_mode);
2189
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302190 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2191 status = wlan_hdd_validate_context(pHddCtx);
2192
2193 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002194 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302195 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2196 "%s: HDD context is not valid", __func__);
2197 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002198 }
2199
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302200 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302202 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 {
2204 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302205
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302207
Jeff Johnson295189b2012-06-20 16:38:30 -07002208 if (!old)
2209 return -ENOENT;
2210
2211 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2212
2213 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302214 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 "%s: Error!!! Allocating the new beacon\n",__func__);
2216 return -EINVAL;
2217 }
2218
2219 pAdapter->sessionCtx.ap.beacon = new;
2220
2221 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2222 }
2223
2224 EXIT();
2225 return status;
2226}
2227
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002228#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2229
2230#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002231static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2232 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002233#else
2234static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2235 struct net_device *dev)
2236#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002237{
2238 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002239 hdd_context_t *pHddCtx = NULL;
2240 hdd_scaninfo_t *pScanInfo = NULL;
2241 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302242 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002243
2244 ENTER();
2245
2246 if (NULL == pAdapter)
2247 {
2248 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002249 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 return -ENODEV;
2251 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002252
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302253 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2254 status = wlan_hdd_validate_context(pHddCtx);
2255
2256 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002257 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302258 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2259 "%s: HDD context is not valid", __func__);
2260 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002261 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002262
2263 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2264 if (NULL == staAdapter)
2265 {
2266 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2267 if (NULL == staAdapter)
2268 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302269 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002270 "%s: HDD adapter context is Null", __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002271 return -ENODEV;
2272 }
2273 }
2274
2275 pScanInfo = &pHddCtx->scan_info;
2276
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2278 __func__,pAdapter->device_mode);
2279
Jeff Johnsone7245742012-09-05 17:12:55 -07002280 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
2281 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002282 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05302283 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002284 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002285 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002286 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2287 if (!status)
2288 {
2289 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson902c9832012-12-10 14:28:09 -08002290 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002291 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002292 VOS_ASSERT(pScanInfo->mScanPending);
2293 return 0;
2294 }
2295 }
2296
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 )
2300 {
2301 beacon_data_t *old;
2302
2303 old = pAdapter->sessionCtx.ap.beacon;
2304
2305 if (!old)
2306 return -ENOENT;
2307
Jeff Johnson295189b2012-06-20 16:38:30 -07002308 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002309
2310 mutex_lock(&pHddCtx->sap_lock);
2311 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2312 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002313 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 {
2315 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2316
2317 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2318
2319 if (!VOS_IS_STATUS_SUCCESS(status))
2320 {
2321 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2322 ("ERROR: HDD vos wait for single_event failed!!\n"));
2323 VOS_ASSERT(0);
2324 }
2325 }
2326 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2327 }
2328 mutex_unlock(&pHddCtx->sap_lock);
2329
2330 if(status != VOS_STATUS_SUCCESS)
2331 {
2332 hddLog(VOS_TRACE_LEVEL_FATAL,
2333 "%s:Error!!! Stopping the BSS\n",__func__);
2334 return -EINVAL;
2335 }
2336
Jeff Johnson4416a782013-03-25 14:17:50 -07002337 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2339 ==eHAL_STATUS_FAILURE)
2340 {
2341 hddLog(LOGE,
2342 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2343 }
2344
Jeff Johnson4416a782013-03-25 14:17:50 -07002345 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2347 eANI_BOOLEAN_FALSE) )
2348 {
2349 hddLog(LOGE,
2350 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2351 }
2352
2353 // Reset WNI_CFG_PROBE_RSP Flags
2354 wlan_hdd_reset_prob_rspies(pAdapter);
2355
2356 pAdapter->sessionCtx.ap.beacon = NULL;
2357 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002358#ifdef WLAN_FEATURE_P2P_DEBUG
2359 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2360 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2361 {
2362 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2363 "GO got removed");
2364 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2365 }
2366#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 }
2368 EXIT();
2369 return status;
2370}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002371
2372#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2373
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302374static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2375 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002376 struct cfg80211_ap_settings *params)
2377{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302378 hdd_adapter_t *pAdapter;
2379 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302380 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002381
2382 ENTER();
2383
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302384 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002385 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302386 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302387 "%s: Device is Null", __func__);
2388 return -ENODEV;
2389 }
2390
2391 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2392 if (NULL == pAdapter)
2393 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302394 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302395 "%s: HDD adapter is Null", __func__);
2396 return -ENODEV;
2397 }
2398
2399 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2400 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302401 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302402 "%s: HDD adapter magic is invalid", __func__);
2403 return -ENODEV;
2404 }
2405
2406 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302407 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302408
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302409 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302410 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302411 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2412 "%s: HDD context is not valid", __func__);
2413 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302414 }
2415
2416 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2417 __func__, pAdapter->device_mode);
2418
2419 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002420 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002421 )
2422 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302423 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002424
2425 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302426
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002427 if (old)
2428 return -EALREADY;
2429
2430 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2431
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302432 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002433 {
2434 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302435 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002436 return -EINVAL;
2437 }
2438 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002439#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002440 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2441#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2442 params->channel, params->channel_type);
2443#else
2444 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2445#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002446#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002447 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2448 params->ssid_len, params->hidden_ssid);
2449 }
2450
2451 EXIT();
2452 return status;
2453}
2454
2455
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302456static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002457 struct net_device *dev,
2458 struct cfg80211_beacon_data *params)
2459{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302460 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302461 hdd_context_t *pHddCtx;
2462 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002463
2464 ENTER();
2465
2466 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2467 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302468
2469 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2470 status = wlan_hdd_validate_context(pHddCtx);
2471
2472 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002473 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302474 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2475 "%s: HDD context is not valid", __func__);
2476 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002477 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002478
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302479 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002480 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302481 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002482 {
2483 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302484
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002485 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302486
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002487 if (!old)
2488 return -ENOENT;
2489
2490 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2491
2492 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302493 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002494 "%s: Error!!! Allocating the new beacon\n",__func__);
2495 return -EINVAL;
2496 }
2497
2498 pAdapter->sessionCtx.ap.beacon = new;
2499
2500 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2501 }
2502
2503 EXIT();
2504 return status;
2505}
2506
2507#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2508
Jeff Johnson295189b2012-06-20 16:38:30 -07002509
2510static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2511 struct net_device *dev,
2512 struct bss_parameters *params)
2513{
2514 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2515
2516 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302517
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2519 __func__,pAdapter->device_mode);
2520
2521 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302523 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 {
2525 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2526 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302527 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 {
2529 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002531 }
2532
2533 EXIT();
2534 return 0;
2535}
2536
2537/*
2538 * FUNCTION: wlan_hdd_cfg80211_change_iface
2539 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2540 */
2541int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2542 struct net_device *ndev,
2543 enum nl80211_iftype type,
2544 u32 *flags,
2545 struct vif_params *params
2546 )
2547{
2548 struct wireless_dev *wdev;
2549 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2550 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002551 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 tCsrRoamProfile *pRoamProfile = NULL;
2553 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302554 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 eMib_dot11DesiredBssType connectedBssType;
2556 VOS_STATUS status;
2557
2558 ENTER();
2559
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302560 status = wlan_hdd_validate_context(pHddCtx);
2561
2562 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302564 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2565 "%s: HDD context is not valid", __func__);
2566 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 }
2568
2569 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2570 __func__, pAdapter->device_mode);
2571
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302572 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002573 wdev = ndev->ieee80211_ptr;
2574
2575#ifdef WLAN_BTAMP_FEATURE
2576 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2577 (NL80211_IFTYPE_ADHOC == type)||
2578 (NL80211_IFTYPE_AP == type)||
2579 (NL80211_IFTYPE_P2P_GO == type))
2580 {
2581 pHddCtx->isAmpAllowed = VOS_FALSE;
2582 // stop AMP traffic
2583 status = WLANBAP_StopAmp();
2584 if(VOS_STATUS_SUCCESS != status )
2585 {
2586 pHddCtx->isAmpAllowed = VOS_TRUE;
2587 hddLog(VOS_TRACE_LEVEL_FATAL,
2588 "%s: Failed to stop AMP", __func__);
2589 return -EINVAL;
2590 }
2591 }
2592#endif //WLAN_BTAMP_FEATURE
2593 /* Reset the current device mode bit mask*/
2594 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2595
2596 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002598 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 )
2600 {
2601 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2602 pRoamProfile = &pWextState->roamProfile;
2603 LastBSSType = pRoamProfile->BSSType;
2604
2605 switch (type)
2606 {
2607 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 hddLog(VOS_TRACE_LEVEL_INFO,
2610 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2611 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002612#ifdef WLAN_FEATURE_11AC
2613 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2614 {
2615 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2616 }
2617#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302618 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002619 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002621 //Check for sub-string p2p to confirm its a p2p interface
2622 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302623 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002624 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2625 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2626 }
2627 else
2628 {
2629 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002631 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302632#ifdef FEATURE_WLAN_TDLS
2633 /* The open adapter for the p2p shall skip initializations in
2634 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2635 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2636 * tdls_init when the change_iface sets the device mode to
2637 * WLAN_HDD_P2P_CLIENT.
2638 */
2639
2640 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2641 {
2642 if (0 != wlan_hdd_tdls_init (pAdapter))
2643 {
2644 return -EINVAL;
2645 }
2646 }
2647#endif
2648
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 break;
2650 case NL80211_IFTYPE_ADHOC:
2651 hddLog(VOS_TRACE_LEVEL_INFO,
2652 "%s: setting interface Type to ADHOC", __func__);
2653 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2654 pRoamProfile->phyMode =
2655 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002656 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 wdev->iftype = type;
2658 break;
2659
2660 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 {
2663 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2664 "%s: setting interface Type to %s", __func__,
2665 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2666
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002667 //Cancel any remain on channel for GO mode
2668 if (NL80211_IFTYPE_P2P_GO == type)
2669 {
2670 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2671 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002672 if (NL80211_IFTYPE_AP == type)
2673 {
2674 /* As Loading WLAN Driver one interface being created for p2p device
2675 * address. This will take one HW STA and the max number of clients
2676 * that can connect to softAP will be reduced by one. so while changing
2677 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2678 * interface as it is not required in SoftAP mode.
2679 */
2680
2681 // Get P2P Adapter
2682 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2683
2684 if (pP2pAdapter)
2685 {
2686 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2687 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2688 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2689 }
2690 }
2691
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 //De-init the adapter.
2693 hdd_stop_adapter( pHddCtx, pAdapter );
2694 hdd_deinit_adapter( pHddCtx, pAdapter );
2695 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2697 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002698
2699 //Disable BMPS and IMPS if enabled
2700 //before starting Go
2701 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2702 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302703 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002704 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2705 {
2706 //Fail to Exit BMPS
2707 VOS_ASSERT(0);
2708 }
2709 }
2710
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002711 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2712 (pConfig->apRandomBssidEnabled))
2713 {
2714 /* To meet Android requirements create a randomized
2715 MAC address of the form 02:1A:11:Fx:xx:xx */
2716 get_random_bytes(&ndev->dev_addr[3], 3);
2717 ndev->dev_addr[0] = 0x02;
2718 ndev->dev_addr[1] = 0x1A;
2719 ndev->dev_addr[2] = 0x11;
2720 ndev->dev_addr[3] |= 0xF0;
2721 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2722 VOS_MAC_ADDR_SIZE);
2723 pr_info("wlan: Generated HotSpot BSSID "
2724 "%02x:%02x:%02x:%02x:%02x:%02x\n",
2725 ndev->dev_addr[0],
2726 ndev->dev_addr[1],
2727 ndev->dev_addr[2],
2728 ndev->dev_addr[3],
2729 ndev->dev_addr[4],
2730 ndev->dev_addr[5]);
2731 }
2732
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 hdd_set_ap_ops( pAdapter->dev );
2734
2735 status = hdd_init_ap_mode(pAdapter);
2736 if(status != VOS_STATUS_SUCCESS)
2737 {
2738 hddLog(VOS_TRACE_LEVEL_FATAL,
2739 "%s: Error initializing the ap mode", __func__);
2740 return -EINVAL;
2741 }
2742 hdd_set_conparam(1);
2743
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 /*interface type changed update in wiphy structure*/
2745 if(wdev)
2746 {
2747 wdev->iftype = type;
2748 pHddCtx->change_iface = type;
2749 }
2750 else
2751 {
2752 hddLog(VOS_TRACE_LEVEL_ERROR,
2753 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2754 return -EINVAL;
2755 }
2756 goto done;
2757 }
2758
2759 default:
2760 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2761 __func__);
2762 return -EOPNOTSUPP;
2763 }
2764 }
2765 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 )
2768 {
2769 switch(type)
2770 {
2771 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 case NL80211_IFTYPE_ADHOC:
Jeff Johnson32d95a32012-09-10 13:15:23 -07002774 hdd_stop_adapter( pHddCtx, pAdapter );
2775 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002777 //Check for sub-string p2p to confirm its a p2p interface
2778 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002779 {
2780 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2781 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2782 }
2783 else
2784 {
2785 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 hdd_set_conparam(0);
2789 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2791 hdd_set_station_ops( pAdapter->dev );
2792 status = hdd_init_station_mode( pAdapter );
2793 if( VOS_STATUS_SUCCESS != status )
2794 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002795 /* In case of JB, for P2P-GO, only change interface will be called,
2796 * This is the right place to enable back bmps_imps()
2797 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302798 if (pHddCtx->hdd_wlan_suspended)
2799 {
2800 hdd_set_pwrparams(pHddCtx);
2801 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002802 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 goto done;
2804 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2808 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 goto done;
2810 default:
2811 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2812 __func__);
2813 return -EOPNOTSUPP;
2814
2815 }
2816
2817 }
2818 else
2819 {
2820 return -EOPNOTSUPP;
2821 }
2822
2823
2824 if(pRoamProfile)
2825 {
2826 if ( LastBSSType != pRoamProfile->BSSType )
2827 {
2828 /*interface type changed update in wiphy structure*/
2829 wdev->iftype = type;
2830
2831 /*the BSS mode changed, We need to issue disconnect
2832 if connected or in IBSS disconnect state*/
2833 if ( hdd_connGetConnectedBssType(
2834 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2835 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2836 {
2837 /*need to issue a disconnect to CSR.*/
2838 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2839 if( eHAL_STATUS_SUCCESS ==
2840 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2841 pAdapter->sessionId,
2842 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2843 {
2844 wait_for_completion_interruptible_timeout(
2845 &pAdapter->disconnect_comp_var,
2846 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2847 }
2848 }
2849 }
2850 }
2851
2852done:
2853 /*set bitmask based on updated value*/
2854 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002855
2856 /* Only STA mode support TM now
2857 * all other mode, TM feature should be disabled */
2858 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2859 (~VOS_STA & pHddCtx->concurrency_mode) )
2860 {
2861 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2862 }
2863
Jeff Johnson295189b2012-06-20 16:38:30 -07002864#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302865 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2867 {
2868 //we are ok to do AMP
2869 pHddCtx->isAmpAllowed = VOS_TRUE;
2870 }
2871#endif //WLAN_BTAMP_FEATURE
2872 EXIT();
2873 return 0;
2874}
2875
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002876#ifdef FEATURE_WLAN_TDLS
2877static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2878 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2879{
2880 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2881 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2882 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002883 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002884
2885 ENTER();
2886
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302887 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002888 {
2889 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2890 "Invalid arguments");
2891 return -EINVAL;
2892 }
Hoonki Lee27511902013-03-14 18:19:06 -07002893
2894 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
2895 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
2896 {
2897 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2898 "%s: TDLS mode is disabled OR not enabled in FW."
2899 MAC_ADDRESS_STR " Request declined.",
2900 __func__, MAC_ADDR_ARRAY(mac));
2901 return -ENOTSUPP;
2902 }
2903
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002904 if (pHddCtx->isLogpInProgress)
2905 {
2906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2907 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07002908 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002909 return -EBUSY;
2910 }
2911
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002912 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac);
2913
2914 if ( NULL == pTdlsPeer ) {
2915 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2916 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
2917 __func__, MAC_ADDR_ARRAY(mac), update);
2918 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002919 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002920
2921 /* in add station, we accept existing valid staId if there is */
2922 if ((0 == update) &&
2923 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
2924 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002925 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002926 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002927 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002928 " link_status %d. staId %d. add station ignored.",
2929 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
2930 return 0;
2931 }
2932 /* in change station, we accept only when staId is valid */
2933 if ((1 == update) &&
2934 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
2935 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
2936 {
2937 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2938 "%s: " MAC_ADDRESS_STR
2939 " link status %d. staId %d. change station %s.",
2940 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
2941 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
2942 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002943 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002944
2945 /* when others are on-going, we want to change link_status to idle */
Hoonki Leefb8df672013-04-10 18:20:34 -07002946 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002947 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002948 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2949 "%s: " MAC_ADDRESS_STR
2950 " TDLS setup is ongoing. Request declined.",
2951 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07002952 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002953 }
2954
2955 /* first to check if we reached to maximum supported TDLS peer.
2956 TODO: for now, return -EPERM looks working fine,
2957 but need to check if any other errno fit into this category.*/
2958 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
2959 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002960 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2961 "%s: " MAC_ADDRESS_STR
2962 " TDLS Max peer already connected. Request declined.",
2963 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07002964 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002965 }
2966 else
2967 {
2968 hddTdlsPeer_t *pTdlsPeer;
2969 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002970 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002971 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002972 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2973 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
2974 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002975 return -EPERM;
2976 }
2977 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002978 if (0 == update)
2979 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002980
Jeff Johnsond75fe012013-04-06 10:53:06 -07002981 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302982 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002983 {
2984 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2985 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07002986 if(StaParams->htcap_present)
2987 {
2988 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2989 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
2990 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2991 "ht_capa->extended_capabilities: %0x",
2992 StaParams->HTCap.extendedHtCapInfo);
2993 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002994 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2995 "params->capability: %0x",StaParams->capability);
2996 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2997 "params->ext_capab_len: %0x",StaParams->extn_capability);
Hoonki Lee66b75f32013-04-16 18:30:07 -07002998 if(StaParams->vhtcap_present)
2999 {
3000 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3001 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3002 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3003 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3004 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003005 {
3006 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003007 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003008 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3009 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3010 "[%d]: %x ", i, StaParams->supported_rates[i]);
3011 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003012 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303013 else if ((1 == update) && (NULL == StaParams))
3014 {
3015 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3016 "%s : update is true, but staParams is NULL. Error!", __func__);
3017 return -EPERM;
3018 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003019
3020 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3021
3022 if (!update)
3023 {
3024 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3025 pAdapter->sessionId, mac);
3026 }
3027 else
3028 {
3029 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3030 pAdapter->sessionId, mac, StaParams);
3031 }
3032
3033 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
3034 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3035
3036 if (!status)
3037 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003039 "%s: timeout waiting for tdls add station indication",
3040 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003041 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003042 }
3043 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
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: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003047 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003048 }
3049
3050 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003051
3052error:
3053 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3054 return -EPERM;
3055
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003056}
3057#endif
3058
Jeff Johnson295189b2012-06-20 16:38:30 -07003059static int wlan_hdd_change_station(struct wiphy *wiphy,
3060 struct net_device *dev,
3061 u8 *mac,
3062 struct station_parameters *params)
3063{
3064 VOS_STATUS status = VOS_STATUS_SUCCESS;
3065 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303066 hdd_context_t *pHddCtx;
3067 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003069#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003070 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003071 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003072#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003073 ENTER();
3074
Gopichand Nakkala29149562013-05-10 21:43:41 +05303075 if ((NULL == pAdapter))
3076 {
3077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3078 "invalid adapter ");
3079 return -EINVAL;
3080 }
3081
3082 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3083 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3084
3085 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3086 {
3087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3088 "invalid HDD state or HDD station context");
3089 return -EINVAL;
3090 }
3091
3092 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003093 {
3094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3095 "%s:LOGP in Progress. Ignore!!!", __func__);
3096 return -EAGAIN;
3097 }
3098
Jeff Johnson295189b2012-06-20 16:38:30 -07003099 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3100
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003101 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3102 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003104 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303106 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003107 WLANTL_STA_AUTHENTICATED);
3108
Gopichand Nakkala29149562013-05-10 21:43:41 +05303109 if (status != VOS_STATUS_SUCCESS)
3110 {
3111 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3112 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3113 return -EINVAL;
3114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 }
3116 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003117 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3118 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303119#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003120 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3121 StaParams.capability = params->capability;
3122 StaParams.uapsd_queues = params->uapsd_queues;
3123 StaParams.max_sp = params->max_sp;
3124
3125 if (0 != params->ext_capab_len)
3126 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3127 sizeof(StaParams.extn_capability));
3128
3129 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003130 {
3131 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003132 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003133 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003134
3135 StaParams.supported_rates_len = params->supported_rates_len;
3136
3137 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3138 * The supported_rates array , for all the structures propogating till Add Sta
3139 * to the firmware has to be modified , if the supplicant (ieee80211) is
3140 * modified to send more rates.
3141 */
3142
3143 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3144 */
3145 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3146 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3147
3148 if (0 != StaParams.supported_rates_len) {
3149 int i = 0;
3150 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3151 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003152 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003153 "Supported Rates with Length %d", StaParams.supported_rates_len);
3154 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003155 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003156 "[%d]: %0x", i, StaParams.supported_rates[i]);
3157 }
3158
3159 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003160 {
3161 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003162 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003163 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003164
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003165 if (0 != params->ext_capab_len ) {
3166 /*Define A Macro : TODO Sunil*/
3167 if ((1<<4) & StaParams.extn_capability[3]) {
3168 isBufSta = 1;
3169 }
3170 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303171 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3172 params->max_sp, isBufSta);
3173 if (VOS_STATUS_SUCCESS != status) {
3174 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3175 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3176 return -EINVAL;
3177 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003178 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3179
3180 if (VOS_STATUS_SUCCESS != status) {
3181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3182 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3183 return -EINVAL;
3184 }
3185 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003186#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303187 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003188 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 return status;
3190}
3191
3192/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 * FUNCTION: wlan_hdd_cfg80211_add_key
3194 * This function is used to initialize the key information
3195 */
3196#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003197static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 struct net_device *ndev,
3199 u8 key_index, bool pairwise,
3200 const u8 *mac_addr,
3201 struct key_params *params
3202 )
3203#else
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, const u8 *mac_addr,
3207 struct key_params *params
3208 )
3209#endif
3210{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003211 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 tCsrRoamSetKey setKey;
3213 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303214 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003215 v_U32_t roamId= 0xFF;
3216 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 hdd_hostapd_state_t *pHostapdState;
3218 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003219 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303220 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003221
3222 ENTER();
3223
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303224 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3225 status = wlan_hdd_validate_context(pHddCtx);
3226
3227 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003228 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303229 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3230 "%s: HDD context is not valid", __func__);
3231 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003232 }
3233
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003234 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3235 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003236
3237 if (CSR_MAX_NUM_KEY <= key_index)
3238 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003239 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 key_index);
3241
3242 return -EINVAL;
3243 }
3244
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003245 if (CSR_MAX_KEY_LEN < params->key_len)
3246 {
3247 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3248 params->key_len);
3249
3250 return -EINVAL;
3251 }
3252
3253 hddLog(VOS_TRACE_LEVEL_INFO,
3254 "%s: called with key index = %d & key length %d",
3255 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003256
3257 /*extract key idx, key len and key*/
3258 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3259 setKey.keyId = key_index;
3260 setKey.keyLength = params->key_len;
3261 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3262
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003263 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 {
3265 case WLAN_CIPHER_SUITE_WEP40:
3266 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3267 break;
3268
3269 case WLAN_CIPHER_SUITE_WEP104:
3270 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3271 break;
3272
3273 case WLAN_CIPHER_SUITE_TKIP:
3274 {
3275 u8 *pKey = &setKey.Key[0];
3276 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3277
3278 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3279
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003280 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003281
3282 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003283 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 |--------------|----------|----------|
3285 <---16bytes---><--8bytes--><--8bytes-->
3286
3287 */
3288 /*Sme expects the 32 bytes key to be in the below order
3289
3290 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003291 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 |--------------|----------|----------|
3293 <---16bytes---><--8bytes--><--8bytes-->
3294 */
3295 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003296 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003297
3298 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003299 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003300
3301 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003302 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003303
3304
3305 break;
3306 }
3307
3308 case WLAN_CIPHER_SUITE_CCMP:
3309 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3310 break;
3311
3312#ifdef FEATURE_WLAN_WAPI
3313 case WLAN_CIPHER_SUITE_SMS4:
3314 {
3315 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3316 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3317 params->key, params->key_len);
3318 return 0;
3319 }
3320#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003321
Jeff Johnson295189b2012-06-20 16:38:30 -07003322#ifdef FEATURE_WLAN_CCX
3323 case WLAN_CIPHER_SUITE_KRK:
3324 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3325 break;
3326#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003327
3328#ifdef WLAN_FEATURE_11W
3329 case WLAN_CIPHER_SUITE_AES_CMAC:
3330 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003331 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003332#endif
3333
Jeff Johnson295189b2012-06-20 16:38:30 -07003334 default:
3335 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu",
3336 __func__, params->cipher);
3337 return -EOPNOTSUPP;
3338 }
3339
3340 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3341 __func__, setKey.encType);
3342
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003343 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003344#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3345 (!pairwise)
3346#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003347 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003348#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003349 )
3350 {
3351 /* set group key*/
3352 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3353 "%s- %d: setting Broadcast key",
3354 __func__, __LINE__);
3355 setKey.keyDirection = eSIR_RX_ONLY;
3356 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3357 }
3358 else
3359 {
3360 /* set pairwise key*/
3361 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3362 "%s- %d: setting pairwise key",
3363 __func__, __LINE__);
3364 setKey.keyDirection = eSIR_TX_RX;
3365 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3366 }
3367 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3368 {
3369 setKey.keyDirection = eSIR_TX_RX;
3370 /*Set the group key*/
3371 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3372 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003373
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003374 if ( 0 != status )
3375 {
3376 hddLog(VOS_TRACE_LEVEL_ERROR,
3377 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3378 return -EINVAL;
3379 }
3380 /*Save the keys here and call sme_RoamSetKey for setting
3381 the PTK after peer joins the IBSS network*/
3382 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3383 &setKey, sizeof(tCsrRoamSetKey));
3384 return status;
3385 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303386 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3387 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3388 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003390 if( pHostapdState->bssState == BSS_START )
3391 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3393
3394 if ( status != eHAL_STATUS_SUCCESS )
3395 {
3396 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3397 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3398 __LINE__, status );
3399 }
3400 }
3401
3402 /* Saving WEP keys */
3403 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3404 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3405 {
3406 //Save the wep key in ap context. Issue setkey after the BSS is started.
3407 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3408 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3409 }
3410 else
3411 {
3412 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003413 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3415 }
3416 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003417 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3418 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 {
3420 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3421 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3422
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303423#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3424 if (!pairwise)
3425#else
3426 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3427#endif
3428 {
3429 /* set group key*/
3430 if (pHddStaCtx->roam_info.deferKeyComplete)
3431 {
3432 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3433 "%s- %d: Perform Set key Complete",
3434 __func__, __LINE__);
3435 hdd_PerformRoamSetKeyComplete(pAdapter);
3436 }
3437 }
3438
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3440
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003441 pWextState->roamProfile.Keys.defaultIndex = key_index;
3442
3443
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003444 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 params->key, params->key_len);
3446
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303447
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3449
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303450 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303452 __func__, setKey.peerMac[0], setKey.peerMac[1],
3453 setKey.peerMac[2], setKey.peerMac[3],
3454 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 setKey.keyDirection);
3456
3457 vos_status = wlan_hdd_check_ula_done(pAdapter);
3458
3459 if ( vos_status != VOS_STATUS_SUCCESS )
3460 {
3461 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3462 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3463 __LINE__, vos_status );
3464
3465 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3466
3467 return -EINVAL;
3468
3469 }
3470
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003471#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303472 /* The supplicant may attempt to set the PTK once pre-authentication
3473 is done. Save the key in the UMAC and include it in the ADD BSS
3474 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003475 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303476 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003477 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303478 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3479 "%s: Update PreAuth Key success", __func__);
3480 return 0;
3481 }
3482 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3483 {
3484 hddLog(VOS_TRACE_LEVEL_ERROR,
3485 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303486 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003487 }
3488#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003489
3490 /* issue set key request to SME*/
3491 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3492 pAdapter->sessionId, &setKey, &roamId );
3493
3494 if ( 0 != status )
3495 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303496 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3498 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3499 return -EINVAL;
3500 }
3501
3502
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303503 /* in case of IBSS as there was no information available about WEP keys during
3504 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303506 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3507 !( ( IW_AUTH_KEY_MGMT_802_1X
3508 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3510 )
3511 &&
3512 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3513 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3514 )
3515 )
3516 {
3517 setKey.keyDirection = eSIR_RX_ONLY;
3518 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3519
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303520 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303522 __func__, setKey.peerMac[0], setKey.peerMac[1],
3523 setKey.peerMac[2], setKey.peerMac[3],
3524 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003525 setKey.keyDirection);
3526
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303527 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 pAdapter->sessionId, &setKey, &roamId );
3529
3530 if ( 0 != status )
3531 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303532 hddLog(VOS_TRACE_LEVEL_ERROR,
3533 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 __func__, status);
3535 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3536 return -EINVAL;
3537 }
3538 }
3539 }
3540
3541 return 0;
3542}
3543
3544/*
3545 * FUNCTION: wlan_hdd_cfg80211_get_key
3546 * This function is used to get the key information
3547 */
3548#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303549static int wlan_hdd_cfg80211_get_key(
3550 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303552 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 const u8 *mac_addr, void *cookie,
3554 void (*callback)(void *cookie, struct key_params*)
3555 )
3556#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303557static int wlan_hdd_cfg80211_get_key(
3558 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003559 struct net_device *ndev,
3560 u8 key_index, const u8 *mac_addr, void *cookie,
3561 void (*callback)(void *cookie, struct key_params*)
3562 )
3563#endif
3564{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303565 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3567 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3568 struct key_params params;
3569
3570 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303571
Jeff Johnson295189b2012-06-20 16:38:30 -07003572 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3573 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303574
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 memset(&params, 0, sizeof(params));
3576
3577 if (CSR_MAX_NUM_KEY <= key_index)
3578 {
3579 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003581
3582 switch(pRoamProfile->EncryptionType.encryptionType[0])
3583 {
3584 case eCSR_ENCRYPT_TYPE_NONE:
3585 params.cipher = IW_AUTH_CIPHER_NONE;
3586 break;
3587
3588 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3589 case eCSR_ENCRYPT_TYPE_WEP40:
3590 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3591 break;
3592
3593 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3594 case eCSR_ENCRYPT_TYPE_WEP104:
3595 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3596 break;
3597
3598 case eCSR_ENCRYPT_TYPE_TKIP:
3599 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3600 break;
3601
3602 case eCSR_ENCRYPT_TYPE_AES:
3603 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3604 break;
3605
3606 default:
3607 params.cipher = IW_AUTH_CIPHER_NONE;
3608 break;
3609 }
3610
3611 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3612 params.seq_len = 0;
3613 params.seq = NULL;
3614 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3615 callback(cookie, &params);
3616 return 0;
3617}
3618
3619/*
3620 * FUNCTION: wlan_hdd_cfg80211_del_key
3621 * This function is used to delete the key information
3622 */
3623#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303624static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303626 u8 key_index,
3627 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 const u8 *mac_addr
3629 )
3630#else
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,
3633 u8 key_index,
3634 const u8 *mac_addr
3635 )
3636#endif
3637{
3638 int status = 0;
3639
3640 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303641 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 //it is observed that this is invalidating peer
3643 //key index whenever re-key is done. This is affecting data link.
3644 //It should be ok to ignore del_key.
3645#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303646 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3647 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3649 tCsrRoamSetKey setKey;
3650 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303651
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 ENTER();
3653
3654 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3655 __func__,pAdapter->device_mode);
3656
3657 if (CSR_MAX_NUM_KEY <= key_index)
3658 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303659 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 key_index);
3661
3662 return -EINVAL;
3663 }
3664
3665 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3666 setKey.keyId = key_index;
3667
3668 if (mac_addr)
3669 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3670 else
3671 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3672
3673 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3674
3675 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303677 )
3678 {
3679
3680 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3682 if( pHostapdState->bssState == BSS_START)
3683 {
3684 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303685
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 if ( status != eHAL_STATUS_SUCCESS )
3687 {
3688 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3689 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3690 __LINE__, status );
3691 }
3692 }
3693 }
3694 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303695 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 )
3697 {
3698 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3699
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303700 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3701
3702 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303704 __func__, setKey.peerMac[0], setKey.peerMac[1],
3705 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303707 if(pAdapter->sessionCtx.station.conn_info.connState ==
3708 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303710 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303712
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 if ( 0 != status )
3714 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303715 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 "%s: sme_RoamSetKey failure, returned %d",
3717 __func__, status);
3718 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3719 return -EINVAL;
3720 }
3721 }
3722 }
3723#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003724 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 return status;
3726}
3727
3728/*
3729 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3730 * This function is used to set the default tx key index
3731 */
3732#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3733static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3734 struct net_device *ndev,
3735 u8 key_index,
3736 bool unicast, bool multicast)
3737#else
3738static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3739 struct net_device *ndev,
3740 u8 key_index)
3741#endif
3742{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303743 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303744 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303745 hdd_wext_state_t *pWextState;
3746 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303747 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003748
3749 ENTER();
3750
Gopichand Nakkala29149562013-05-10 21:43:41 +05303751 if ((NULL == pAdapter))
3752 {
3753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3754 "invalid adapter");
3755 return -EINVAL;
3756 }
3757
3758 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3759 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3760
3761 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3762 {
3763 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3764 "invalid Wext state or HDD context");
3765 return -EINVAL;
3766 }
3767
Jeff Johnson295189b2012-06-20 16:38:30 -07003768 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3769 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303770
Jeff Johnson295189b2012-06-20 16:38:30 -07003771 if (CSR_MAX_NUM_KEY <= key_index)
3772 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303773 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 key_index);
3775
3776 return -EINVAL;
3777 }
3778
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303779 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3780 status = wlan_hdd_validate_context(pHddCtx);
3781
3782 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003783 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303784 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3785 "%s: HDD context is not valid", __func__);
3786 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003787 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303788
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303791 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303793 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303795 (eCSR_ENCRYPT_TYPE_AES !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 pWextState->roamProfile.EncryptionType.encryptionType[0])
3797 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303798 {
3799 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303801
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 tCsrRoamSetKey setKey;
3803 v_U32_t roamId= 0xFF;
3804 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303805
3806 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003807 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303808
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 Keys->defaultIndex = (u8)key_index;
3810 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3811 setKey.keyId = key_index;
3812 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303813
3814 vos_mem_copy(&setKey.Key[0],
3815 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303817
Gopichand Nakkala29149562013-05-10 21:43:41 +05303818 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303819
3820 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 &pHddStaCtx->conn_info.bssId[0],
3822 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303823
Gopichand Nakkala29149562013-05-10 21:43:41 +05303824 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3825 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3826 eCSR_ENCRYPT_TYPE_WEP104)
3827 {
3828 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3829 even though ap is configured for WEP-40 encryption. In this canse the key length
3830 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3831 type(104) and switching encryption type to 40*/
3832 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3833 eCSR_ENCRYPT_TYPE_WEP40;
3834 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3835 eCSR_ENCRYPT_TYPE_WEP40;
3836 }
3837
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303838 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303840
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303842 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303844
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 if ( 0 != status )
3846 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303847 hddLog(VOS_TRACE_LEVEL_ERROR,
3848 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003849 status);
3850 return -EINVAL;
3851 }
3852 }
3853 }
3854
3855 /* In SoftAp mode setting key direction for default mode */
3856 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3857 {
3858 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3859 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3860 (eCSR_ENCRYPT_TYPE_AES !=
3861 pWextState->roamProfile.EncryptionType.encryptionType[0])
3862 )
3863 {
3864 /* Saving key direction for default key index to TX default */
3865 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3866 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3867 }
3868 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303869
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 return status;
3871}
3872
Jeff Johnson295189b2012-06-20 16:38:30 -07003873/*
3874 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3875 * This function is used to inform the BSS details to nl80211 interface.
3876 */
3877static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3878 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3879{
3880 struct net_device *dev = pAdapter->dev;
3881 struct wireless_dev *wdev = dev->ieee80211_ptr;
3882 struct wiphy *wiphy = wdev->wiphy;
3883 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3884 int chan_no;
3885 int ie_length;
3886 const char *ie;
3887 unsigned int freq;
3888 struct ieee80211_channel *chan;
3889 int rssi = 0;
3890 struct cfg80211_bss *bss = NULL;
3891
3892 ENTER();
3893
3894 if( NULL == pBssDesc )
3895 {
3896 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
3897 return bss;
3898 }
3899
3900 chan_no = pBssDesc->channelId;
3901 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
3902 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
3903
3904 if( NULL == ie )
3905 {
3906 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
3907 return bss;
3908 }
3909
3910#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
3911 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
3912 {
3913 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
3914 }
3915 else
3916 {
3917 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
3918 }
3919#else
3920 freq = ieee80211_channel_to_frequency(chan_no);
3921#endif
3922
3923 chan = __ieee80211_get_channel(wiphy, freq);
3924
3925 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
3926 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
3927 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
3928 if (bss == NULL)
3929 {
3930 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
3931
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303932 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
3933 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 pBssDesc->capabilityInfo,
3935 pBssDesc->beaconInterval, ie, ie_length,
3936 rssi, GFP_KERNEL ));
3937}
3938 else
3939 {
3940 return bss;
3941 }
3942}
3943
3944
3945
3946/*
3947 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
3948 * This function is used to inform the BSS details to nl80211 interface.
3949 */
3950struct cfg80211_bss*
3951wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
3952 tSirBssDescription *bss_desc
3953 )
3954{
3955 /*
3956 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
3957 already exists in bss data base of cfg80211 for that particular BSS ID.
3958 Using cfg80211_inform_bss_frame to update the bss entry instead of
3959 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
3960 now there is no possibility to get the mgmt(probe response) frame from PE,
3961 converting bss_desc to ieee80211_mgmt(probe response) and passing to
3962 cfg80211_inform_bss_frame.
3963 */
3964 struct net_device *dev = pAdapter->dev;
3965 struct wireless_dev *wdev = dev->ieee80211_ptr;
3966 struct wiphy *wiphy = wdev->wiphy;
3967 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08003968#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
3969 qcom_ie_age *qie_age = NULL;
3970 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
3971#else
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08003973#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 const char *ie =
3975 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
3976 unsigned int freq;
3977 struct ieee80211_channel *chan;
3978 struct ieee80211_mgmt *mgmt =
3979 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
3980 struct cfg80211_bss *bss_status = NULL;
3981 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
3982 int rssi = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07003983#ifdef WLAN_OPEN_SOURCE
3984 struct timespec ts;
3985#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003986
3987 ENTER();
3988
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07003989 if (!mgmt)
3990 return NULL;
3991
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07003993
3994#ifdef WLAN_OPEN_SOURCE
3995 /* Android does not want the timestamp from the frame.
3996 Instead it wants a monotonic increasing value */
3997 get_monotonic_boottime(&ts);
3998 mgmt->u.probe_resp.timestamp =
3999 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4000#else
4001 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4003 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004004
4005#endif
4006
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4008 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004009
4010#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4011 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4012 /* Assuming this is the last IE, copy at the end */
4013 ie_length -=sizeof(qcom_ie_age);
4014 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4015 qie_age->element_id = QCOM_VENDOR_IE_ID;
4016 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4017 qie_age->oui_1 = QCOM_OUI1;
4018 qie_age->oui_2 = QCOM_OUI2;
4019 qie_age->oui_3 = QCOM_OUI3;
4020 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4021 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4022#endif
4023
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304025 if (bss_desc->fProbeRsp)
4026 {
4027 mgmt->frame_control |=
4028 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4029 }
4030 else
4031 {
4032 mgmt->frame_control |=
4033 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004035
4036#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304037 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4039 {
4040 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4041 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304042 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4044
4045 {
4046 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4047 }
4048 else
4049 {
4050 kfree(mgmt);
4051 return NULL;
4052 }
4053#else
4054 freq = ieee80211_channel_to_frequency(chan_no);
4055#endif
4056 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004057 /*when the band is changed on the fly using the GUI, three things are done
4058 * 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)
4059 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4060 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4061 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4062 * and discards the channels correponding to previous band and calls back with zero bss results.
4063 * 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
4064 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4065 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4066 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4067 * So drop the bss and continue to next bss.
4068 */
4069 if(chan == NULL)
4070 {
4071 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004072 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004073 return NULL;
4074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304076 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 * */
4078 if (( eConnectionState_Associated ==
4079 pAdapter->sessionCtx.station.conn_info.connState ) &&
4080 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4081 pAdapter->sessionCtx.station.conn_info.bssId,
4082 WNI_CFG_BSSID_LEN)))
4083 {
4084 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4085 rssi = (pAdapter->rssi * 100);
4086 }
4087 else
4088 {
4089 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4090 }
4091
4092 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4093 frame_len, rssi, GFP_KERNEL);
4094 kfree(mgmt);
4095 return bss_status;
4096}
4097
4098/*
4099 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4100 * This function is used to update the BSS data base of CFG8011
4101 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304102struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 tCsrRoamInfo *pRoamInfo
4104 )
4105{
4106 tCsrRoamConnectedProfile roamProfile;
4107 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4108 struct cfg80211_bss *bss = NULL;
4109
4110 ENTER();
4111
4112 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4113 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4114
4115 if (NULL != roamProfile.pBssDesc)
4116 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304117 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004118 &roamProfile);
4119
4120 if (NULL == bss)
4121 {
4122 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4123 __func__);
4124 }
4125
4126 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4127 }
4128 else
4129 {
4130 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4131 __func__);
4132 }
4133 return bss;
4134}
4135
4136/*
4137 * FUNCTION: wlan_hdd_cfg80211_update_bss
4138 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304139static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4140 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304142{
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4144 tCsrScanResultInfo *pScanResult;
4145 eHalStatus status = 0;
4146 tScanResultHandle pResult;
4147 struct cfg80211_bss *bss_status = NULL;
4148
4149 ENTER();
4150
4151 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4152 {
4153 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
4154 return -EAGAIN;
4155 }
4156
4157 /*
4158 * start getting scan results and populate cgf80211 BSS database
4159 */
4160 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4161
4162 /* no scan results */
4163 if (NULL == pResult)
4164 {
4165 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4166 return status;
4167 }
4168
4169 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4170
4171 while (pScanResult)
4172 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304173 /*
4174 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4175 * entry already exists in bss data base of cfg80211 for that
4176 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4177 * bss entry instead of cfg80211_inform_bss, But this call expects
4178 * mgmt packet as input. As of now there is no possibility to get
4179 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 * ieee80211_mgmt(probe response) and passing to c
4181 * fg80211_inform_bss_frame.
4182 * */
4183
4184 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4185 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304186
Jeff Johnson295189b2012-06-20 16:38:30 -07004187
4188 if (NULL == bss_status)
4189 {
4190 hddLog(VOS_TRACE_LEVEL_INFO,
4191 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4192 }
4193 else
4194 {
Yue Maf49ba872013-08-19 12:04:25 -07004195 cfg80211_put_bss(
4196#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4197 wiphy,
4198#endif
4199 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 }
4201
4202 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4203 }
4204
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304205 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004206
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304207 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004208}
4209
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004210void
4211hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4212{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304213 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004214 "%02X:%02X:%02X:%02X:%02X:%02X\n",
4215 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
4216 macAddr[5]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004217} /****** end hddPrintMacAddr() ******/
4218
4219void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004220hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004221{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304222 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004223 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4224 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4225 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4226 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004227} /****** end hddPrintPmkId() ******/
4228
4229//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4230//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4231
4232//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4233//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4234
4235#define dump_bssid(bssid) \
4236 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004237 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4238 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4239 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004240 }
4241
4242#define dump_pmkid(pMac, pmkid) \
4243 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004244 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4245 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4246 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004247 }
4248
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004249#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004250/*
4251 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4252 * This function is used to notify the supplicant of a new PMKSA candidate.
4253 */
4254int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304255 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004256 int index, bool preauth )
4257{
Jeff Johnsone7245742012-09-05 17:12:55 -07004258#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004259 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004260 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004261
4262 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004263 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004264
4265 if( NULL == pRoamInfo )
4266 {
4267 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4268 return -EINVAL;
4269 }
4270
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004271 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4272 {
4273 dump_bssid(pRoamInfo->bssid);
4274 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004275 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004276 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004277#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304278 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004279}
4280#endif //FEATURE_WLAN_LFR
4281
Jeff Johnson295189b2012-06-20 16:38:30 -07004282/*
4283 * FUNCTION: hdd_cfg80211_scan_done_callback
4284 * scanning callback function, called after finishing scan
4285 *
4286 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304287static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4289{
4290 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304291 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004293 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4294 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 struct cfg80211_scan_request *req = NULL;
4296 int ret = 0;
4297
4298 ENTER();
4299
4300 hddLog(VOS_TRACE_LEVEL_INFO,
4301 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304302 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 __func__, halHandle, pContext, (int) scanId, (int) status);
4304
4305 //Block on scan req completion variable. Can't wait forever though.
4306 ret = wait_for_completion_interruptible_timeout(
4307 &pScanInfo->scan_req_completion_event,
4308 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4309 if (!ret)
4310 {
4311 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004312 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 }
4314
4315 if(pScanInfo->mScanPending != VOS_TRUE)
4316 {
4317 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004318 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 }
4320
4321 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304322 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 {
4324 hddLog(VOS_TRACE_LEVEL_INFO,
4325 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304326 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004327 (int) scanId);
4328 }
4329
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304330 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 pAdapter);
4332
4333 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304334 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004335
4336
4337 /* If any client wait scan result through WEXT
4338 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004339 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 {
4341 /* The other scan request waiting for current scan finish
4342 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004343 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004345 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 }
4347 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004348 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004349 {
4350 struct net_device *dev = pAdapter->dev;
4351 union iwreq_data wrqu;
4352 int we_event;
4353 char *msg;
4354
4355 memset(&wrqu, '\0', sizeof(wrqu));
4356 we_event = SIOCGIWSCAN;
4357 msg = NULL;
4358 wireless_send_event(dev, we_event, &wrqu, msg);
4359 }
4360 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004361 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004362
4363 /* Get the Scan Req */
4364 req = pAdapter->request;
4365
4366 if (!req)
4367 {
4368 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004369 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004370 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 }
4372
4373 /*
4374 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304375 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 req->n_ssids = 0;
4377 req->n_channels = 0;
4378 req->ie = 0;
4379
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004381 /* Scan is no longer pending */
4382 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004383
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004384 /*
4385 * cfg80211_scan_done informing NL80211 about completion
4386 * of scanning
4387 */
4388 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004389 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004390
Jeff Johnsone7245742012-09-05 17:12:55 -07004391allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004392 /* release the wake lock at the end of the scan*/
4393 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004394
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004395 /* Acquire wakelock to handle the case where APP's tries to suspend
4396 * immediatly after the driver gets connect request(i.e after scan)
4397 * from supplicant, this result in app's is suspending and not able
4398 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004399 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004400
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004401#ifdef FEATURE_WLAN_TDLS
4402 wlan_hdd_tdls_scan_done_callback(pAdapter);
4403#endif
4404
Jeff Johnson295189b2012-06-20 16:38:30 -07004405 EXIT();
4406 return 0;
4407}
4408
4409/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004410 * FUNCTION: hdd_isScanAllowed
4411 * Go through each adapter and check if scan allowed
4412 *
4413 */
4414v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4415{
4416 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4417 hdd_station_ctx_t *pHddStaCtx = NULL;
4418 hdd_adapter_t *pAdapter = NULL;
4419 VOS_STATUS status = 0;
4420 v_U8_t staId = 0;
4421 v_U8_t *staMac = NULL;
4422
4423 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4424
4425 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4426 {
4427 pAdapter = pAdapterNode->pAdapter;
4428
4429 if( pAdapter )
4430 {
4431 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304432 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004433 __func__, pAdapter->device_mode);
4434 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4435 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4436 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4437 {
4438 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4439 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4440 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4441 {
4442 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4443 hddLog(VOS_TRACE_LEVEL_ERROR,
4444 "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304445 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004446 staMac[0], staMac[1], staMac[2],
4447 staMac[3], staMac[4], staMac[5]);
4448 return VOS_FALSE;
4449 }
4450 }
4451 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4452 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4453 {
4454 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4455 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304456 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004457 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4458 {
4459 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4460
4461 hddLog(VOS_TRACE_LEVEL_ERROR,
4462 "%s: client %02x:%02x:%02x:%02x:%02x:%02x of SoftAP/P2P-GO is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304463 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004464 staMac[0], staMac[1], staMac[2],
4465 staMac[3], staMac[4], staMac[5]);
4466 return VOS_FALSE;
4467 }
4468 }
4469 }
4470 }
4471 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4472 pAdapterNode = pNext;
4473 }
4474 hddLog(VOS_TRACE_LEVEL_INFO,
4475 "%s: Scan allowed", __func__);
4476 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304477}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004478
4479/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 * FUNCTION: wlan_hdd_cfg80211_scan
4481 * this scan respond to scan trigger and update cfg80211 scan database
4482 * later, scan dump command can be used to recieve scan results
4483 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004484int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4485#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4486 struct net_device *dev,
4487#endif
4488 struct cfg80211_scan_request *request)
4489{
4490#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4491 struct net_device *dev = request->wdev->netdev;
4492#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304493 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4495 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304496 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 tCsrScanRequest scanRequest;
4498 tANI_U8 *channelList = NULL, i;
4499 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304500 int status;
4501 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004503
4504 ENTER();
4505
4506 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4507 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004508
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304509 status = wlan_hdd_validate_context(pHddCtx);
4510
4511 if (0 != status)
4512 {
4513 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4514 "%s: HDD context is not valid", __func__);
4515 return status;
4516 }
4517
4518 cfg_param = pHddCtx->cfg_ini;
4519 pScanInfo = &pHddCtx->scan_info;
4520
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004521 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004522 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004523 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004524 {
4525 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004526 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4527 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004528 return -EBUSY;
4529 }
4530
Jeff Johnson295189b2012-06-20 16:38:30 -07004531#ifdef WLAN_BTAMP_FEATURE
4532 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004533 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004535 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 "%s: No scanning when AMP is on", __func__);
4537 return -EOPNOTSUPP;
4538 }
4539#endif
4540 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004541 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004543 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 "%s: Not scanning on device_mode = %d",
4545 __func__, pAdapter->device_mode);
4546 return -EOPNOTSUPP;
4547 }
4548
4549 if (TRUE == pScanInfo->mScanPending)
4550 {
4551 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004552 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 }
4554
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304555 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004556 //Channel and action frame is pending
4557 //Otherwise Cancel Remain On Channel and allow Scan
4558 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004559 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004560 {
4561 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__);
4562 return -EBUSY;
4563 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004564#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004565 /* if tdls disagree scan right now, return immediately.
4566 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4567 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4568 */
4569 status = wlan_hdd_tdls_scan_callback (pAdapter,
4570 wiphy,
4571#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4572 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004573#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004574 request);
4575 if(status <= 0)
4576 {
4577 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4578 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004579 }
4580#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004581
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4583 {
4584 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004585 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4589 {
4590 hddLog(VOS_TRACE_LEVEL_WARN,
4591 "%s: MAX TM Level Scan not allowed", __func__);
4592 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304593 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 }
4595 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4596
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004597 /* Check if scan is allowed at this point of time.
4598 */
4599 if (!hdd_isScanAllowed(pHddCtx))
4600 {
4601 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4602 return -EBUSY;
4603 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304604
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4606
4607 if (NULL != request)
4608 {
4609 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304610 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004611
4612 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4613 * Becasue of this, driver is assuming that this is not wildcard scan and so
4614 * is not aging out the scan results.
4615 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004616 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 {
4618 request->n_ssids = 0;
4619 }
4620
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004621 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 {
4623 tCsrSSIDInfo *SsidInfo;
4624 int j;
4625 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4626 /* Allocate num_ssid tCsrSSIDInfo structure */
4627 SsidInfo = scanRequest.SSIDs.SSIDList =
4628 ( tCsrSSIDInfo *)vos_mem_malloc(
4629 request->n_ssids*sizeof(tCsrSSIDInfo));
4630
4631 if(NULL == scanRequest.SSIDs.SSIDList)
4632 {
4633 hddLog(VOS_TRACE_LEVEL_ERROR,
4634 "memory alloc failed SSIDInfo buffer");
4635 return -ENOMEM;
4636 }
4637
4638 /* copy all the ssid's and their length */
4639 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4640 {
4641 /* get the ssid length */
4642 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4643 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4644 SsidInfo->SSID.length);
4645 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4646 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4647 j, SsidInfo->SSID.ssId);
4648 }
4649 /* set the scan type to active */
4650 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4651 }
4652 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4653 {
4654 /* set the scan type to active */
4655 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4656 }
4657 else
4658 {
4659 /*Set the scan type to default type, in this case it is ACTIVE*/
4660 scanRequest.scanType = pScanInfo->scan_mode;
4661 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304662 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4664 }
4665 else
4666 {
4667 /* set the scan type to active */
4668 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4669 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4670
4671 /* set min and max channel time to zero */
4672 scanRequest.minChnTime = 0;
4673 scanRequest.maxChnTime = 0;
4674 }
4675
4676 /* set BSSType to default type */
4677 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4678
4679 /*TODO: scan the requested channels only*/
4680
4681 /*Right now scanning all the channels */
4682 if( request )
4683 {
4684 if( request->n_channels )
4685 {
4686 channelList = vos_mem_malloc( request->n_channels );
4687 if( NULL == channelList )
4688 {
4689 status = -ENOMEM;
4690 goto free_mem;
4691 }
4692
4693 for( i = 0 ; i < request->n_channels ; i++ )
4694 channelList[i] = request->channels[i]->hw_value;
4695 }
4696
4697 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4698 scanRequest.ChannelInfo.ChannelList = channelList;
4699
4700 /* set requestType to full scan */
4701 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304702
4703 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004704 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304705 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004706 */
4707
4708 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304709 * and in that case driver shoudnt flush scan results. If
4710 * driver flushes the scan results here and unfortunately if
4711 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004712 * fails which is not desired
4713 */
4714
4715 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4716 {
4717 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4718 pAdapter->sessionId );
4719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004720
4721 if( request->ie_len )
4722 {
4723 /* save this for future association (join requires this) */
4724 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4725 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4726 pScanInfo->scanAddIE.length = request->ie_len;
4727
4728 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07004729 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4730 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 )
4732 {
4733 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
4734 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
4735 }
4736
4737 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
4738 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
4739
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
4741 request->ie_len);
4742 if (pP2pIe != NULL)
4743 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07004744#ifdef WLAN_FEATURE_P2P_DEBUG
4745 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
4746 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
4747 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4748 {
4749 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
4750 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4751 "Go nego completed to Connection is started");
4752 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4753 "for 8way Handshake");
4754 }
4755 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
4756 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4757 {
4758 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
4759 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4760 "Disconnected state to Connection is started");
4761 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4762 "for 4way Handshake");
4763 }
4764#endif
4765
Jeff Johnsone7245742012-09-05 17:12:55 -07004766 /* no_cck will be set during p2p find to disable 11b rates */
4767 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004769 hddLog(VOS_TRACE_LEVEL_INFO,
4770 "%s: This is a P2P Search", __func__);
4771 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07004772
Jeff Johnsone7245742012-09-05 17:12:55 -07004773 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
4774 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07004775 /* set requestType to P2P Discovery */
4776 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07004777 }
4778
4779 /*
4780 Skip Dfs Channel in case of P2P Search
4781 if it is set in ini file
4782 */
4783 if(cfg_param->skipDfsChnlInP2pSearch)
4784 {
4785 scanRequest.skipDfsChnlInP2pSearch = 1;
4786 }
4787 else
4788 {
4789 scanRequest.skipDfsChnlInP2pSearch = 0;
4790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004791
Jeff Johnson295189b2012-06-20 16:38:30 -07004792 }
4793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 }
4795 }
4796
4797 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
4798
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004799 /* acquire the wakelock to avoid the apps suspend during the scan. To
4800 * address the following issues.
4801 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
4802 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
4803 * for long time, this result in apps running at full power for long time.
4804 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
4805 * be stuck in full power because of resume BMPS
4806 */
4807 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004808
4809 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 pAdapter->sessionId, &scanRequest, &scanId,
4811 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07004812
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 if (eHAL_STATUS_SUCCESS != status)
4814 {
4815 hddLog(VOS_TRACE_LEVEL_ERROR,
4816 "%s: sme_ScanRequest returned error %d", __func__, status);
4817 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07004818 if(eHAL_STATUS_RESOURCES == status)
4819 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07004820 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 -07004821 status = -EBUSY;
4822 } else {
4823 status = -EIO;
4824 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004825 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 goto free_mem;
4827 }
4828
4829 pScanInfo->mScanPending = TRUE;
4830 pAdapter->request = request;
4831 pScanInfo->scanId = scanId;
4832
4833 complete(&pScanInfo->scan_req_completion_event);
4834
4835free_mem:
4836 if( scanRequest.SSIDs.SSIDList )
4837 {
4838 vos_mem_free(scanRequest.SSIDs.SSIDList);
4839 }
4840
4841 if( channelList )
4842 vos_mem_free( channelList );
4843
4844 EXIT();
4845
4846 return status;
4847}
4848
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004849
4850void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
4851{
4852 v_U8_t iniDot11Mode =
4853 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
4854 eHddDot11Mode hddDot11Mode = iniDot11Mode;
4855
4856 switch ( iniDot11Mode )
4857 {
4858 case eHDD_DOT11_MODE_AUTO:
4859 case eHDD_DOT11_MODE_11ac:
4860 case eHDD_DOT11_MODE_11ac_ONLY:
4861#ifdef WLAN_FEATURE_11AC
4862 hddDot11Mode = eHDD_DOT11_MODE_11ac;
4863#else
4864 hddDot11Mode = eHDD_DOT11_MODE_11n;
4865#endif
4866 break;
4867 case eHDD_DOT11_MODE_11n:
4868 case eHDD_DOT11_MODE_11n_ONLY:
4869 hddDot11Mode = eHDD_DOT11_MODE_11n;
4870 break;
4871 default:
4872 hddDot11Mode = iniDot11Mode;
4873 break;
4874 }
4875 /* This call decides required channel bonding mode */
4876 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
4877 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
4878 operationChannel);
4879}
4880
Jeff Johnson295189b2012-06-20 16:38:30 -07004881/*
4882 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304883 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07004884 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304885int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004886 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07004887{
4888 int status = 0;
4889 hdd_wext_state_t *pWextState;
4890 v_U32_t roamId;
4891 tCsrRoamProfile *pRoamProfile;
4892 eMib_dot11DesiredBssType connectedBssType;
4893 eCsrAuthType RSNAuthType;
4894
4895 ENTER();
4896
4897 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304898
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
4900 {
4901 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
4902 return -EINVAL;
4903 }
4904
4905 pRoamProfile = &pWextState->roamProfile;
4906
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304907 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004909 int ret = 0;
4910 hdd_station_ctx_t *pHddStaCtx;
4911 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4912 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
4913
4914 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
4915 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
4916 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 {
4918 /* Issue disconnect to CSR */
4919 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304920 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
4922 pAdapter->sessionId,
4923 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
4924 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004925 ret = wait_for_completion_interruptible_timeout(
4926 &pAdapter->disconnect_comp_var,
4927 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4928 if (0 == ret)
4929 {
4930 VOS_ASSERT(0);
4931 }
4932 }
4933 }
4934 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
4935 {
4936 ret = wait_for_completion_interruptible_timeout(
4937 &pAdapter->disconnect_comp_var,
4938 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4939 if (0 == ret)
4940 {
4941 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 }
4943 }
4944
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304945 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
4947 {
4948 /*QoS not enabled in cfg file*/
4949 pRoamProfile->uapsd_mask = 0;
4950 }
4951 else
4952 {
4953 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304954 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
4956 }
4957
4958 pRoamProfile->SSIDs.numOfSSIDs = 1;
4959 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
4960 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304961 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
4963 ssid, ssid_len);
4964
4965 if (bssid)
4966 {
4967 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
4968 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
4969 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304970 /* Save BSSID in seperate variable as well, as RoamProfile
4971 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 case of join failure we should send valid BSSID to supplicant
4973 */
4974 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
4975 WNI_CFG_BSSID_LEN);
4976 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004977 else
4978 {
4979 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
4980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004981
4982 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
4983 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304984 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 /*set gen ie*/
4986 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4987 /*set auth*/
4988 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4989 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004990#ifdef FEATURE_WLAN_WAPI
4991 if (pAdapter->wapi_info.nWapiMode)
4992 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004993 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 switch (pAdapter->wapi_info.wapiAuthMode)
4995 {
4996 case WAPI_AUTH_MODE_PSK:
4997 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004998 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 pAdapter->wapi_info.wapiAuthMode);
5000 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5001 break;
5002 }
5003 case WAPI_AUTH_MODE_CERT:
5004 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005005 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 pAdapter->wapi_info.wapiAuthMode);
5007 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5008 break;
5009 }
5010 } // End of switch
5011 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5012 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5013 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005014 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 pRoamProfile->AuthType.numEntries = 1;
5016 pRoamProfile->EncryptionType.numEntries = 1;
5017 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5018 pRoamProfile->mcEncryptionType.numEntries = 1;
5019 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5020 }
5021 }
5022#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305023#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305024 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305025 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5026 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5027 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305028 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5029 sizeof (tSirGtkOffloadParams));
5030 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305031 }
5032#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 pRoamProfile->csrPersona = pAdapter->device_mode;
5034
Jeff Johnson32d95a32012-09-10 13:15:23 -07005035 if( operatingChannel )
5036 {
5037 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5038 pRoamProfile->ChannelInfo.numOfChannels = 1;
5039 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005040 else
5041 {
5042 pRoamProfile->ChannelInfo.ChannelList = NULL;
5043 pRoamProfile->ChannelInfo.numOfChannels = 0;
5044 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005045 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5046 {
5047 hdd_select_cbmode(pAdapter,operatingChannel);
5048 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005049 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5050 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305051 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005052 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005053 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5054 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305055 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5056 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005057 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5058 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305059
5060 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 pAdapter->sessionId, pRoamProfile, &roamId);
5062
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305063 if ((eHAL_STATUS_SUCCESS != status) &&
5064 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5065 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305066
5067 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005068 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5069 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5070 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305071 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005072 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305073 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005074
5075 pRoamProfile->ChannelInfo.ChannelList = NULL;
5076 pRoamProfile->ChannelInfo.numOfChannels = 0;
5077
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 }
5079 else
5080 {
5081 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5082 return -EINVAL;
5083 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005084 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 return status;
5086}
5087
5088/*
5089 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5090 * This function is used to set the authentication type (OPEN/SHARED).
5091 *
5092 */
5093static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5094 enum nl80211_auth_type auth_type)
5095{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305096 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5098
5099 ENTER();
5100
5101 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305102 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005104 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305105 hddLog(VOS_TRACE_LEVEL_INFO,
5106 "%s: set authentication type to AUTOSWITCH", __func__);
5107 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5108 break;
5109
5110 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005111#ifdef WLAN_FEATURE_VOWIFI_11R
5112 case NL80211_AUTHTYPE_FT:
5113#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305114 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 "%s: set authentication type to OPEN", __func__);
5116 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5117 break;
5118
5119 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305120 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 "%s: set authentication type to SHARED", __func__);
5122 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5123 break;
5124#ifdef FEATURE_WLAN_CCX
5125 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305126 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005127 "%s: set authentication type to CCKM WPA", __func__);
5128 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5129 break;
5130#endif
5131
5132
5133 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305134 hddLog(VOS_TRACE_LEVEL_ERROR,
5135 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005136 auth_type);
5137 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5138 return -EINVAL;
5139 }
5140
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305141 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 pHddStaCtx->conn_info.authType;
5143 return 0;
5144}
5145
5146/*
5147 * FUNCTION: wlan_hdd_set_akm_suite
5148 * This function is used to set the key mgmt type(PSK/8021x).
5149 *
5150 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305151static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005152 u32 key_mgmt
5153 )
5154{
5155 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5156 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305157
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 /*set key mgmt type*/
5159 switch(key_mgmt)
5160 {
5161 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305162#ifdef WLAN_FEATURE_VOWIFI_11R
5163 case WLAN_AKM_SUITE_FT_PSK:
5164#endif
5165 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005166 __func__);
5167 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5168 break;
5169
5170 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305171#ifdef WLAN_FEATURE_VOWIFI_11R
5172 case WLAN_AKM_SUITE_FT_8021X:
5173#endif
5174 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005175 __func__);
5176 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5177 break;
5178#ifdef FEATURE_WLAN_CCX
5179#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5180#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5181 case WLAN_AKM_SUITE_CCKM:
5182 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5183 __func__);
5184 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5185 break;
5186#endif
5187
5188 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305189 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 __func__, key_mgmt);
5191 return -EINVAL;
5192
5193 }
5194 return 0;
5195}
5196
5197/*
5198 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305199 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005200 * (NONE/WEP40/WEP104/TKIP/CCMP).
5201 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305202static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5203 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005204 bool ucast
5205 )
5206{
5207 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305208 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5210
5211 ENTER();
5212
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305213 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005214 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305215 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 __func__, cipher);
5217 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5218 }
5219 else
5220 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305221
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305223 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 {
5225 case IW_AUTH_CIPHER_NONE:
5226 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5227 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305228
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305230 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305232
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305234 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305236
Jeff Johnson295189b2012-06-20 16:38:30 -07005237 case WLAN_CIPHER_SUITE_TKIP:
5238 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5239 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305240
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 case WLAN_CIPHER_SUITE_CCMP:
5242 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5243 break;
5244#ifdef FEATURE_WLAN_WAPI
5245 case WLAN_CIPHER_SUITE_SMS4:
5246 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5247 break;
5248#endif
5249
5250#ifdef FEATURE_WLAN_CCX
5251 case WLAN_CIPHER_SUITE_KRK:
5252 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5253 break;
5254#endif
5255 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305256 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 __func__, cipher);
5258 return -EOPNOTSUPP;
5259 }
5260 }
5261
5262 if (ucast)
5263 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305264 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005265 __func__, encryptionType);
5266 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5267 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305268 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 encryptionType;
5270 }
5271 else
5272 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305273 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 __func__, encryptionType);
5275 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5276 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5277 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5278 }
5279
5280 return 0;
5281}
5282
5283
5284/*
5285 * FUNCTION: wlan_hdd_cfg80211_set_ie
5286 * This function is used to parse WPA/RSN IE's.
5287 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305288int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5289 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 size_t ie_len
5291 )
5292{
5293 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5294 u8 *genie = ie;
5295 v_U16_t remLen = ie_len;
5296#ifdef FEATURE_WLAN_WAPI
5297 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5298 u16 *tmp;
5299 v_U16_t akmsuiteCount;
5300 int *akmlist;
5301#endif
5302 ENTER();
5303
5304 /* clear previous assocAddIE */
5305 pWextState->assocAddIE.length = 0;
5306 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5307
5308 while (remLen >= 2)
5309 {
5310 v_U16_t eLen = 0;
5311 v_U8_t elementId;
5312 elementId = *genie++;
5313 eLen = *genie++;
5314 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305315
5316 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305318
5319 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305321 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005322 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 -07005323 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305324 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 "%s: Invalid WPA IE", __func__);
5326 return -EINVAL;
5327 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305328 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 {
5330 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305331 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305333
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5335 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005336 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5337 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005338 VOS_ASSERT(0);
5339 return -ENOMEM;
5340 }
5341 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5342 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5343 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305344
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5346 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5347 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5348 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305349 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5350 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5352 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5353 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5354 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5355 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5356 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305357 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
5358 P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 /*Consider P2P IE, only for P2P Client */
5360 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5361 {
5362 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305363 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305365
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5367 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005368 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5369 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 VOS_ASSERT(0);
5371 return -ENOMEM;
5372 }
5373 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5374 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5375 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305376
Jeff Johnson295189b2012-06-20 16:38:30 -07005377 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5378 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005380#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305381 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5382 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 /*Consider WFD IE, only for P2P Client */
5384 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5385 {
5386 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305387 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305389
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5391 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005392 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5393 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005394 VOS_ASSERT(0);
5395 return -ENOMEM;
5396 }
5397 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5398 // WPS IE + P2P IE + WFD IE
5399 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5400 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305401
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5403 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5404 }
5405#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005406 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305407 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005408 HS20_OUI_TYPE_SIZE)) )
5409 {
5410 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305411 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005412 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005413
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005414 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5415 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005416 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5417 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005418 VOS_ASSERT(0);
5419 return -ENOMEM;
5420 }
5421 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5422 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005423
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005424 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5425 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5426 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005427
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 break;
5429 case DOT11F_EID_RSN:
5430 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5431 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5432 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5433 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5434 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5435 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005436 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5437 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305438 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005439 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305440 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005441 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305442
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005443 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5444 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005445 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5446 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005447 VOS_ASSERT(0);
5448 return -ENOMEM;
5449 }
5450 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5451 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305452
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005453 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5454 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5455 break;
5456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005457#ifdef FEATURE_WLAN_WAPI
5458 case WLAN_EID_WAPI:
5459 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
5460 hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n",
5461 pAdapter->wapi_info.nWapiMode);
5462 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305463 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 akmsuiteCount = WPA_GET_LE16(tmp);
5465 tmp = tmp + 1;
5466 akmlist = (int *)(tmp);
5467 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5468 {
5469 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5470 }
5471 else
5472 {
5473 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5474 VOS_ASSERT(0);
5475 return -EINVAL;
5476 }
5477
5478 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5479 {
5480 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005481 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305483 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305485 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005486 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005487 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5489 }
5490 break;
5491#endif
5492 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305493 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005495 /* when Unknown IE is received we should break and continue
5496 * to the next IE in the buffer instead we were returning
5497 * so changing this to break */
5498 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 }
5500 genie += eLen;
5501 remLen -= eLen;
5502 }
5503 EXIT();
5504 return 0;
5505}
5506
5507/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305508 * FUNCTION: hdd_isWPAIEPresent
5509 * Parse the received IE to find the WPA IE
5510 *
5511 */
5512static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5513{
5514 v_U8_t eLen = 0;
5515 v_U16_t remLen = ie_len;
5516 v_U8_t elementId = 0;
5517
5518 while (remLen >= 2)
5519 {
5520 elementId = *ie++;
5521 eLen = *ie++;
5522 remLen -= 2;
5523 if (eLen > remLen)
5524 {
5525 hddLog(VOS_TRACE_LEVEL_ERROR,
5526 "%s: IE length is wrong %d", __func__, eLen);
5527 return FALSE;
5528 }
5529 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5530 {
5531 /* OUI - 0x00 0X50 0XF2
5532 WPA Information Element - 0x01
5533 WPA version - 0x01*/
5534 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5535 return TRUE;
5536 }
5537 ie += eLen;
5538 remLen -= eLen;
5539 }
5540 return FALSE;
5541}
5542
5543/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305545 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 * parameters during connect operation.
5547 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305548int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 struct cfg80211_connect_params *req
5550 )
5551{
5552 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305553 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 ENTER();
5555
5556 /*set wpa version*/
5557 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5558
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305559 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005560 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305561 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 {
5563 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5564 }
5565 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5566 {
5567 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5568 }
5569 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305570
5571 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 pWextState->wpaVersion);
5573
5574 /*set authentication type*/
5575 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5576
5577 if (0 > status)
5578 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305579 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 "%s: failed to set authentication type ", __func__);
5581 return status;
5582 }
5583
5584 /*set key mgmt type*/
5585 if (req->crypto.n_akm_suites)
5586 {
5587 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5588 if (0 > status)
5589 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305590 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005591 __func__);
5592 return status;
5593 }
5594 }
5595
5596 /*set pairwise cipher type*/
5597 if (req->crypto.n_ciphers_pairwise)
5598 {
5599 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5600 req->crypto.ciphers_pairwise[0], true);
5601 if (0 > status)
5602 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305603 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 "%s: failed to set unicast cipher type", __func__);
5605 return status;
5606 }
5607 }
5608 else
5609 {
5610 /*Reset previous cipher suite to none*/
5611 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5612 if (0 > status)
5613 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305614 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 "%s: failed to set unicast cipher type", __func__);
5616 return status;
5617 }
5618 }
5619
5620 /*set group cipher type*/
5621 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
5622 false);
5623
5624 if (0 > status)
5625 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305626 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 __func__);
5628 return status;
5629 }
5630
Chet Lanctot186b5732013-03-18 10:26:30 -07005631#ifdef WLAN_FEATURE_11W
5632 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
5633#endif
5634
Jeff Johnson295189b2012-06-20 16:38:30 -07005635 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
5636 if (req->ie_len)
5637 {
5638 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
5639 if ( 0 > status)
5640 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305641 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 __func__);
5643 return status;
5644 }
5645 }
5646
5647 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305648 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 {
5650 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
5651 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
5652 )
5653 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305654 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5656 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305657 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 __func__);
5659 return -EOPNOTSUPP;
5660 }
5661 else
5662 {
5663 u8 key_len = req->key_len;
5664 u8 key_idx = req->key_idx;
5665
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305666 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 && (CSR_MAX_NUM_KEY > key_idx)
5668 )
5669 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305670 hddLog(VOS_TRACE_LEVEL_INFO,
5671 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 __func__, key_idx, key_len);
5673 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305674 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07005675 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305676 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 (u8)key_len;
5678 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
5679 }
5680 }
5681 }
5682 }
5683
5684 return status;
5685}
5686
5687/*
5688 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305689 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 * parameters during connect operation.
5691 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305692static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 struct net_device *ndev,
5694 struct cfg80211_connect_params *req
5695 )
5696{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305697 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305698 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
5700 hdd_context_t *pHddCtx = NULL;
5701
5702 ENTER();
5703
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305704 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
5706
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305707 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5708 status = wlan_hdd_validate_context(pHddCtx);
5709
5710 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305712 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5713 "%s: HDD context is not valid", __func__);
5714 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 }
5716
5717#ifdef WLAN_BTAMP_FEATURE
5718 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305719 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305721 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005722 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08005723 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 }
5725#endif
5726 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305727 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07005728
5729 if ( 0 > status)
5730 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305731 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 __func__);
5733 return status;
5734 }
5735
5736 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005737 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07005738 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
5739 (vos_concurrent_sessions_running()))
5740 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305741 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 }
5743
Mohit Khanna765234a2012-09-11 15:08:35 -07005744 if ( req->channel )
5745 {
5746 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
5747 req->ssid_len, req->bssid,
5748 req->channel->hw_value);
5749 }
5750 else
5751 {
5752 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305753 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07005754 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005755
5756 if (0 > status)
5757 {
5758 //ReEnable BMPS if disabled
5759 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
5760 (NULL != pHddCtx))
5761 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05305762 if (pHddCtx->hdd_wlan_suspended)
5763 {
5764 hdd_set_pwrparams(pHddCtx);
5765 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 //ReEnable Bmps and Imps back
5767 hdd_enable_bmps_imps(pHddCtx);
5768 }
5769
5770 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
5771 return status;
5772 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305773 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 EXIT();
5775 return status;
5776}
5777
5778
5779/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305780 * FUNCTION: wlan_hdd_disconnect
5781 * This function is used to issue a disconnect request to SME
5782 */
5783int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
5784{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305785 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305786 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305787 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5788
5789 status = wlan_hdd_validate_context(pHddCtx);
5790
5791 if (0 != status)
5792 {
5793 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5794 "%s: HDD context is not valid", __func__);
5795 return status;
5796 }
5797
5798 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305799 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305800 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305801
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305802 /*issue disconnect*/
5803 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5804 pAdapter->sessionId, reason);
5805
5806 if ( 0 != status )
5807 {
5808 hddLog(VOS_TRACE_LEVEL_ERROR,
5809 "%s csrRoamDisconnect failure, returned %d \n",
5810 __func__, (int)status );
5811 return -EINVAL;
5812 }
5813 wait_for_completion_interruptible_timeout(
5814 &pAdapter->disconnect_comp_var,
5815 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5816 /*stop tx queues*/
5817 netif_tx_disable(pAdapter->dev);
5818 netif_carrier_off(pAdapter->dev);
5819 return status;
5820}
5821
5822
5823/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005824 * FUNCTION: wlan_hdd_cfg80211_disconnect
5825 * This function is used to issue a disconnect request to SME
5826 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305827static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 struct net_device *dev,
5829 u16 reason
5830 )
5831{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305832 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
5833 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305835 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005837 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05305838#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005839 tANI_U8 staIdx;
5840#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305841
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305843
5844 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 __func__,pAdapter->device_mode);
5846
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305847 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
5848 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005849
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305850 status = wlan_hdd_validate_context(pHddCtx);
5851
5852 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305854 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5855 "%s: HDD context is not valid", __func__);
5856 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305858
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 if (NULL != pRoamProfile)
5860 {
5861 /*issue disconnect request to SME, if station is in connected state*/
5862 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
5863 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305864 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05305866 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 switch(reason)
5868 {
5869 case WLAN_REASON_MIC_FAILURE:
5870 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
5871 break;
5872
5873 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
5874 case WLAN_REASON_DISASSOC_AP_BUSY:
5875 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
5876 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
5877 break;
5878
5879 case WLAN_REASON_PREV_AUTH_NOT_VALID:
5880 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
5881 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
5882 break;
5883
5884 case WLAN_REASON_DEAUTH_LEAVING:
5885 default:
5886 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
5887 break;
5888 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05305889 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
5890 pScanInfo = &pHddCtx->scan_info;
5891 if (pScanInfo->mScanPending)
5892 {
5893 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
5894 "Aborting Scan");
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05305895 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05305896 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005897
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005898#ifdef FEATURE_WLAN_TDLS
5899 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005900 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005901 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005902 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
5903 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005904 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08005905 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005906 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08005907 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07005908 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005909 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07005910 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005911 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005912 pAdapter->sessionId,
5913 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005914 }
5915 }
5916#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305917 status = wlan_hdd_disconnect(pAdapter, reasonCode);
5918 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 {
5920 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305921 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 __func__, (int)status );
5923 return -EINVAL;
5924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 }
5926 }
5927 else
5928 {
5929 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
5930 }
5931
5932 return status;
5933}
5934
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305935
Jeff Johnson295189b2012-06-20 16:38:30 -07005936/*
5937 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305938 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 * settings in IBSS mode.
5940 */
5941static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305942 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 struct cfg80211_ibss_params *params
5944 )
5945{
5946 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305947 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5949 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305950
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 ENTER();
5952
5953 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5954
5955 if (params->ie_len && ( NULL != params->ie) )
5956 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005957 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
5958 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 {
5960 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5961 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5962 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005963 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005965 tDot11fIEWPA dot11WPAIE;
5966 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005967 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07005968
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005969 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
5970 params->ie_len, DOT11F_EID_WPA);
5971 if ( NULL != ie )
5972 {
5973 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5974 // Unpack the WPA IE
5975 //Skip past the EID byte and length byte - and four byte WiFi OUI
5976 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
5977 &ie[2+4],
5978 ie[1] - 4,
5979 &dot11WPAIE);
5980 /*Extract the multicast cipher, the encType for unicast
5981 cipher for wpa-none is none*/
5982 encryptionType =
5983 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
5984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07005986
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
5988
5989 if (0 > status)
5990 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305991 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 __func__);
5993 return status;
5994 }
5995 }
5996
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305997 pWextState->roamProfile.AuthType.authType[0] =
5998 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6000
6001 if (params->privacy)
6002 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306003 /* Security enabled IBSS, At this time there is no information available
6004 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306006 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006007 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306008 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 *enable privacy bit in beacons */
6010
6011 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6012 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006013 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6014 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6016 pWextState->roamProfile.EncryptionType.numEntries = 1;
6017 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 return status;
6019}
6020
6021/*
6022 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306023 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306025static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 struct net_device *dev,
6027 struct cfg80211_ibss_params *params
6028 )
6029{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306030 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6032 tCsrRoamProfile *pRoamProfile;
6033 int status;
6034 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306035 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006036
6037 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306038
6039 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6041
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306042 status = wlan_hdd_validate_context(pHddCtx);
6043
6044 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306046 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6047 "%s: HDD context is not valid", __func__);
6048 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 }
6050
6051 if (NULL == pWextState)
6052 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306053 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 __func__);
6055 return -EIO;
6056 }
6057
6058 pRoamProfile = &pWextState->roamProfile;
6059
6060 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6061 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306062 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006063 "%s Interface type is not set to IBSS \n", __func__);
6064 return -EINVAL;
6065 }
6066
6067 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006068 if (NULL !=
6069#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6070 params->chandef.chan)
6071#else
6072 params->channel)
6073#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006074 {
6075 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006076 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6077 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6078 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6079 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006080
6081 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306082 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006083 ieee80211_frequency_to_channel(
6084#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6085 params->chandef.chan->center_freq);
6086#else
6087 params->channel->center_freq);
6088#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006089
6090 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6091 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006093 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6094 __func__);
6095 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006096 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006097
6098 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006100 if (channelNum == validChan[indx])
6101 {
6102 break;
6103 }
6104 }
6105 if (indx >= numChans)
6106 {
6107 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 __func__, channelNum);
6109 return -EINVAL;
6110 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006111 /* Set the Operational Channel */
6112 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6113 channelNum);
6114 pRoamProfile->ChannelInfo.numOfChannels = 1;
6115 pHddStaCtx->conn_info.operationChannel = channelNum;
6116 pRoamProfile->ChannelInfo.ChannelList =
6117 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006118 }
6119
6120 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306121 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 if (status < 0)
6123 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306124 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 __func__);
6126 return status;
6127 }
6128
6129 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306130 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006131 params->ssid_len, params->bssid,
6132 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006133
6134 if (0 > status)
6135 {
6136 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6137 return status;
6138 }
6139
6140 return 0;
6141}
6142
6143/*
6144 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306145 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306147static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 struct net_device *dev
6149 )
6150{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306151 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6153 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306154 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6155 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006156
6157 ENTER();
6158
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306159 status = wlan_hdd_validate_context(pHddCtx);
6160
6161 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006162 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306163 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6164 "%s: HDD context is not valid", __func__);
6165 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006166 }
6167
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6169 if (NULL == pWextState)
6170 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306171 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 __func__);
6173 return -EIO;
6174 }
6175
6176 pRoamProfile = &pWextState->roamProfile;
6177
6178 /* Issue disconnect only if interface type is set to IBSS */
6179 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6180 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306181 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006182 __func__);
6183 return -EINVAL;
6184 }
6185
6186 /* Issue Disconnect request */
6187 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6188 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6189 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6190
6191 return 0;
6192}
6193
6194/*
6195 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6196 * This function is used to set the phy parameters
6197 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6198 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306199static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006200 u32 changed)
6201{
6202 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6203 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306204 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006205
6206 ENTER();
6207
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306208 status = wlan_hdd_validate_context(pHddCtx);
6209
6210 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006211 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306212 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6213 "%s: HDD context is not valid", __func__);
6214 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006215 }
6216
Jeff Johnson295189b2012-06-20 16:38:30 -07006217 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6218 {
6219 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6220 WNI_CFG_RTS_THRESHOLD_STAMAX :
6221 wiphy->rts_threshold;
6222
6223 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306224 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306226 hddLog(VOS_TRACE_LEVEL_ERROR,
6227 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 __func__, rts_threshold);
6229 return -EINVAL;
6230 }
6231
6232 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6233 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306234 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306236 hddLog(VOS_TRACE_LEVEL_ERROR,
6237 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 __func__, rts_threshold);
6239 return -EIO;
6240 }
6241
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306242 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 rts_threshold);
6244 }
6245
6246 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6247 {
6248 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6249 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6250 wiphy->frag_threshold;
6251
6252 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306253 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306255 hddLog(VOS_TRACE_LEVEL_ERROR,
6256 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 frag_threshold);
6258 return -EINVAL;
6259 }
6260
6261 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6262 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306263 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306265 hddLog(VOS_TRACE_LEVEL_ERROR,
6266 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006267 __func__, frag_threshold);
6268 return -EIO;
6269 }
6270
6271 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6272 frag_threshold);
6273 }
6274
6275 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6276 || (changed & WIPHY_PARAM_RETRY_LONG))
6277 {
6278 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6279 wiphy->retry_short :
6280 wiphy->retry_long;
6281
6282 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6283 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6284 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306285 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 __func__, retry_value);
6287 return -EINVAL;
6288 }
6289
6290 if (changed & WIPHY_PARAM_RETRY_SHORT)
6291 {
6292 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6293 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306294 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306296 hddLog(VOS_TRACE_LEVEL_ERROR,
6297 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006298 __func__, retry_value);
6299 return -EIO;
6300 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306301 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 __func__, retry_value);
6303 }
6304 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6305 {
6306 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6307 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306308 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306310 hddLog(VOS_TRACE_LEVEL_ERROR,
6311 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006312 __func__, retry_value);
6313 return -EIO;
6314 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306315 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 __func__, retry_value);
6317 }
6318 }
6319
6320 return 0;
6321}
6322
6323/*
6324 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6325 * This function is used to set the txpower
6326 */
6327static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006328#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6329 struct wireless_dev *wdev,
6330#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006331#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306332 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006333#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306334 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006335#endif
6336 int dbm)
6337{
6338 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306339 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6341 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306342 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006343
6344 ENTER();
6345
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306346 status = wlan_hdd_validate_context(pHddCtx);
6347
6348 if (0 != status)
6349 {
6350 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6351 "%s: HDD context is not valid", __func__);
6352 return status;
6353 }
6354
6355 hHal = pHddCtx->hHal;
6356
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306357 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6358 dbm, ccmCfgSetCallback,
6359 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306361 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006362 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6363 return -EIO;
6364 }
6365
6366 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6367 dbm);
6368
6369 switch(type)
6370 {
6371 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6372 /* Fall through */
6373 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6374 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6375 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306376 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6377 __func__);
6378 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006379 }
6380 break;
6381 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306382 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 __func__);
6384 return -EOPNOTSUPP;
6385 break;
6386 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306387 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6388 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 return -EIO;
6390 }
6391
6392 return 0;
6393}
6394
6395/*
6396 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6397 * This function is used to read the txpower
6398 */
Yue Maf49ba872013-08-19 12:04:25 -07006399static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6400#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6401 struct wireless_dev *wdev,
6402#endif
6403 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006404{
6405
6406 hdd_adapter_t *pAdapter;
6407 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306408 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006409
Jeff Johnsone7245742012-09-05 17:12:55 -07006410 ENTER();
6411
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306412 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006413
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306414 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006415 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306416 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6417 "%s: HDD context is not valid", __func__);
6418 *dbm = 0;
6419 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006420 }
6421
Jeff Johnson295189b2012-06-20 16:38:30 -07006422 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6423 if (NULL == pAdapter)
6424 {
6425 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6426 return -ENOENT;
6427 }
6428
6429 wlan_hdd_get_classAstats(pAdapter);
6430 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6431
Jeff Johnsone7245742012-09-05 17:12:55 -07006432 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006433 return 0;
6434}
6435
6436static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6437 u8* mac, struct station_info *sinfo)
6438{
6439 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6440 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6441 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6442 tANI_U8 rate_flags;
6443
6444 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6445 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006446
6447 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6448 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6449 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6450 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6451 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6452 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6453 tANI_U16 maxRate = 0;
6454 tANI_U16 myRate;
6455 tANI_U16 currentRate = 0;
6456 tANI_U8 maxSpeedMCS = 0;
6457 tANI_U8 maxMCSIdx = 0;
6458 tANI_U8 rateFlag = 1;
6459 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006460 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306461 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006462
Leo Chang6f8870f2013-03-26 18:11:36 -07006463#ifdef WLAN_FEATURE_11AC
6464 tANI_U32 vht_mcs_map;
6465 eDataRate11ACMaxMcs vhtMaxMcs;
6466#endif /* WLAN_FEATURE_11AC */
6467
Jeff Johnsone7245742012-09-05 17:12:55 -07006468 ENTER();
6469
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6471 (0 == ssidlen))
6472 {
6473 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6474 " Invalid ssidlen, %d", __func__, ssidlen);
6475 /*To keep GUI happy*/
6476 return 0;
6477 }
6478
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306479 status = wlan_hdd_validate_context(pHddCtx);
6480
6481 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006482 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306483 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6484 "%s: HDD context is not valid", __func__);
6485 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006486 }
6487
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6489 sinfo->filled |= STATION_INFO_SIGNAL;
6490
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006491 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006492 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6493
6494 //convert to the UI units of 100kbps
6495 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6496
6497#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006498 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 -07006499 sinfo->signal,
6500 pCfg->reportMaxLinkSpeed,
6501 myRate,
6502 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006503 (int) pCfg->linkSpeedRssiMid,
6504 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006505 (int) rate_flags,
6506 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006507#endif //LINKSPEED_DEBUG_ENABLED
6508
6509 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6510 {
6511 // we do not want to necessarily report the current speed
6512 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6513 {
6514 // report the max possible speed
6515 rssidx = 0;
6516 }
6517 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6518 {
6519 // report the max possible speed with RSSI scaling
6520 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6521 {
6522 // report the max possible speed
6523 rssidx = 0;
6524 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006525 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 {
6527 // report middle speed
6528 rssidx = 1;
6529 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006530 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6531 {
6532 // report middle speed
6533 rssidx = 2;
6534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 else
6536 {
6537 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006538 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 }
6540 }
6541 else
6542 {
6543 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6544 hddLog(VOS_TRACE_LEVEL_ERROR,
6545 "%s: Invalid value for reportMaxLinkSpeed: %u",
6546 __func__, pCfg->reportMaxLinkSpeed);
6547 rssidx = 0;
6548 }
6549
6550 maxRate = 0;
6551
6552 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306553 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6554 OperationalRates, &ORLeng))
6555 {
6556 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6557 /*To keep GUI happy*/
6558 return 0;
6559 }
6560
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 for (i = 0; i < ORLeng; i++)
6562 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006563 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 {
6565 /* Validate Rate Set */
6566 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6567 {
6568 currentRate = supported_data_rate[j].supported_rate[rssidx];
6569 break;
6570 }
6571 }
6572 /* Update MAX rate */
6573 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6574 }
6575
6576 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306577 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
6578 ExtendedRates, &ERLeng))
6579 {
6580 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6581 /*To keep GUI happy*/
6582 return 0;
6583 }
6584
Jeff Johnson295189b2012-06-20 16:38:30 -07006585 for (i = 0; i < ERLeng; i++)
6586 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006587 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 {
6589 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
6590 {
6591 currentRate = supported_data_rate[j].supported_rate[rssidx];
6592 break;
6593 }
6594 }
6595 /* Update MAX rate */
6596 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 /* Get MCS Rate Set -- but only if we are connected at MCS
6599 rates or if we are always reporting max speed or if we have
6600 good rssi */
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006601 if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306603 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
6604 MCSRates, &MCSLeng))
6605 {
6606 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6607 /*To keep GUI happy*/
6608 return 0;
6609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006610 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07006611#ifdef WLAN_FEATURE_11AC
6612 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306613 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07006614 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006615 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306616 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07006617 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006619 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006621 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07006622 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006623 maxMCSIdx = 7;
6624 }
6625 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
6626 {
6627 maxMCSIdx = 8;
6628 }
6629 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
6630 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306631 //VHT20 is supporting 0~8
6632 if (rate_flags & eHAL_TX_RATE_VHT20)
6633 maxMCSIdx = 8;
6634 else
6635 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07006636 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306637
6638 if (rate_flags & eHAL_TX_RATE_VHT80)
6639 {
6640 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
6641 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
6642 }
6643 else if (rate_flags & eHAL_TX_RATE_VHT40)
6644 {
6645 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
6646 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
6647 }
6648 else if (rate_flags & eHAL_TX_RATE_VHT20)
6649 {
6650 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
6651 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
6652 }
6653
Leo Chang6f8870f2013-03-26 18:11:36 -07006654 maxSpeedMCS = 1;
6655 if (currentRate > maxRate)
6656 {
6657 maxRate = currentRate;
6658 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306659
Leo Chang6f8870f2013-03-26 18:11:36 -07006660 }
6661 else
6662#endif /* WLAN_FEATURE_11AC */
6663 {
6664 if (rate_flags & eHAL_TX_RATE_HT40)
6665 {
6666 rateFlag |= 1;
6667 }
6668 if (rate_flags & eHAL_TX_RATE_SGI)
6669 {
6670 rateFlag |= 2;
6671 }
6672
6673 for (i = 0; i < MCSLeng; i++)
6674 {
6675 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
6676 for (j = 0; j < temp; j++)
6677 {
6678 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
6679 {
6680 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
6681 break;
6682 }
6683 }
6684 if ((j < temp) && (currentRate > maxRate))
6685 {
6686 maxRate = currentRate;
6687 maxSpeedMCS = 1;
6688 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
6689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 }
6691 }
6692 }
6693
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306694 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
6695 {
6696 maxRate = myRate;
6697 maxSpeedMCS = 1;
6698 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6699 }
6700
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006702 if (((maxRate < myRate) && (0 == rssidx)) ||
6703 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 {
6705 maxRate = myRate;
6706 if (rate_flags & eHAL_TX_RATE_LEGACY)
6707 {
6708 maxSpeedMCS = 0;
6709 }
6710 else
6711 {
6712 maxSpeedMCS = 1;
6713 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6714 }
6715 }
6716
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306717 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 {
6719 sinfo->txrate.legacy = maxRate;
6720#ifdef LINKSPEED_DEBUG_ENABLED
6721 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
6722#endif //LINKSPEED_DEBUG_ENABLED
6723 }
6724 else
6725 {
6726 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07006727#ifdef WLAN_FEATURE_11AC
6728 sinfo->txrate.nss = 1;
6729 if (rate_flags & eHAL_TX_RATE_VHT80)
6730 {
6731 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306732 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07006733 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306734 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07006735 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306736 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6737 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6738 }
6739 else if (rate_flags & eHAL_TX_RATE_VHT20)
6740 {
6741 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6742 }
6743#endif /* WLAN_FEATURE_11AC */
6744 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
6745 {
6746 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
6747 if (rate_flags & eHAL_TX_RATE_HT40)
6748 {
6749 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6750 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006751 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006752 if (rate_flags & eHAL_TX_RATE_SGI)
6753 {
6754 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
6755 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306756
Jeff Johnson295189b2012-06-20 16:38:30 -07006757#ifdef LINKSPEED_DEBUG_ENABLED
6758 pr_info("Reporting MCS rate %d flags %x\n",
6759 sinfo->txrate.mcs,
6760 sinfo->txrate.flags );
6761#endif //LINKSPEED_DEBUG_ENABLED
6762 }
6763 }
6764 else
6765 {
6766 // report current rate instead of max rate
6767
6768 if (rate_flags & eHAL_TX_RATE_LEGACY)
6769 {
6770 //provide to the UI in units of 100kbps
6771 sinfo->txrate.legacy = myRate;
6772#ifdef LINKSPEED_DEBUG_ENABLED
6773 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
6774#endif //LINKSPEED_DEBUG_ENABLED
6775 }
6776 else
6777 {
6778 //must be MCS
6779 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07006780#ifdef WLAN_FEATURE_11AC
6781 sinfo->txrate.nss = 1;
6782 if (rate_flags & eHAL_TX_RATE_VHT80)
6783 {
6784 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6785 }
6786 else
6787#endif /* WLAN_FEATURE_11AC */
6788 {
6789 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
6790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006791 if (rate_flags & eHAL_TX_RATE_SGI)
6792 {
6793 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
6794 }
6795 if (rate_flags & eHAL_TX_RATE_HT40)
6796 {
6797 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6798 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006799#ifdef WLAN_FEATURE_11AC
6800 else if (rate_flags & eHAL_TX_RATE_VHT80)
6801 {
6802 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
6803 }
6804#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07006805#ifdef LINKSPEED_DEBUG_ENABLED
6806 pr_info("Reporting actual MCS rate %d flags %x\n",
6807 sinfo->txrate.mcs,
6808 sinfo->txrate.flags );
6809#endif //LINKSPEED_DEBUG_ENABLED
6810 }
6811 }
6812 sinfo->filled |= STATION_INFO_TX_BITRATE;
6813
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006814 sinfo->tx_packets =
6815 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
6816 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
6817 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
6818 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
6819
6820 sinfo->tx_retries =
6821 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
6822 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
6823 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
6824 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
6825
6826 sinfo->tx_failed =
6827 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
6828 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
6829 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
6830 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
6831
6832 sinfo->filled |=
6833 STATION_INFO_TX_PACKETS |
6834 STATION_INFO_TX_RETRIES |
6835 STATION_INFO_TX_FAILED;
6836
6837 EXIT();
6838 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006839}
6840
6841static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07006842 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07006843{
6844 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306845 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306847 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006848
Jeff Johnsone7245742012-09-05 17:12:55 -07006849 ENTER();
6850
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 if (NULL == pAdapter)
6852 {
6853 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
6854 return -ENODEV;
6855 }
6856
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306857 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306858 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306859
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306860 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306861 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306862 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6863 "%s: HDD context is not valid", __func__);
6864 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306865 }
6866
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306867 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
6868 (TRUE == pHddCtx->hdd_wlan_suspended) &&
6869 (pHddCtx->cfg_ini->fhostArpOffload) &&
6870 (eConnectionState_Associated ==
6871 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
6872 {
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05306873 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306874 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6875 {
6876 hddLog(VOS_TRACE_LEVEL_INFO,
6877 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
6878 __func__, vos_status);
6879 }
6880 }
6881
Jeff Johnson295189b2012-06-20 16:38:30 -07006882 /**The get power cmd from the supplicant gets updated by the nl only
6883 *on successful execution of the function call
6884 *we are oppositely mapped w.r.t mode in the driver
6885 **/
6886 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
6887
Jeff Johnsone7245742012-09-05 17:12:55 -07006888 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006889 if (VOS_STATUS_E_FAILURE == vos_status)
6890 {
6891 return -EINVAL;
6892 }
6893 return 0;
6894}
6895
6896
6897#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
6898static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
6899 struct net_device *netdev,
6900 u8 key_index)
6901{
Jeff Johnsone7245742012-09-05 17:12:55 -07006902 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 return 0;
6904}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306905#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07006906
6907#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
6908static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
6909 struct net_device *dev,
6910 struct ieee80211_txq_params *params)
6911{
Jeff Johnsone7245742012-09-05 17:12:55 -07006912 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 return 0;
6914}
6915#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
6916static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
6917 struct ieee80211_txq_params *params)
6918{
Jeff Johnsone7245742012-09-05 17:12:55 -07006919 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006920 return 0;
6921}
6922#endif //LINUX_VERSION_CODE
6923
6924static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
6925 struct net_device *dev, u8 *mac)
6926{
6927 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306928 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006929 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306930 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006931 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006932
Jeff Johnsone7245742012-09-05 17:12:55 -07006933 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306934 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306936 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 return -EINVAL;
6938 }
6939
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306940 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6941 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006942
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306943 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006944 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306945 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6946 "%s: HDD context is not valid", __func__);
6947 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006948 }
6949
Jeff Johnson295189b2012-06-20 16:38:30 -07006950 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07006951 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 )
6953 {
6954 if( NULL == mac )
6955 {
6956 v_U16_t i;
6957 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
6958 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07006959 if ((pAdapter->aStaInfo[i].isUsed) &&
6960 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07006961 {
6962 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
6963 hddLog(VOS_TRACE_LEVEL_INFO,
6964 "%s: Delete STA with MAC::"
6965 "%02x:%02x:%02x:%02x:%02x:%02x",
6966 __func__,
6967 macAddr[0], macAddr[1], macAddr[2],
6968 macAddr[3], macAddr[4], macAddr[5]);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07006969 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
6970 if (VOS_IS_STATUS_SUCCESS(vos_status))
6971 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 }
6973 }
6974 }
6975 else
6976 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08006977
6978 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
6979 if (!VOS_IS_STATUS_SUCCESS(vos_status))
6980 {
6981 hddLog(VOS_TRACE_LEVEL_INFO,
6982 "%s: Skip this DEL STA as this is not used::"
6983 "%02x:%02x:%02x:%02x:%02x:%02x",
6984 __func__,
6985 mac[0], mac[1], mac[2],
6986 mac[3], mac[4], mac[5]);
6987 return -ENOENT;
6988 }
6989
6990 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
6991 {
6992 hddLog(VOS_TRACE_LEVEL_INFO,
6993 "%s: Skip this DEL STA as deauth is in progress::"
6994 "%02x:%02x:%02x:%02x:%02x:%02x",
6995 __func__,
6996 mac[0], mac[1], mac[2],
6997 mac[3], mac[4], mac[5]);
6998 return -ENOENT;
6999 }
7000
7001 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7002
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 hddLog(VOS_TRACE_LEVEL_INFO,
7004 "%s: Delete STA with MAC::"
7005 "%02x:%02x:%02x:%02x:%02x:%02x",
7006 __func__,
7007 mac[0], mac[1], mac[2],
7008 mac[3], mac[4], mac[5]);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007009
7010 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7011 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7012 {
7013 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7014 hddLog(VOS_TRACE_LEVEL_INFO,
7015 "%s: STA removal failed for ::"
7016 "%02x:%02x:%02x:%02x:%02x:%02x",
7017 __func__,
7018 mac[0], mac[1], mac[2],
7019 mac[3], mac[4], mac[5]);
7020 return -ENOENT;
7021 }
7022
Jeff Johnson295189b2012-06-20 16:38:30 -07007023 }
7024 }
7025
7026 EXIT();
7027
7028 return 0;
7029}
7030
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007031static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7032 struct net_device *dev, u8 *mac, struct station_parameters *params)
7033{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007034 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007035#ifdef FEATURE_WLAN_TDLS
7036 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007037 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007038 mask = params->sta_flags_mask;
7039
7040 set = params->sta_flags_set;
7041
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007042#ifdef WLAN_FEATURE_TDLS_DEBUG
7043 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7044 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7045 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7046#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007047
7048 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7049 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007050 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007051 }
7052 }
7053#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007054 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007055}
7056
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007057
7058#ifdef FEATURE_WLAN_LFR
7059static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007060 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007061{
7062#define MAX_PMKSAIDS_IN_CACHE 8
7063 static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307064 static tANI_U32 i; // HDD Local Cache index
7065 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007066 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7067 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307068 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307069 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007070 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307071 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307072
Jeff Johnsone7245742012-09-05 17:12:55 -07007073 ENTER();
7074
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307075 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307076 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007077 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307078 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007079 return -EINVAL;
7080 }
7081
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307082 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7083 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007084
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307085 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007086 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307087 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7088 "%s: HDD context is not valid", __func__);
7089 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007090 }
7091
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307092 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007093 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7094
7095 for (j = 0; j < i; j++)
7096 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307097 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007098 pmksa->bssid, WNI_CFG_BSSID_LEN))
7099 {
7100 /* BSSID matched previous entry. Overwrite it. */
7101 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307102 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007103 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307104 vos_mem_copy(PMKIDCache[j].PMKID,
7105 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007106 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307107 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007108 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007109 dump_bssid(pmksa->bssid);
7110 dump_pmkid(halHandle, pmksa->pmkid);
7111 break;
7112 }
7113 }
7114
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007115 /* Check we compared all entries,if then take the first slot now */
7116 if(j == MAX_PMKSAIDS_IN_CACHE) i=0;
7117
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007118 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307119 {
7120 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
7121 vos_mem_copy(PMKIDCache[i].BSSID,
7122 pmksa->bssid, ETHER_ADDR_LEN);
7123 vos_mem_copy(PMKIDCache[i].PMKID,
7124 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007125 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307126 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007127 __func__, i );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007128 dump_bssid(pmksa->bssid);
7129 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307130 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007131 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307132 if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007133 }
7134
7135
7136 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307137 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007138 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307139 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007140 __func__, i );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007141 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307142 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7143 PMKIDCache,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007144 i );
7145 return 0;
7146}
7147
7148
7149static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007150 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007151{
Jeff Johnsone7245742012-09-05 17:12:55 -07007152 ENTER();
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007153 // TODO: Implement this later.
7154 return 0;
7155}
7156
7157static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7158{
Jeff Johnsone7245742012-09-05 17:12:55 -07007159 ENTER();
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007160 // TODO: Implement this later.
7161 return 0;
7162}
7163#endif
7164
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007165#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307166static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007167 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7168{
7169 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7170 hdd_station_ctx_t *pHddStaCtx;
7171
7172 if (NULL == pAdapter)
7173 {
7174 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7175 return -ENODEV;
7176 }
7177
7178 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7179
7180 // Added for debug on reception of Re-assoc Req.
7181 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7182 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307183 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007184 ftie->ie_len);
7185 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7186 }
7187
7188#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307189 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007190 ftie->ie_len);
7191#endif
7192
7193 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307194 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7195 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007196 ftie->ie_len);
7197 return 0;
7198}
7199#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007200
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307201#ifdef FEATURE_WLAN_SCAN_PNO
7202
7203void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7204 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7205{
7206 int ret;
7207 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7208 hdd_context_t *pHddCtx;
7209
7210 if (NULL == pAdapter)
7211 {
7212 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7213 "%s: HDD adapter is Null", __func__);
7214 return ;
7215 }
7216
7217 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7218 if (NULL == pHddCtx)
7219 {
7220 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7221 "%s: HDD context is Null!!!", __func__);
7222 return ;
7223 }
7224
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307225 spin_lock(&pHddCtx->schedScan_lock);
7226 if (TRUE == pHddCtx->isWiphySuspended)
7227 {
7228 pHddCtx->isSchedScanUpdatePending = TRUE;
7229 spin_unlock(&pHddCtx->schedScan_lock);
7230 hddLog(VOS_TRACE_LEVEL_INFO,
7231 "%s: Update cfg80211 scan database after it resume", __func__);
7232 return ;
7233 }
7234 spin_unlock(&pHddCtx->schedScan_lock);
7235
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307236 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7237
7238 if (0 > ret)
7239 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7240
7241 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307242 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7243 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307244}
7245
7246/*
7247 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7248 * NL interface to enable PNO
7249 */
7250static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7251 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7252{
7253 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7254 tpSirPNOScanReq pPnoRequest = NULL;
7255 hdd_context_t *pHddCtx;
7256 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307257 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307258 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7259 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7260 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7261 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307262 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307263
7264 if (NULL == pAdapter)
7265 {
7266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7267 "%s: HDD adapter is Null", __func__);
7268 return -ENODEV;
7269 }
7270
7271 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307272 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307273
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307274 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307275 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307276 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7277 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307278 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307279 }
7280
7281 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7282 if (NULL == hHal)
7283 {
7284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7285 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307286 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307287 }
7288
7289 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7290 if (NULL == pPnoRequest)
7291 {
7292 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7293 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307294 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307295 }
7296
7297 pPnoRequest->enable = 1; /*Enable PNO */
7298 pPnoRequest->ucNetworksCount = request->n_match_sets;
7299
7300 if (( !pPnoRequest->ucNetworksCount ) ||
7301 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7302 {
7303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7304 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307305 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307306 goto error;
7307 }
7308
7309 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7310 {
7311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7312 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307313 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307314 goto error;
7315 }
7316
7317 /* Framework provides one set of channels(all)
7318 * common for all saved profile */
7319 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7320 channels_allowed, &num_channels_allowed))
7321 {
7322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7323 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307324 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307325 goto error;
7326 }
7327 /* Checking each channel against allowed channel list */
7328 num_ch = 0;
7329 for (i = 0; i < request->n_channels; i++)
7330 {
7331 for (indx = 0; indx < num_channels_allowed; indx++)
7332 {
7333 if (request->channels[i]->hw_value == channels_allowed[indx])
7334 {
7335 valid_ch[num_ch++] = request->channels[i]->hw_value;
7336 break ;
7337 }
7338 }
7339 }
7340
7341 /* Filling per profile params */
7342 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7343 {
7344 pPnoRequest->aNetworks[i].ssId.length =
7345 request->match_sets[i].ssid.ssid_len;
7346
7347 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7348 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7349 {
7350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7351 "SSID Len %d is not correct for network %d",
7352 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307353 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307354 goto error;
7355 }
7356
7357 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7358 request->match_sets[i].ssid.ssid,
7359 request->match_sets[i].ssid.ssid_len);
7360 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7361 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7362 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7363
7364 /*Copying list of valid channel into request */
7365 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7366 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7367
7368 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7369 }
7370
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307371 /* Driver gets only one time interval which is hardcoded in
7372 * supplicant for 10000ms. Taking power consumption into account 6 timers
7373 * will be used, Timervalue is increased exponentially i.e 10,20,40,
7374 * 80,160,320 secs. And number of scan cycle for each timer
7375 * is configurable through INI param gPNOScanTimerRepeatValue.
7376 * If it is set to 0 only one timer will be used and PNO scan cycle
7377 * will be repeated after each interval specified by supplicant
7378 * till PNO is disabled.
7379 */
7380 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
7381 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
7382 else
7383 pPnoRequest->scanTimers.ucScanTimersCount =
7384 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
7385
7386 tempInterval = (request->interval)/1000;
7387 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7388 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
7389 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
7390 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
7391 {
7392 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
7393 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
7394 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
7395 tempInterval *= 2;
7396 }
7397 //Repeat last timer until pno disabled.
7398 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
7399
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307400 pPnoRequest->modePNO = SIR_PNO_MODE_ON_SUSPEND;
7401
7402 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7403 pPnoRequest, pAdapter->sessionId,
7404 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7405 if (eHAL_STATUS_SUCCESS != status)
7406 {
7407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7408 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307409 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307410 goto error;
7411 }
7412
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7414 "PNO scanRequest offloaded");
7415
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307416error:
7417 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307418 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307419}
7420
7421/*
7422 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
7423 * NL interface to disable PNO
7424 */
7425static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
7426 struct net_device *dev)
7427{
7428 eHalStatus status = eHAL_STATUS_FAILURE;
7429 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7430 hdd_context_t *pHddCtx;
7431 tHalHandle hHal;
7432 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307433 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307434
7435 ENTER();
7436
7437 if (NULL == pAdapter)
7438 {
7439 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7440 "%s: HDD adapter is Null", __func__);
7441 return -ENODEV;
7442 }
7443
7444 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307445
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307446 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307447 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307448 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307449 "%s: HDD context is Null", __func__);
7450 return -ENODEV;
7451 }
7452
7453 /* The return 0 is intentional when isLogpInProgress and
7454 * isLoadUnloadInProgress. We did observe a crash due to a return of
7455 * failure in sched_scan_stop , especially for a case where the unload
7456 * of the happens at the same time. The function __cfg80211_stop_sched_scan
7457 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
7458 * success. If it returns a failure , then its next invocation due to the
7459 * clean up of the second interface will have the dev pointer corresponding
7460 * to the first one leading to a crash.
7461 */
7462 if (pHddCtx->isLogpInProgress)
7463 {
7464 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7465 "%s: LOGP in Progress. Ignore!!!", __func__);
7466 return ret;
7467 }
7468
7469 if (pHddCtx->isLoadUnloadInProgress)
7470 {
7471 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7472 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
7473 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307474 }
7475
7476 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7477 if (NULL == hHal)
7478 {
7479 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7480 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307481 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307482 }
7483
7484 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7485 if (NULL == pPnoRequest)
7486 {
7487 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7488 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307489 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307490 }
7491
7492 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
7493 pPnoRequest->enable = 0; /* Disable PNO */
7494 pPnoRequest->ucNetworksCount = 0;
7495
7496 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
7497 pAdapter->sessionId,
7498 NULL, pAdapter);
7499 if (eHAL_STATUS_SUCCESS != status)
7500 {
7501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7502 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307503 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307504 }
7505
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307506 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7507 "%s: PNO scan disabled", __func__);
7508
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307509 vos_mem_free(pPnoRequest);
7510
7511 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307512 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307513}
7514
7515#endif /*FEATURE_WLAN_SCAN_PNO*/
7516
7517
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007518#ifdef FEATURE_WLAN_TDLS
7519static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
7520 u8 *peer, u8 action_code, u8 dialog_token,
7521 u16 status_code, const u8 *buf, size_t len)
7522{
7523
7524 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7525 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007526 u8 peerMac[6];
7527 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007528 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08007529 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007530 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007531
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007532 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007533 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307534 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007535 "Invalid arguments");
7536 return -EINVAL;
7537 }
7538
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007539 if (pHddCtx->isLogpInProgress)
7540 {
7541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7542 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007543 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007544 return -EBUSY;
7545 }
7546
Hoonki Lee27511902013-03-14 18:19:06 -07007547 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007548 {
Hoonki Lee27511902013-03-14 18:19:06 -07007549 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7550 "%s: TDLS mode is disabled OR not enabled in FW."
7551 MAC_ADDRESS_STR " action %d declined.",
7552 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007553 return -ENOTSUPP;
7554 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08007555
Hoonki Lee27511902013-03-14 18:19:06 -07007556 /* other than teardown frame, other mgmt frames are not sent if disabled */
7557 if (SIR_MAC_TDLS_TEARDOWN != action_code)
7558 {
7559 /* if tdls_mode is disabled to respond to peer's request */
7560 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
7561 {
7562 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7563 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007564 " TDLS mode is disabled. action %d declined.",
7565 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07007566
7567 return -ENOTSUPP;
7568 }
7569 }
7570
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007571 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
7572 {
Hoonki Leefb8df672013-04-10 18:20:34 -07007573 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007574 {
7575 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007576 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007577 " TDLS setup is ongoing. action %d declined.",
7578 __func__, MAC_ADDR_ARRAY(peer), action_code);
7579 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007580 }
7581 }
7582
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007583 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
7584 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08007585 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007586 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08007587 {
7588 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
7589 we return error code at 'add_station()'. Hence we have this
7590 check again in addtion to add_station().
7591 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007592 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08007593 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007594 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7595 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007596 " TDLS Max peer already connected. action %d declined.",
7597 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007598 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08007599 }
7600 else
7601 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007602 /* maximum reached. tweak to send error code to peer and return
7603 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08007604 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007605 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7606 "%s: " MAC_ADDRESS_STR
7607 " TDLS Max peer already connected send response status %d",
7608 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007609 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007610 /* fall through to send setup resp with failure status
7611 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08007612 }
7613 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007614 else
7615 {
7616 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007617 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007618 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007619 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007620 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007621 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
7622 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007623 return -EPERM;
7624 }
7625 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08007626 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007627 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007628
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007629#ifdef WLAN_FEATURE_TDLS_DEBUG
7630 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007631 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
7632 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
7633 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007634#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007635
Hoonki Leea34dd892013-02-05 22:56:02 -08007636 /*Except teardown responder will not be used so just make 0*/
7637 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007638 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08007639 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007640
7641 hddTdlsPeer_t *pTdlsPeer;
7642 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac);
7643
7644 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
7645 responder = pTdlsPeer->is_responder;
7646 else
Hoonki Leea34dd892013-02-05 22:56:02 -08007647 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007648 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7649 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
7650 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
7651 dialog_token, status_code, len);
7652 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08007653 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007654 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007655
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307656 /* For explicit trigger of DIS_REQ come out of BMPS for
7657 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07007658 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307659 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
7660 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07007661 {
7662 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7663 {
7664 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307665 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07007666 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
7667 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307668 if (SIR_MAC_TDLS_DIS_REQ != action_code)
7669 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07007670 }
7671
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007672 /* make sure doesn't call send_mgmt() while it is pending */
7673 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
7674 {
7675 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7676 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
7677 __func__, MAC_ADDR_ARRAY(peer), action_code);
7678 return -EBUSY;
7679 }
7680
7681 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007682 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
7683
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007684 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08007685 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007686
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007687 if (VOS_STATUS_SUCCESS != status)
7688 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7690 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007691 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07007692 wlan_hdd_tdls_check_bmps(pAdapter);
7693 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007694 }
7695
Hoonki Leed37cbb32013-04-20 00:31:14 -07007696 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
7697 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
7698
7699 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007700 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07007701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7702 "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu",
7703 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007704 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007705 wlan_hdd_tdls_check_bmps(pAdapter);
7706 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007707 }
7708
Gopichand Nakkala05922802013-03-14 12:23:19 -07007709 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07007710 {
7711 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007712 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07007713 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007714
Hoonki Leea34dd892013-02-05 22:56:02 -08007715 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
7716 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007717 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08007718 }
7719 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
7720 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007721 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08007722 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007723
7724 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007725error:
7726 /* max_sta_failed ; we didn't set to CONNECTING for this case,
7727 because we already know that this transaction will be failed,
7728 but we weren't sure if supplicant call DISABLE_LINK or not. So,
7729 to be safe, do not change the state mahine.
7730 */
7731 if(max_sta_failed == 0 &&
7732 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
7733 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
7734 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007735}
7736
7737static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
7738 u8 *peer, enum nl80211_tdls_operation oper)
7739{
7740 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7741 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307742 int status;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007743#ifdef WLAN_FEATURE_TDLS_DEBUG
7744 const char *tdls_oper_str[]= {
7745 "NL80211_TDLS_DISCOVERY_REQ",
7746 "NL80211_TDLS_SETUP",
7747 "NL80211_TDLS_TEARDOWN",
7748 "NL80211_TDLS_ENABLE_LINK",
7749 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05307750 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007751#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007752 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007753
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307754 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007755 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007756 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07007757 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007758 return -EINVAL;
7759 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007760
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307761 status = wlan_hdd_validate_context(pHddCtx);
7762
7763 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007764 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307765 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7766 "%s: HDD context is not valid", __func__);
7767 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007768 }
7769
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007770 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer);
7771
7772 if ( NULL == pTdlsPeer ) {
7773 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
7774 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
7775 return -EINVAL;
7776 }
7777
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007778#ifdef WLAN_FEATURE_TDLS_DEBUG
7779 if((int)oper > 4)
7780 oper = 5;
7781
7782 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007783 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
7784 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007785 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007786#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007787
7788 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007789 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007790 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07007792 "TDLS Disabled in INI OR not enabled in FW. "
7793 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007794 return -ENOTSUPP;
7795 }
7796
7797 switch (oper) {
7798 case NL80211_TDLS_ENABLE_LINK:
7799 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007800 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307801 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007802
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07007803 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
7804 {
7805 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
7806 MAC_ADDRESS_STR " failed",
7807 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
7808 return -EINVAL;
7809 }
7810
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007811 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007812 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307813 long ret;
7814
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307815 if (0 != wlan_hdd_tdls_get_link_establish_params(pAdapter, peer,&tdlsLinkEstablishParams)) {
7816 return -EINVAL;
7817 }
7818 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
7819
7820 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
7821 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
7822 /* Send TDLS peer UAPSD capabilities to the firmware and
7823 * register with the TL on after the response for this operation
7824 * is received .
7825 */
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307826 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_link_establish_req_comp,
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307827 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307828 if (ret <= 0)
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307829 {
7830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7831 "%s: Link Establish Request Faled Status %ld",
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307832 __func__, ret);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307833 return -EINVAL;
7834 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007835 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05307836 /* Mark TDLS client Authenticated .*/
7837 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
7838 pTdlsPeer->staId,
7839 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007840 if (VOS_STATUS_SUCCESS == status)
7841 {
Hoonki Lee14621352013-04-16 17:51:19 -07007842 if (pTdlsPeer->is_responder == 0)
7843 {
7844 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
7845
7846 wlan_hdd_tdls_timer_restart(pAdapter,
7847 &pTdlsPeer->initiatorWaitTimeoutTimer,
7848 WAIT_TIME_TDLS_INITIATOR);
7849 /* suspend initiator TX until it receives direct packet from the
7850 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
7851 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
7852 &staId, NULL);
7853 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007854 wlan_hdd_tdls_increment_peer_count(pAdapter);
7855 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007856 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307857
7858 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307859 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
7860 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307861 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05307862 int ac;
7863 uint8 ucAc[4] = { WLANTL_AC_VO,
7864 WLANTL_AC_VI,
7865 WLANTL_AC_BK,
7866 WLANTL_AC_BE };
7867 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
7868 for(ac=0; ac < 4; ac++)
7869 {
7870 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
7871 pTdlsPeer->staId, ucAc[ac],
7872 tlTid[ac], tlTid[ac], 0, 0,
7873 WLANTL_BI_DIR );
7874 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307875 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007876 }
7877
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007878 }
7879 break;
7880 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08007881 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007882 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08007883 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007884 long status;
7885
7886 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
7887
Lee Hoonkic1262f22013-01-24 21:59:00 -08007888 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
7889 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007890
7891 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
7892 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
7893 if (status <= 0)
7894 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007895 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7897 "%s: Del station failed status %ld",
7898 __func__, status);
7899 return -EPERM;
7900 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007901 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08007902 }
7903 else
7904 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7906 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08007907 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08007908 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007909 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007910 case NL80211_TDLS_TEARDOWN:
7911 case NL80211_TDLS_SETUP:
7912 case NL80211_TDLS_DISCOVERY_REQ:
7913 /* We don't support in-driver setup/teardown/discovery */
7914 return -ENOTSUPP;
7915 default:
7916 return -ENOTSUPP;
7917 }
7918 return 0;
7919}
Chilam NG571c65a2013-01-19 12:27:36 +05307920
7921int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
7922 struct net_device *dev, u8 *peer)
7923{
7924 hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x",
7925 peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]);
7926
7927 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
7928 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
7929}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007930#endif
7931
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307932#ifdef WLAN_FEATURE_GTK_OFFLOAD
7933/*
7934 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
7935 * Callback rountine called upon receiving response for
7936 * get offload info
7937 */
7938void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
7939 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
7940{
7941
7942 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307943 tANI_U8 tempReplayCounter[8];
7944 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307945
7946 ENTER();
7947
7948 if (NULL == pAdapter)
7949 {
7950 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7951 "%s: HDD adapter is Null", __func__);
7952 return ;
7953 }
7954
7955 if (NULL == pGtkOffloadGetInfoRsp)
7956 {
7957 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7958 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
7959 return ;
7960 }
7961
7962 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
7963 {
7964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7965 "%s: wlan Failed to get replay counter value",
7966 __func__);
7967 return ;
7968 }
7969
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307970 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7971 /* Update replay counter */
7972 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
7973 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
7974
7975 {
7976 /* changing from little to big endian since supplicant
7977 * works on big endian format
7978 */
7979 int i;
7980 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
7981
7982 for (i = 0; i < 8; i++)
7983 {
7984 tempReplayCounter[7-i] = (tANI_U8)p[i];
7985 }
7986 }
7987
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307988 /* Update replay counter to NL */
7989 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05307990 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05307991}
7992
7993/*
7994 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
7995 * This function is used to offload GTK rekeying job to the firmware.
7996 */
7997int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
7998 struct cfg80211_gtk_rekey_data *data)
7999{
8000 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8001 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8002 hdd_station_ctx_t *pHddStaCtx;
8003 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308004 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308005 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308006 eHalStatus status = eHAL_STATUS_FAILURE;
8007
8008 ENTER();
8009
8010 if (NULL == pAdapter)
8011 {
8012 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8013 "%s: HDD adapter is Null", __func__);
8014 return -ENODEV;
8015 }
8016
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308017 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308018
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308019 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308020 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308021 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8022 "%s: HDD context is not valid", __func__);
8023 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308024 }
8025
8026 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8027 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8028 if (NULL == hHal)
8029 {
8030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8031 "%s: HAL context is Null!!!", __func__);
8032 return -EAGAIN;
8033 }
8034
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308035 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8036 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8037 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8038 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308039 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308040 {
8041 /* changing from big to little endian since driver
8042 * works on little endian format
8043 */
8044 tANI_U8 *p =
8045 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8046 int i;
8047
8048 for (i = 0; i < 8; i++)
8049 {
8050 p[7-i] = data->replay_ctr[i];
8051 }
8052 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308053
8054 if (TRUE == pHddCtx->hdd_wlan_suspended)
8055 {
8056 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308057 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8058 sizeof (tSirGtkOffloadParams));
8059 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308060 pAdapter->sessionId);
8061
8062 if (eHAL_STATUS_SUCCESS != status)
8063 {
8064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8065 "%s: sme_SetGTKOffload failed, returned %d",
8066 __func__, status);
8067 return status;
8068 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8070 "%s: sme_SetGTKOffload successfull", __func__);
8071 }
8072 else
8073 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8075 "%s: wlan not suspended GTKOffload request is stored",
8076 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308077 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308078
8079 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308080}
8081#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8082
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308083/*
8084 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8085 * This function is used to set access control policy
8086 */
8087static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8088 struct net_device *dev, const struct cfg80211_acl_data *params)
8089{
8090 int i;
8091 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8092 hdd_hostapd_state_t *pHostapdState;
8093 tsap_Config_t *pConfig;
8094 v_CONTEXT_t pVosContext = NULL;
8095 hdd_context_t *pHddCtx;
8096 int status;
8097
8098 ENTER();
8099
8100 if (NULL == pAdapter)
8101 {
8102 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8103 "%s: HDD adapter is Null", __func__);
8104 return -ENODEV;
8105 }
8106
8107 if (NULL == params)
8108 {
8109 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8110 "%s: params is Null", __func__);
8111 return -EINVAL;
8112 }
8113
8114 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8115 status = wlan_hdd_validate_context(pHddCtx);
8116
8117 if (0 != status)
8118 {
8119 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8120 "%s: HDD context is not valid", __func__);
8121 return status;
8122 }
8123
8124 pVosContext = pHddCtx->pvosContext;
8125 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8126
8127 if (NULL == pHostapdState)
8128 {
8129 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8130 "%s: pHostapdState is Null", __func__);
8131 return -EINVAL;
8132 }
8133
8134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8135 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8136
8137 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8138 {
8139 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8140
8141 /* default value */
8142 pConfig->num_accept_mac = 0;
8143 pConfig->num_deny_mac = 0;
8144
8145 /**
8146 * access control policy
8147 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8148 * listed in hostapd.deny file.
8149 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8150 * listed in hostapd.accept file.
8151 */
8152 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8153 {
8154 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8155 }
8156 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8157 {
8158 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8159 }
8160 else
8161 {
8162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8163 "%s:Acl Policy : %d is not supported",
8164 __func__, params->acl_policy);
8165 return -ENOTSUPP;
8166 }
8167
8168 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8169 {
8170 pConfig->num_accept_mac = params->n_acl_entries;
8171 for (i = 0; i < params->n_acl_entries; i++)
8172 {
8173 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8174 "** Add ACL MAC entry %i in WhiletList :"
8175 MAC_ADDRESS_STR, i,
8176 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8177
8178 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8179 sizeof(qcmacaddr));
8180 }
8181 }
8182 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8183 {
8184 pConfig->num_deny_mac = params->n_acl_entries;
8185 for (i = 0; i < params->n_acl_entries; i++)
8186 {
8187 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8188 "** Add ACL MAC entry %i in BlackList :"
8189 MAC_ADDRESS_STR, i,
8190 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8191
8192 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8193 sizeof(qcmacaddr));
8194 }
8195 }
8196
8197 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8198 {
8199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8200 "%s: SAP Set Mac Acl fail", __func__);
8201 return -EINVAL;
8202 }
8203 }
8204 else
8205 {
8206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8207 "%s: Invalid device_mode = %d",
8208 __func__, pAdapter->device_mode);
8209 return -EINVAL;
8210 }
8211
8212 return 0;
8213}
8214
Leo Chang9056f462013-08-01 19:21:11 -07008215#ifdef WLAN_NL80211_TESTMODE
8216#ifdef FEATURE_WLAN_LPHB
8217static void wlan_hdd_cfg80211_lphb_wait_timeout_ind_handler
8218(
8219 void *pAdapter,
8220 void *indCont
8221)
8222{
8223 tSirLPHBTimeoutInd *lphbTimeoutInd;
8224 struct sk_buff *skb;
8225
8226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8227 "LPHB wait timeout indication arrived");
8228
8229 if (NULL == indCont)
8230 {
8231 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8232 "LPHB timeout, invalid argument");
8233 return;
8234 }
8235
8236 lphbTimeoutInd = (tSirLPHBTimeoutInd *)indCont;
8237 skb = cfg80211_testmode_alloc_event_skb(
8238 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
8239 sizeof(tSirLPHBTimeoutInd),
8240 GFP_ATOMIC);
8241 if (!skb)
8242 {
8243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8244 "LPHB timeout, NL buffer alloc fail");
8245 return;
8246 }
8247
8248 NLA_PUT_U32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB);
8249 NLA_PUT_U32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbTimeoutInd->protocolType);
8250 NLA_PUT(skb, WLAN_HDD_TM_ATTR_DATA,
8251 sizeof(tSirLPHBTimeoutInd), lphbTimeoutInd);
8252 cfg80211_testmode_event(skb, GFP_ATOMIC);
8253 return;
8254
8255nla_put_failure:
8256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8257 "NLA Put fail");
8258 kfree_skb(skb);
8259
8260 return;
8261}
8262#endif /* FEATURE_WLAN_LPHB */
8263
8264static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8265{
8266 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8267 int err = 0;
8268#ifdef FEATURE_WLAN_LPHB
8269 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8270#endif /* FEATURE_WLAN_LPHB */
8271
8272 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8273 if (err)
8274 {
8275 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8276 "%s Testmode INV ATTR", __func__);
8277 return err;
8278 }
8279
8280 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8281 {
8282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8283 "%s Testmode INV CMD", __func__);
8284 return -EINVAL;
8285 }
8286
8287 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8288 {
8289#ifdef FEATURE_WLAN_LPHB
8290 /* Low Power Heartbeat configuration request */
8291 case WLAN_HDD_TM_CMD_WLAN_HB:
8292 {
8293 int buf_len;
8294 void *buf;
8295 tSirLPHBReq *hb_params = NULL;
8296
8297 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8298 {
8299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8300 "%s Testmode INV DATA", __func__);
8301 return -EINVAL;
8302 }
8303
8304 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8305 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8306 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8307 if (NULL == hb_params)
8308 {
8309 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8310 "%s Request Buffer Alloc Fail", __func__);
8311 return -EINVAL;
8312 }
8313
8314 vos_mem_copy(hb_params, buf, buf_len);
8315
8316 /* LPHB enable and disable request will send to FW
8317 * when host suspend and resume
8318 * host suspend -> enable LPHB
8319 * host resume -> disable LPHB
8320 * if host is not suspend, cache into HDD context
8321 * and when host goes to suspend, send request to FW */
8322 if ((LPHB_SET_EN_PARAMS_INDID == hb_params->cmd) &&
8323 (!pHddCtx->hdd_wlan_suspended))
8324 {
8325 /* Feature enable command cache into HDD context,
8326 * if WLAN is not suspend
8327 * When WLAN goes into suspend, send enable command to FW */
8328 pHddCtx->lphbEnableReq.enable =
8329 hb_params->params.lphbEnableReq.enable;
8330 pHddCtx->lphbEnableReq.item =
8331 hb_params->params.lphbEnableReq.item;
8332 pHddCtx->lphbEnableReq.session =
8333 hb_params->params.lphbEnableReq.session;
8334 vos_mem_free(hb_params);
8335 }
8336 else
8337 {
8338 eHalStatus smeStatus;
8339
8340 /* If WLAN is suspend state, send enable command immediately */
8341 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8342 hb_params,
8343 wlan_hdd_cfg80211_lphb_wait_timeout_ind_handler);
8344 if (eHAL_STATUS_SUCCESS != smeStatus)
8345 {
8346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8347 "LPHB Config Fail, disable");
8348 pHddCtx->lphbEnableReq.enable = 0;
8349 vos_mem_free(hb_params);
8350 }
8351 }
8352 return 0;
8353 }
8354#endif /* FEATURE_WLAN_LPHB */
8355 default:
8356 return -EOPNOTSUPP;
8357 }
8358
8359 return err;
8360}
8361#endif /* CONFIG_NL80211_TESTMODE */
8362
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308363static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8364 struct net_device *dev,
8365 int idx, struct survey_info *survey)
8366{
8367 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8368 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308369 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308370 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308371 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308372 v_S7_t snr,rssi;
8373 int status, i, j, filled = 0;
8374
8375 ENTER();
8376
8377
8378 if (NULL == pAdapter)
8379 {
8380 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8381 "%s: HDD adapter is Null", __func__);
8382 return -ENODEV;
8383 }
8384
8385 if (NULL == wiphy)
8386 {
8387 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8388 "%s: wiphy is Null", __func__);
8389 return -ENODEV;
8390 }
8391
8392 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8393 status = wlan_hdd_validate_context(pHddCtx);
8394
8395 if (0 != status)
8396 {
8397 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8398 "%s: HDD context is not valid", __func__);
8399 return status;
8400 }
8401
Mihir Sheted9072e02013-08-21 17:02:29 +05308402 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8403
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308404 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308405 0 != pAdapter->survey_idx ||
8406 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308407 {
8408 /* The survey dump ops when implemented completely is expected to
8409 * return a survey of all channels and the ops is called by the
8410 * kernel with incremental values of the argument 'idx' till it
8411 * returns -ENONET. But we can only support the survey for the
8412 * operating channel for now. survey_idx is used to track
8413 * that the ops is called only once and then return -ENONET for
8414 * the next iteration
8415 */
8416 pAdapter->survey_idx = 0;
8417 return -ENONET;
8418 }
8419
8420 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8421
8422 wlan_hdd_get_snr(pAdapter, &snr);
8423 wlan_hdd_get_rssi(pAdapter, &rssi);
8424
8425 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
8426 hdd_wlan_get_freq(channel, &freq);
8427
8428
8429 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8430 {
8431 if (NULL == wiphy->bands[i])
8432 {
8433 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
8434 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
8435 continue;
8436 }
8437
8438 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8439 {
8440 struct ieee80211_supported_band *band = wiphy->bands[i];
8441
8442 if (band->channels[j].center_freq == (v_U16_t)freq)
8443 {
8444 survey->channel = &band->channels[j];
8445 /* The Rx BDs contain SNR values in dB for the received frames
8446 * while the supplicant expects noise. So we calculate and
8447 * return the value of noise (dBm)
8448 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
8449 */
8450 survey->noise = rssi - snr;
8451 survey->filled = SURVEY_INFO_NOISE_DBM;
8452 filled = 1;
8453 }
8454 }
8455 }
8456
8457 if (filled)
8458 pAdapter->survey_idx = 1;
8459 else
8460 {
8461 pAdapter->survey_idx = 0;
8462 return -ENONET;
8463 }
8464
8465 return 0;
8466}
8467
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308468/*
8469 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
8470 * this is called when cfg80211 driver resume
8471 * driver updates latest sched_scan scan result(if any) to cfg80211 database
8472 */
8473int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
8474{
8475 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8476 hdd_adapter_t *pAdapter;
8477 hdd_adapter_list_node_t *pAdapterNode, *pNext;
8478 VOS_STATUS status = VOS_STATUS_SUCCESS;
8479
8480 ENTER();
8481
8482 if ( NULL == pHddCtx )
8483 {
8484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8485 "%s: HddCtx validation failed", __func__);
8486 return 0;
8487 }
8488
8489 if (pHddCtx->isLogpInProgress)
8490 {
8491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8492 "%s: LOGP in Progress. Ignore!!!", __func__);
8493 return 0;
8494 }
8495
8496 if (pHddCtx->isLoadUnloadInProgress)
8497 {
8498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8499 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8500 return 0;
8501 }
8502
8503 spin_lock(&pHddCtx->schedScan_lock);
8504 pHddCtx->isWiphySuspended = FALSE;
8505 if (TRUE != pHddCtx->isSchedScanUpdatePending)
8506 {
8507 spin_unlock(&pHddCtx->schedScan_lock);
8508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8509 "%s: Return resume is not due to PNO indication", __func__);
8510 return 0;
8511 }
8512 // Reset flag to avoid updatating cfg80211 data old results again
8513 pHddCtx->isSchedScanUpdatePending = FALSE;
8514 spin_unlock(&pHddCtx->schedScan_lock);
8515
8516 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8517
8518 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8519 {
8520 pAdapter = pAdapterNode->pAdapter;
8521 if ( (NULL != pAdapter) &&
8522 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
8523 {
8524 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
8525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8526 "%s: NO SCAN result", __func__);
8527 else
8528 cfg80211_sched_scan_results(pHddCtx->wiphy);
8529
8530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8531 "%s : cfg80211 scan result database updated", __func__);
8532
8533 return 0;
8534
8535 }
8536 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8537 pAdapterNode = pNext;
8538 }
8539
8540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8541 "%s: Failed to find Adapter", __func__);
8542 return 0;
8543}
8544
8545/*
8546 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
8547 * this is called when cfg80211 driver suspends
8548 */
8549int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
8550 struct cfg80211_wowlan *wow)
8551{
8552 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8553
8554 ENTER();
8555 if (NULL == pHddCtx)
8556 {
8557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8558 "%s: HddCtx validation failed", __func__);
8559 return 0;
8560 }
8561
8562 pHddCtx->isWiphySuspended = TRUE;
8563
8564 EXIT();
8565
8566 return 0;
8567}
8568
Jeff Johnson295189b2012-06-20 16:38:30 -07008569/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308570static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07008571{
8572 .add_virtual_intf = wlan_hdd_add_virtual_intf,
8573 .del_virtual_intf = wlan_hdd_del_virtual_intf,
8574 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
8575 .change_station = wlan_hdd_change_station,
8576#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8577 .add_beacon = wlan_hdd_cfg80211_add_beacon,
8578 .del_beacon = wlan_hdd_cfg80211_del_beacon,
8579 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008580#else
8581 .start_ap = wlan_hdd_cfg80211_start_ap,
8582 .change_beacon = wlan_hdd_cfg80211_change_beacon,
8583 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07008584#endif
8585 .change_bss = wlan_hdd_cfg80211_change_bss,
8586 .add_key = wlan_hdd_cfg80211_add_key,
8587 .get_key = wlan_hdd_cfg80211_get_key,
8588 .del_key = wlan_hdd_cfg80211_del_key,
8589 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08008590#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008591 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08008592#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008593 .scan = wlan_hdd_cfg80211_scan,
8594 .connect = wlan_hdd_cfg80211_connect,
8595 .disconnect = wlan_hdd_cfg80211_disconnect,
8596 .join_ibss = wlan_hdd_cfg80211_join_ibss,
8597 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
8598 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
8599 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
8600 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07008601 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
8602 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
8603 .mgmt_tx = wlan_hdd_action,
8604#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8605 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
8606 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
8607 .set_txq_params = wlan_hdd_set_txq_params,
8608#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 .get_station = wlan_hdd_cfg80211_get_station,
8610 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
8611 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008612 .add_station = wlan_hdd_cfg80211_add_station,
8613#ifdef FEATURE_WLAN_LFR
8614 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
8615 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
8616 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
8617#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008618#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
8619 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
8620#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008621#ifdef FEATURE_WLAN_TDLS
8622 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
8623 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
8624#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308625#ifdef WLAN_FEATURE_GTK_OFFLOAD
8626 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
8627#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308628#ifdef FEATURE_WLAN_SCAN_PNO
8629 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
8630 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
8631#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308632 .resume = wlan_hdd_cfg80211_resume_wlan,
8633 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308634 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07008635#ifdef WLAN_NL80211_TESTMODE
8636 .testmode_cmd = wlan_hdd_cfg80211_testmode,
8637#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308638 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07008639};
8640