blob: 5c433d57e747226054960c1eb38f037222334841 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20*/
Jeff Johnson295189b2012-06-20 16:38:30 -070021
22/**========================================================================
23
24 \file wlan_hdd_cfg80211.c
25
26 \brief WLAN Host Device Driver implementation
27
Gopichand Nakkala747461f2013-04-24 19:24:45 +053028 Copyright 2008 (c) Qualcomm Technologies, Inc. All Rights Reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070029
Gopichand Nakkala747461f2013-04-24 19:24:45 +053030 Qualcomm Technologies Confidential and Proprietary.
Jeff Johnson295189b2012-06-20 16:38:30 -070031
32 ========================================================================*/
33
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070034/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070035
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070036 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070037
38
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070039 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070043 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070044
45
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070046 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070047 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070048 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070049
50 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070051 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070052 ==========================================================================*/
53
Jeff Johnson295189b2012-06-20 16:38:30 -070054
55#include <linux/version.h>
56#include <linux/module.h>
57#include <linux/kernel.h>
58#include <linux/init.h>
59#include <linux/wireless.h>
60#include <wlan_hdd_includes.h>
61#include <net/arp.h>
62#include <net/cfg80211.h>
63#include <linux/wireless.h>
64#include <wlan_hdd_wowl.h>
65#include <aniGlobal.h>
66#include "ccmApi.h"
67#include "sirParams.h"
68#include "dot11f.h"
69#include "wlan_hdd_assoc.h"
70#include "wlan_hdd_wext.h"
71#include "sme_Api.h"
72#include "wlan_hdd_p2p.h"
73#include "wlan_hdd_cfg80211.h"
74#include "wlan_hdd_hostapd.h"
75#include "sapInternal.h"
76#include "wlan_hdd_softap_tx_rx.h"
77#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053078#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053079#include "wlan_hdd_power.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070080#ifdef WLAN_BTAMP_FEATURE
81#include "bap_hdd_misc.h"
82#endif
83#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080084#ifdef FEATURE_WLAN_TDLS
85#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053086#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053087#include "wlan_qct_wda.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080088#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053089#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070090#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070091
92#define g_mode_rates_size (12)
93#define a_mode_rates_size (8)
94#define FREQ_BASE_80211G (2407)
95#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070096#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +053097#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -070098#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
99 ((int) OFFSET_OF( tSirBssDescription, ieFields)))
100
101#define HDD2GHZCHAN(freq, chan, flag) { \
102 .band = IEEE80211_BAND_2GHZ, \
103 .center_freq = (freq), \
104 .hw_value = (chan),\
105 .flags = (flag), \
106 .max_antenna_gain = 0 ,\
107 .max_power = 30, \
108}
109
110#define HDD5GHZCHAN(freq, chan, flag) { \
111 .band = IEEE80211_BAND_5GHZ, \
112 .center_freq = (freq), \
113 .hw_value = (chan),\
114 .flags = (flag), \
115 .max_antenna_gain = 0 ,\
116 .max_power = 30, \
117}
118
119#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
120{\
121 .bitrate = rate, \
122 .hw_value = rate_id, \
123 .flags = flag, \
124}
125
Lee Hoonkic1262f22013-01-24 21:59:00 -0800126#ifndef WLAN_FEATURE_TDLS_DEBUG
127#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
128#else
129#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
130#endif
131
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530132#ifdef WLAN_FEATURE_VOWIFI_11R
133#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
134#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
135#endif
136
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530137static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700138{
139 WLAN_CIPHER_SUITE_WEP40,
140 WLAN_CIPHER_SUITE_WEP104,
141 WLAN_CIPHER_SUITE_TKIP,
142#ifdef FEATURE_WLAN_CCX
143#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
144 WLAN_CIPHER_SUITE_KRK,
145 WLAN_CIPHER_SUITE_CCMP,
146#else
147 WLAN_CIPHER_SUITE_CCMP,
148#endif
149#ifdef FEATURE_WLAN_WAPI
150 WLAN_CIPHER_SUITE_SMS4,
151#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700152#ifdef WLAN_FEATURE_11W
153 WLAN_CIPHER_SUITE_AES_CMAC,
154#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700155};
156
157static inline int is_broadcast_ether_addr(const u8 *addr)
158{
159 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
160 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
161}
162
163static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530164{
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 HDD2GHZCHAN(2412, 1, 0) ,
166 HDD2GHZCHAN(2417, 2, 0) ,
167 HDD2GHZCHAN(2422, 3, 0) ,
168 HDD2GHZCHAN(2427, 4, 0) ,
169 HDD2GHZCHAN(2432, 5, 0) ,
170 HDD2GHZCHAN(2437, 6, 0) ,
171 HDD2GHZCHAN(2442, 7, 0) ,
172 HDD2GHZCHAN(2447, 8, 0) ,
173 HDD2GHZCHAN(2452, 9, 0) ,
174 HDD2GHZCHAN(2457, 10, 0) ,
175 HDD2GHZCHAN(2462, 11, 0) ,
176 HDD2GHZCHAN(2467, 12, 0) ,
177 HDD2GHZCHAN(2472, 13, 0) ,
178 HDD2GHZCHAN(2484, 14, 0) ,
179};
180
Jeff Johnson295189b2012-06-20 16:38:30 -0700181static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
182{
183 HDD2GHZCHAN(2412, 1, 0) ,
184 HDD2GHZCHAN(2437, 6, 0) ,
185 HDD2GHZCHAN(2462, 11, 0) ,
186};
Jeff Johnson295189b2012-06-20 16:38:30 -0700187
188static struct ieee80211_channel hdd_channels_5_GHZ[] =
189{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700190 HDD5GHZCHAN(4920, 240, 0) ,
191 HDD5GHZCHAN(4940, 244, 0) ,
192 HDD5GHZCHAN(4960, 248, 0) ,
193 HDD5GHZCHAN(4980, 252, 0) ,
194 HDD5GHZCHAN(5040, 208, 0) ,
195 HDD5GHZCHAN(5060, 212, 0) ,
196 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700197 HDD5GHZCHAN(5180, 36, 0) ,
198 HDD5GHZCHAN(5200, 40, 0) ,
199 HDD5GHZCHAN(5220, 44, 0) ,
200 HDD5GHZCHAN(5240, 48, 0) ,
201 HDD5GHZCHAN(5260, 52, 0) ,
202 HDD5GHZCHAN(5280, 56, 0) ,
203 HDD5GHZCHAN(5300, 60, 0) ,
204 HDD5GHZCHAN(5320, 64, 0) ,
205 HDD5GHZCHAN(5500,100, 0) ,
206 HDD5GHZCHAN(5520,104, 0) ,
207 HDD5GHZCHAN(5540,108, 0) ,
208 HDD5GHZCHAN(5560,112, 0) ,
209 HDD5GHZCHAN(5580,116, 0) ,
210 HDD5GHZCHAN(5600,120, 0) ,
211 HDD5GHZCHAN(5620,124, 0) ,
212 HDD5GHZCHAN(5640,128, 0) ,
213 HDD5GHZCHAN(5660,132, 0) ,
214 HDD5GHZCHAN(5680,136, 0) ,
215 HDD5GHZCHAN(5700,140, 0) ,
216 HDD5GHZCHAN(5745,149, 0) ,
217 HDD5GHZCHAN(5765,153, 0) ,
218 HDD5GHZCHAN(5785,157, 0) ,
219 HDD5GHZCHAN(5805,161, 0) ,
220 HDD5GHZCHAN(5825,165, 0) ,
221};
222
223static struct ieee80211_rate g_mode_rates[] =
224{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530225 HDD_G_MODE_RATETAB(10, 0x1, 0),
226 HDD_G_MODE_RATETAB(20, 0x2, 0),
227 HDD_G_MODE_RATETAB(55, 0x4, 0),
228 HDD_G_MODE_RATETAB(110, 0x8, 0),
229 HDD_G_MODE_RATETAB(60, 0x10, 0),
230 HDD_G_MODE_RATETAB(90, 0x20, 0),
231 HDD_G_MODE_RATETAB(120, 0x40, 0),
232 HDD_G_MODE_RATETAB(180, 0x80, 0),
233 HDD_G_MODE_RATETAB(240, 0x100, 0),
234 HDD_G_MODE_RATETAB(360, 0x200, 0),
235 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530237};
Jeff Johnson295189b2012-06-20 16:38:30 -0700238
239static struct ieee80211_rate a_mode_rates[] =
240{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530241 HDD_G_MODE_RATETAB(60, 0x10, 0),
242 HDD_G_MODE_RATETAB(90, 0x20, 0),
243 HDD_G_MODE_RATETAB(120, 0x40, 0),
244 HDD_G_MODE_RATETAB(180, 0x80, 0),
245 HDD_G_MODE_RATETAB(240, 0x100, 0),
246 HDD_G_MODE_RATETAB(360, 0x200, 0),
247 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 HDD_G_MODE_RATETAB(540, 0x800, 0),
249};
250
251static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
252{
253 .channels = hdd_channels_2_4_GHZ,
254 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
255 .band = IEEE80211_BAND_2GHZ,
256 .bitrates = g_mode_rates,
257 .n_bitrates = g_mode_rates_size,
258 .ht_cap.ht_supported = 1,
259 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
260 | IEEE80211_HT_CAP_GRN_FLD
261 | IEEE80211_HT_CAP_DSSSCCK40
262 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
263 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
264 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
265 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
266 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
267 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
268};
269
Jeff Johnson295189b2012-06-20 16:38:30 -0700270static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
271{
272 .channels = hdd_social_channels_2_4_GHZ,
273 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
274 .band = IEEE80211_BAND_2GHZ,
275 .bitrates = g_mode_rates,
276 .n_bitrates = g_mode_rates_size,
277 .ht_cap.ht_supported = 1,
278 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
279 | IEEE80211_HT_CAP_GRN_FLD
280 | IEEE80211_HT_CAP_DSSSCCK40
281 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
282 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
283 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
284 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
285 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
286 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
287};
Jeff Johnson295189b2012-06-20 16:38:30 -0700288
289static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
290{
291 .channels = hdd_channels_5_GHZ,
292 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
293 .band = IEEE80211_BAND_5GHZ,
294 .bitrates = a_mode_rates,
295 .n_bitrates = a_mode_rates_size,
296 .ht_cap.ht_supported = 1,
297 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
298 | IEEE80211_HT_CAP_GRN_FLD
299 | IEEE80211_HT_CAP_DSSSCCK40
300 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
301 | IEEE80211_HT_CAP_SGI_40
302 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
303 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
304 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
305 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
306 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
307 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
308};
309
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530310/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700311 TX/RX direction for each kind of interface */
312static const struct ieee80211_txrx_stypes
313wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
314 [NL80211_IFTYPE_STATION] = {
315 .tx = 0xffff,
316 .rx = BIT(SIR_MAC_MGMT_ACTION) |
317 BIT(SIR_MAC_MGMT_PROBE_REQ),
318 },
319 [NL80211_IFTYPE_AP] = {
320 .tx = 0xffff,
321 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
322 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
323 BIT(SIR_MAC_MGMT_PROBE_REQ) |
324 BIT(SIR_MAC_MGMT_DISASSOC) |
325 BIT(SIR_MAC_MGMT_AUTH) |
326 BIT(SIR_MAC_MGMT_DEAUTH) |
327 BIT(SIR_MAC_MGMT_ACTION),
328 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700329 [NL80211_IFTYPE_ADHOC] = {
330 .tx = 0xffff,
331 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
332 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
333 BIT(SIR_MAC_MGMT_PROBE_REQ) |
334 BIT(SIR_MAC_MGMT_DISASSOC) |
335 BIT(SIR_MAC_MGMT_AUTH) |
336 BIT(SIR_MAC_MGMT_DEAUTH) |
337 BIT(SIR_MAC_MGMT_ACTION),
338 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 [NL80211_IFTYPE_P2P_CLIENT] = {
340 .tx = 0xffff,
341 .rx = BIT(SIR_MAC_MGMT_ACTION) |
342 BIT(SIR_MAC_MGMT_PROBE_REQ),
343 },
344 [NL80211_IFTYPE_P2P_GO] = {
345 /* This is also same as for SoftAP */
346 .tx = 0xffff,
347 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
348 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
349 BIT(SIR_MAC_MGMT_PROBE_REQ) |
350 BIT(SIR_MAC_MGMT_DISASSOC) |
351 BIT(SIR_MAC_MGMT_AUTH) |
352 BIT(SIR_MAC_MGMT_DEAUTH) |
353 BIT(SIR_MAC_MGMT_ACTION),
354 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700355};
356
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800357#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800358static const struct ieee80211_iface_limit
359wlan_hdd_iface_limit[] = {
360 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800361 /* max = 3 ; Our driver create two interfaces during driver init
362 * wlan0 and p2p0 interfaces. p2p0 is considered as station
363 * interface until a group is formed. In JB architecture, once the
364 * group is formed, interface type of p2p0 is changed to P2P GO or
365 * Client.
366 * When supplicant remove the group, it first issue a set interface
367 * cmd to change the mode back to Station. In JB this works fine as
368 * we advertize two station type interface during driver init.
369 * Some vendors create separate interface for P2P GO/Client,
370 * after group formation(Third one). But while group remove
371 * supplicant first tries to change the mode(3rd interface) to STATION
372 * But as we advertized only two sta type interfaces nl80211 was
373 * returning error for the third one which was leading to failure in
374 * delete interface. Ideally while removing the group, supplicant
375 * should not try to change the 3rd interface mode to Station type.
376 * Till we get a fix in wpa_supplicant, we advertize max STA
377 * interface type to 3
378 */
379 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800380 .types = BIT(NL80211_IFTYPE_STATION),
381 },
382 {
383 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700384 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800385 },
386 {
387 .max = 1,
388 .types = BIT(NL80211_IFTYPE_P2P_GO) |
389 BIT(NL80211_IFTYPE_P2P_CLIENT),
390 },
391};
392
393/* By default, only single channel concurrency is allowed */
394static struct ieee80211_iface_combination
395wlan_hdd_iface_combination = {
396 .limits = wlan_hdd_iface_limit,
397 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800398 /*
399 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
400 * and p2p0 interfaces during driver init
401 * Some vendors create separate interface for P2P operations.
402 * wlan0: STA interface
403 * p2p0: P2P Device interface, action frames goes
404 * through this interface.
405 * p2p-xx: P2P interface, After GO negotiation this interface is
406 * created for p2p operations(GO/CLIENT interface).
407 */
408 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800409 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
410 .beacon_int_infra_match = false,
411};
412#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800413
Jeff Johnson295189b2012-06-20 16:38:30 -0700414static struct cfg80211_ops wlan_hdd_cfg80211_ops;
415
416/* Data rate 100KBPS based on IE Index */
417struct index_data_rate_type
418{
419 v_U8_t beacon_rate_index;
420 v_U16_t supported_rate[4];
421};
422
423/* 11B, 11G Rate table include Basic rate and Extended rate
424 The IDX field is the rate index
425 The HI field is the rate when RSSI is strong or being ignored
426 (in this case we report actual rate)
427 The MID field is the rate when RSSI is moderate
428 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
429 The LO field is the rate when RSSI is low
430 (in this case we don't report rates, actual current rate used)
431 */
432static const struct
433{
434 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700435 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700436} supported_data_rate[] =
437{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700438/* IDX HI HM LM LO (RSSI-based index */
439 {2, { 10, 10, 10, 0}},
440 {4, { 20, 20, 10, 0}},
441 {11, { 55, 20, 10, 0}},
442 {12, { 60, 55, 20, 0}},
443 {18, { 90, 55, 20, 0}},
444 {22, {110, 55, 20, 0}},
445 {24, {120, 90, 60, 0}},
446 {36, {180, 120, 60, 0}},
447 {44, {220, 180, 60, 0}},
448 {48, {240, 180, 90, 0}},
449 {66, {330, 180, 90, 0}},
450 {72, {360, 240, 90, 0}},
451 {96, {480, 240, 120, 0}},
452 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700453};
454
455/* MCS Based rate table */
456static struct index_data_rate_type supported_mcs_rate[] =
457{
458/* MCS L20 L40 S20 S40 */
459 {0, {65, 135, 72, 150}},
460 {1, {130, 270, 144, 300}},
461 {2, {195, 405, 217, 450}},
462 {3, {260, 540, 289, 600}},
463 {4, {390, 810, 433, 900}},
464 {5, {520, 1080, 578, 1200}},
465 {6, {585, 1215, 650, 1350}},
466 {7, {650, 1350, 722, 1500}}
467};
468
Leo Chang6f8870f2013-03-26 18:11:36 -0700469#ifdef WLAN_FEATURE_11AC
470
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530471#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700472
473struct index_vht_data_rate_type
474{
475 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530476 v_U16_t supported_VHT80_rate[2];
477 v_U16_t supported_VHT40_rate[2];
478 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700479};
480
481typedef enum
482{
483 DATA_RATE_11AC_MAX_MCS_7,
484 DATA_RATE_11AC_MAX_MCS_8,
485 DATA_RATE_11AC_MAX_MCS_9,
486 DATA_RATE_11AC_MAX_MCS_NA
487} eDataRate11ACMaxMcs;
488
489/* MCS Based VHT rate table */
490static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
491{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530492/* MCS L80 S80 L40 S40 L20 S40*/
493 {0, {293, 325}, {135, 150}, {65, 72}},
494 {1, {585, 650}, {270, 300}, {130, 144}},
495 {2, {878, 975}, {405, 450}, {195, 217}},
496 {3, {1170, 1300}, {540, 600}, {260, 289}},
497 {4, {1755, 1950}, {810, 900}, {390, 433}},
498 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
499 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
500 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
501 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
502 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700503};
504#endif /* WLAN_FEATURE_11AC */
505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506extern struct net_device_ops net_ops_struct;
507
Leo Chang9056f462013-08-01 19:21:11 -0700508#ifdef WLAN_NL80211_TESTMODE
509enum wlan_hdd_tm_attr
510{
511 WLAN_HDD_TM_ATTR_INVALID = 0,
512 WLAN_HDD_TM_ATTR_CMD = 1,
513 WLAN_HDD_TM_ATTR_DATA = 2,
514 WLAN_HDD_TM_ATTR_TYPE = 3,
515 /* keep last */
516 WLAN_HDD_TM_ATTR_AFTER_LAST,
517 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
518};
519
520enum wlan_hdd_tm_cmd
521{
522 WLAN_HDD_TM_CMD_WLAN_HB = 1,
523};
524
525#define WLAN_HDD_TM_DATA_MAX_LEN 5000
526
527static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
528{
529 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
530 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
531 .len = WLAN_HDD_TM_DATA_MAX_LEN },
532};
533#endif /* WLAN_NL80211_TESTMODE */
534
Jeff Johnson295189b2012-06-20 16:38:30 -0700535/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530536 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530537 * This function is called by hdd_wlan_startup()
538 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530539 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530541struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -0700542{
543 struct wiphy *wiphy;
544 ENTER();
545
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530546 /*
547 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 */
549 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
550
551 if (!wiphy)
552 {
553 /* Print error and jump into err label and free the memory */
554 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
555 return NULL;
556 }
557
558 return wiphy;
559}
560
561/*
562 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530563 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 * private ioctl to change the band value
565 */
566int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
567{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530568 int i, j;
569 eNVChannelEnabledType channelEnabledState;
570
Jeff Johnsone7245742012-09-05 17:12:55 -0700571 ENTER();
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530572 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530574
575 if (NULL == wiphy->bands[i])
576 {
577 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
578 __func__, i);
579 continue;
580 }
581
582 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
583 {
584 struct ieee80211_supported_band *band = wiphy->bands[i];
585
586 channelEnabledState = vos_nv_getChannelEnabledState(
587 band->channels[j].hw_value);
588
589 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
590 {
591 // Enable Social channels for P2P
592 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
593 NV_CHANNEL_ENABLE == channelEnabledState)
594 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
595 else
596 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
597 continue;
598 }
599 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
600 {
601 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
602 continue;
603 }
604
605 if (NV_CHANNEL_DISABLE == channelEnabledState ||
606 NV_CHANNEL_INVALID == channelEnabledState)
607 {
608 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
609 }
610 else if (NV_CHANNEL_DFS == channelEnabledState)
611 {
612 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
613 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
614 }
615 else
616 {
617 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
618 |IEEE80211_CHAN_RADAR);
619 }
620 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700621 }
622 return 0;
623}
624/*
625 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530626 * This function is called by hdd_wlan_startup()
627 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 * This function is used to initialize and register wiphy structure.
629 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530630int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 struct wiphy *wiphy,
632 hdd_config_t *pCfg
633 )
634{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530635 int i, j;
Jeff Johnsone7245742012-09-05 17:12:55 -0700636 ENTER();
637
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 /* Now bind the underlying wlan device with wiphy */
639 set_wiphy_dev(wiphy, dev);
640
641 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700642
Kiet Lam6c583332013-10-14 05:37:09 +0530643#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -0700644 /* the flag for the other case would be initialzed in
645 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -0700646 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +0530647#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700648
Amar Singhalfddc28c2013-09-05 13:03:40 -0700649 /* This will disable updating of NL channels from passive to
650 * active if a beacon is received on passive channel. */
651 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -0700652
Amar Singhalfddc28c2013-09-05 13:03:40 -0700653
Amar Singhala49cbc52013-10-08 18:37:44 -0700654
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700655#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700656 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
657 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
658 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700659 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +0530660 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700661#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700662
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700663#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
664 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800665#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700666 || pCfg->isFastRoamIniFeatureEnabled
667#endif
668#ifdef FEATURE_WLAN_CCX
669 || pCfg->isCcxIniFeatureEnabled
670#endif
671 )
672 {
673 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
674 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800675#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800676#ifdef FEATURE_WLAN_TDLS
677 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
678 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
679#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530680#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +0530681 if (pCfg->configPNOScanSupport)
682 {
683 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
684 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
685 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
686 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
687 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530688#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800689
Amar Singhalfddc28c2013-09-05 13:03:40 -0700690#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700691 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
692 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -0700693 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700694 driver need to determine what to do with both
695 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -0700696
697 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -0700698#else
699 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700700#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700701
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530702 wiphy->max_scan_ssids = MAX_SCAN_SSID;
703
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530704 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700705
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530706 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
707
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530709 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 | BIT(NL80211_IFTYPE_P2P_CLIENT)
712 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 | BIT(NL80211_IFTYPE_AP);
714
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800715#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800716 if( pCfg->enableMCC )
717 {
718 /* Currently, supports up to two channels */
719 wlan_hdd_iface_combination.num_different_channels = 2;
720
721 if( !pCfg->allowMCCGODiffBI )
722 wlan_hdd_iface_combination.beacon_int_infra_match = true;
723
724 }
725 wiphy->iface_combinations = &wlan_hdd_iface_combination;
726 wiphy->n_iface_combinations = 1;
727#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800728
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 /* Before registering we need to update the ht capabilitied based
730 * on ini values*/
731 if( !pCfg->ShortGI20MhzEnable )
732 {
733 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
734 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
735 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
736 }
737
738 if( !pCfg->ShortGI40MhzEnable )
739 {
740 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
741 }
742
743 if( !pCfg->nChannelBondingMode5GHz )
744 {
745 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
746 }
747
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530748 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
749 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
750
751 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
752 {
753
754 if (NULL == wiphy->bands[i])
755 {
756 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
757 __func__, i);
758 continue;
759 }
760
761 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
762 {
763 struct ieee80211_supported_band *band = wiphy->bands[i];
764
765 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
766 {
767 // Enable social channels for P2P
768 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
769 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
770 else
771 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
772 continue;
773 }
774 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
775 {
776 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
777 continue;
778 }
779 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700780 }
781 /*Initialise the supported cipher suite details*/
782 wiphy->cipher_suites = hdd_cipher_suites;
783 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
784
785 /*signal strength in mBm (100*dBm) */
786 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
787
788#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 wiphy->max_remain_on_channel_duration = 1000;
790#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700791
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530792 EXIT();
793 return 0;
794}
795
796/* In this function we are registering wiphy. */
797int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
798{
799 ENTER();
800 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 if (0 > wiphy_register(wiphy))
802 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530803 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
805 return -EIO;
806 }
807
808 EXIT();
809 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530810}
Jeff Johnson295189b2012-06-20 16:38:30 -0700811
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530812/* In this function we are updating channel list when,
813 regulatory domain is FCC and country code is US.
814 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
815 As per FCC smart phone is not a indoor device.
816 GO should not opeate on indoor channels */
817void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
818{
819 int j;
820 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
821 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
822 //Default counrtycode from NV at the time of wiphy initialization.
823 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
824 &defaultCountryCode[0]))
825 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700826 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530827 }
828 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
829 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530830 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
831 {
832 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
833 return;
834 }
835 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
836 {
837 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
838 // Mark UNII -1 band channel as passive
839 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
840 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
841 }
842 }
843}
844
Jeff Johnson295189b2012-06-20 16:38:30 -0700845/* In this function we will do all post VOS start initialization.
846 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530847 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700848*/
849void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
850{
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
852 /* Register for all P2P action, public action etc frames */
853 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
854
Jeff Johnsone7245742012-09-05 17:12:55 -0700855 ENTER();
856
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 /* Right now we are registering these frame when driver is getting
858 initialized. Once we will move to 2.6.37 kernel, in which we have
859 frame register ops, we will move this code as a part of that */
860 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530861 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
863
864 /* GAS Initial Response */
865 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
866 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530867
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 /* GAS Comeback Request */
869 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
870 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
871
872 /* GAS Comeback Response */
873 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
874 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
875
876 /* P2P Public Action */
877 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530878 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 P2P_PUBLIC_ACTION_FRAME_SIZE );
880
881 /* P2P Action */
882 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
883 (v_U8_t*)P2P_ACTION_FRAME,
884 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700885
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530886 /* WNM BSS Transition Request frame */
887 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
888 (v_U8_t*)WNM_BSS_ACTION_FRAME,
889 WNM_BSS_ACTION_FRAME_SIZE );
890
Chet Lanctot186b5732013-03-18 10:26:30 -0700891#ifdef WLAN_FEATURE_11W
892 /* SA Query Response Action Frame */
893 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
894 (v_U8_t*)SA_QUERY_FRAME_RSP,
895 SA_QUERY_FRAME_RSP_SIZE );
896#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700897}
898
899void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
900{
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
902 /* Register for all P2P action, public action etc frames */
903 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
904
Jeff Johnsone7245742012-09-05 17:12:55 -0700905 ENTER();
906
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 /* Right now we are registering these frame when driver is getting
908 initialized. Once we will move to 2.6.37 kernel, in which we have
909 frame register ops, we will move this code as a part of that */
910 /* GAS Initial Request */
911
912 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
913 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
914
915 /* GAS Initial Response */
916 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
917 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530918
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 /* GAS Comeback Request */
920 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
921 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
922
923 /* GAS Comeback Response */
924 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
925 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
926
927 /* P2P Public Action */
928 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530929 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 P2P_PUBLIC_ACTION_FRAME_SIZE );
931
932 /* P2P Action */
933 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
934 (v_U8_t*)P2P_ACTION_FRAME,
935 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700936
937#ifdef WLAN_FEATURE_11W
938 /* SA Query Response Action Frame */
939 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
940 (v_U8_t*)SA_QUERY_FRAME_RSP,
941 SA_QUERY_FRAME_RSP_SIZE );
942#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700943}
944
945#ifdef FEATURE_WLAN_WAPI
946void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
947 const u8 *mac_addr, u8 *key , int key_Len)
948{
949 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
950 tCsrRoamSetKey setKey;
951 v_BOOL_t isConnected = TRUE;
952 int status = 0;
953 v_U32_t roamId= 0xFF;
954 tANI_U8 *pKeyPtr = NULL;
955 int n = 0;
956
957 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
958 __func__,pAdapter->device_mode);
959
Gopichand Nakkalae7480202013-02-11 15:24:22 +0530960 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 setKey.keyId = key_index; // Store Key ID
962 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
963 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
964 setKey.paeRole = 0 ; // the PAE role
965 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
966 {
967 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
968 }
969 else
970 {
971 isConnected = hdd_connIsConnected(pHddStaCtx);
972 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
973 }
974 setKey.keyLength = key_Len;
975 pKeyPtr = setKey.Key;
976 memcpy( pKeyPtr, key, key_Len);
977
978 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
979 __func__, key_Len);
980 for (n = 0 ; n < key_Len; n++)
981 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
982 __func__,n,setKey.Key[n]);
983
984 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
985 if ( isConnected )
986 {
987 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
988 pAdapter->sessionId, &setKey, &roamId );
989 }
990 if ( status != 0 )
991 {
992 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
993 "[%4d] sme_RoamSetKey returned ERROR status= %d",
994 __LINE__, status );
995 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
996 }
997}
998#endif /* FEATURE_WLAN_WAPI*/
999
1000#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301001int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001002 beacon_data_t **ppBeacon,
1003 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001004#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301005int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001006 beacon_data_t **ppBeacon,
1007 struct cfg80211_beacon_data *params,
1008 int dtim_period)
1009#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301010{
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 int size;
1012 beacon_data_t *beacon = NULL;
1013 beacon_data_t *old = NULL;
1014 int head_len,tail_len;
1015
Jeff Johnsone7245742012-09-05 17:12:55 -07001016 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 if (params->head && !params->head_len)
1018 return -EINVAL;
1019
1020 old = pAdapter->sessionCtx.ap.beacon;
1021
1022 if (!params->head && !old)
1023 return -EINVAL;
1024
Jeff Johnson295189b2012-06-20 16:38:30 -07001025#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1026 /* Kernel 3.0 is not updating dtim_period for set beacon */
1027 if (!params->dtim_period)
1028 return -EINVAL;
1029#endif
1030
1031 if(params->head)
1032 head_len = params->head_len;
1033 else
1034 head_len = old->head_len;
1035
1036 if(params->tail || !old)
1037 tail_len = params->tail_len;
1038 else
1039 tail_len = old->tail_len;
1040
1041 size = sizeof(beacon_data_t) + head_len + tail_len;
1042
1043 beacon = kzalloc(size, GFP_KERNEL);
1044
1045 if( beacon == NULL )
1046 return -ENOMEM;
1047
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001048#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001049 if(params->dtim_period || !old )
1050 beacon->dtim_period = params->dtim_period;
1051 else
1052 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001053#else
1054 if(dtim_period || !old )
1055 beacon->dtim_period = dtim_period;
1056 else
1057 beacon->dtim_period = old->dtim_period;
1058#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301059
Jeff Johnson295189b2012-06-20 16:38:30 -07001060 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1061 beacon->tail = beacon->head + head_len;
1062 beacon->head_len = head_len;
1063 beacon->tail_len = tail_len;
1064
1065 if(params->head) {
1066 memcpy (beacon->head,params->head,beacon->head_len);
1067 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301068 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 if(old)
1070 memcpy (beacon->head,old->head,beacon->head_len);
1071 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301072
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 if(params->tail) {
1074 memcpy (beacon->tail,params->tail,beacon->tail_len);
1075 }
1076 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301077 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 memcpy (beacon->tail,old->tail,beacon->tail_len);
1079 }
1080
1081 *ppBeacon = beacon;
1082
1083 kfree(old);
1084
1085 return 0;
1086
1087}
Jeff Johnson295189b2012-06-20 16:38:30 -07001088
1089v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1090{
1091 int left = length;
1092 v_U8_t *ptr = pIes;
1093 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301094
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301096 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 elem_id = ptr[0];
1098 elem_len = ptr[1];
1099 left -= 2;
1100 if(elem_len > left)
1101 {
1102 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001103 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 eid,elem_len,left);
1105 return NULL;
1106 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301107 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 {
1109 return ptr;
1110 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301111
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 left -= elem_len;
1113 ptr += (elem_len + 2);
1114 }
1115 return NULL;
1116}
1117
Jeff Johnson295189b2012-06-20 16:38:30 -07001118/* Check if rate is 11g rate or not */
1119static int wlan_hdd_rate_is_11g(u8 rate)
1120{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001121 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 u8 i;
1123 for (i = 0; i < 8; i++)
1124 {
1125 if(rate == gRateArray[i])
1126 return TRUE;
1127 }
1128 return FALSE;
1129}
1130
1131/* Check for 11g rate and set proper 11g only mode */
1132static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1133 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1134{
1135 u8 i, num_rates = pIe[0];
1136
1137 pIe += 1;
1138 for ( i = 0; i < num_rates; i++)
1139 {
1140 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1141 {
1142 /* If rate set have 11g rate than change the mode to 11G */
1143 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1144 if (pIe[i] & BASIC_RATE_MASK)
1145 {
1146 /* If we have 11g rate as basic rate, it means mode
1147 is 11g only mode.
1148 */
1149 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1150 *pCheckRatesfor11g = FALSE;
1151 }
1152 }
1153 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1154 {
1155 *require_ht = TRUE;
1156 }
1157 }
1158 return;
1159}
1160
1161static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1162{
1163 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1164 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1165 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1166 u8 checkRatesfor11g = TRUE;
1167 u8 require_ht = FALSE;
1168 u8 *pIe=NULL;
1169
1170 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1171
1172 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1173 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1174 if (pIe != NULL)
1175 {
1176 pIe += 1;
1177 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1178 &pConfig->SapHw_mode);
1179 }
1180
1181 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1182 WLAN_EID_EXT_SUPP_RATES);
1183 if (pIe != NULL)
1184 {
1185
1186 pIe += 1;
1187 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1188 &pConfig->SapHw_mode);
1189 }
1190
1191 if( pConfig->channel > 14 )
1192 {
1193 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1194 }
1195
1196 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1197 WLAN_EID_HT_CAPABILITY);
1198
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301199 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 {
1201 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1202 if(require_ht)
1203 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1204 }
1205}
1206
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301207static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1208 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1209{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001210 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301211 v_U8_t *pIe = NULL;
1212 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1213
1214 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1215 pBeacon->tail, pBeacon->tail_len);
1216
1217 if (pIe)
1218 {
1219 ielen = pIe[1] + 2;
1220 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1221 {
1222 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1223 }
1224 else
1225 {
1226 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1227 return -EINVAL;
1228 }
1229 *total_ielen += ielen;
1230 }
1231 return 0;
1232}
1233
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001234static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
1235 v_U8_t *genie, v_U8_t *total_ielen)
1236{
1237 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1238 int left = pBeacon->tail_len;
1239 v_U8_t *ptr = pBeacon->tail;
1240 v_U8_t elem_id, elem_len;
1241 v_U16_t ielen = 0;
1242
1243 if ( NULL == ptr || 0 == left )
1244 return;
1245
1246 while (left >= 2)
1247 {
1248 elem_id = ptr[0];
1249 elem_len = ptr[1];
1250 left -= 2;
1251 if (elem_len > left)
1252 {
1253 hddLog( VOS_TRACE_LEVEL_ERROR,
1254 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
1255 elem_id, elem_len, left);
1256 return;
1257 }
1258 if (IE_EID_VENDOR == elem_id)
1259 {
1260 /* skipping the VSIE's which we don't want to include or
1261 * it will be included by existing code
1262 */
1263 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
1264#ifdef WLAN_FEATURE_WFD
1265 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
1266#endif
1267 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1268 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1269 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
1270 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1271 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
1272 {
1273 ielen = ptr[1] + 2;
1274 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1275 {
1276 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
1277 *total_ielen += ielen;
1278 }
1279 else
1280 {
1281 hddLog( VOS_TRACE_LEVEL_ERROR,
1282 "IE Length is too big "
1283 "IEs eid=%d elem_len=%d total_ie_lent=%d",
1284 elem_id, elem_len, *total_ielen);
1285 }
1286 }
1287 }
1288
1289 left -= elem_len;
1290 ptr += (elem_len + 2);
1291 }
1292 return;
1293}
1294
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001295#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001296static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1297 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001298#else
1299static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1300 struct cfg80211_beacon_data *params)
1301#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001302{
1303 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301304 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001306 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001307
1308 genie = vos_mem_malloc(MAX_GENIE_LEN);
1309
1310 if(genie == NULL) {
1311
1312 return -ENOMEM;
1313 }
1314
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301315 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1316 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301318 ret = -EINVAL;
1319 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 }
1321
1322#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301323 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1324 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1325 {
1326 ret = -EINVAL;
1327 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 }
1329#endif
1330
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301331 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1332 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301334 ret = -EINVAL;
1335 goto done;
1336 }
1337
1338 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1339 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001340 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001342
1343 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1344 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1345 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1346 {
1347 hddLog(LOGE,
1348 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001349 ret = -EINVAL;
1350 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 }
1352
1353 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1354 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1355 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1356 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1357 ==eHAL_STATUS_FAILURE)
1358 {
1359 hddLog(LOGE,
1360 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001361 ret = -EINVAL;
1362 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 }
1364
1365 // Added for ProResp IE
1366 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1367 {
1368 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1369 u8 probe_rsp_ie_len[3] = {0};
1370 u8 counter = 0;
1371 /* Check Probe Resp Length if it is greater then 255 then Store
1372 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1373 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1374 Store More then 255 bytes into One Variable.
1375 */
1376 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1377 {
1378 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1379 {
1380 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1381 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1382 }
1383 else
1384 {
1385 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1386 rem_probe_resp_ie_len = 0;
1387 }
1388 }
1389
1390 rem_probe_resp_ie_len = 0;
1391
1392 if (probe_rsp_ie_len[0] > 0)
1393 {
1394 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1395 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1396 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1397 probe_rsp_ie_len[0], NULL,
1398 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1399 {
1400 hddLog(LOGE,
1401 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001402 ret = -EINVAL;
1403 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 }
1405 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1406 }
1407
1408 if (probe_rsp_ie_len[1] > 0)
1409 {
1410 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1411 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1412 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1413 probe_rsp_ie_len[1], NULL,
1414 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1415 {
1416 hddLog(LOGE,
1417 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001418 ret = -EINVAL;
1419 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 }
1421 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1422 }
1423
1424 if (probe_rsp_ie_len[2] > 0)
1425 {
1426 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1427 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1428 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1429 probe_rsp_ie_len[2], NULL,
1430 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1431 {
1432 hddLog(LOGE,
1433 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001434 ret = -EINVAL;
1435 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 }
1437 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1438 }
1439
1440 if (probe_rsp_ie_len[1] == 0 )
1441 {
1442 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1443 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1444 eANI_BOOLEAN_FALSE) )
1445 {
1446 hddLog(LOGE,
1447 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1448 }
1449 }
1450
1451 if (probe_rsp_ie_len[2] == 0 )
1452 {
1453 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1454 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1455 eANI_BOOLEAN_FALSE) )
1456 {
1457 hddLog(LOGE,
1458 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1459 }
1460 }
1461
1462 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1463 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1464 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1465 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1466 == eHAL_STATUS_FAILURE)
1467 {
1468 hddLog(LOGE,
1469 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001470 ret = -EINVAL;
1471 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 }
1473 }
1474 else
1475 {
1476 // Reset WNI_CFG_PROBE_RSP Flags
1477 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1478
1479 hddLog(VOS_TRACE_LEVEL_INFO,
1480 "%s: No Probe Response IE received in set beacon",
1481 __func__);
1482 }
1483
1484 // Added for AssocResp IE
1485 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1486 {
1487 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1488 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1489 params->assocresp_ies_len, NULL,
1490 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1491 {
1492 hddLog(LOGE,
1493 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001494 ret = -EINVAL;
1495 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 }
1497
1498 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1499 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1500 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1501 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1502 == eHAL_STATUS_FAILURE)
1503 {
1504 hddLog(LOGE,
1505 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001506 ret = -EINVAL;
1507 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 }
1509 }
1510 else
1511 {
1512 hddLog(VOS_TRACE_LEVEL_INFO,
1513 "%s: No Assoc Response IE received in set beacon",
1514 __func__);
1515
1516 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1517 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1518 eANI_BOOLEAN_FALSE) )
1519 {
1520 hddLog(LOGE,
1521 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1522 }
1523 }
1524
Jeff Johnsone7245742012-09-05 17:12:55 -07001525done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301527 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001528}
Jeff Johnson295189b2012-06-20 16:38:30 -07001529
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301530/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 * FUNCTION: wlan_hdd_validate_operation_channel
1532 * called by wlan_hdd_cfg80211_start_bss() and
1533 * wlan_hdd_cfg80211_set_channel()
1534 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301535 * channel list.
1536 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001537VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001538{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301539
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 v_U32_t num_ch = 0;
1541 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1542 u32 indx = 0;
1543 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301544 v_U8_t fValidChannel = FALSE, count = 0;
1545 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301546
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1548
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301549 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301551 /* Validate the channel */
1552 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301554 if ( channel == rfChannels[count].channelNum )
1555 {
1556 fValidChannel = TRUE;
1557 break;
1558 }
1559 }
1560 if (fValidChannel != TRUE)
1561 {
1562 hddLog(VOS_TRACE_LEVEL_ERROR,
1563 "%s: Invalid Channel [%d]", __func__, channel);
1564 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 }
1566 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301567 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301569 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1570 valid_ch, &num_ch))
1571 {
1572 hddLog(VOS_TRACE_LEVEL_ERROR,
1573 "%s: failed to get valid channel list", __func__);
1574 return VOS_STATUS_E_FAILURE;
1575 }
1576 for (indx = 0; indx < num_ch; indx++)
1577 {
1578 if (channel == valid_ch[indx])
1579 {
1580 break;
1581 }
1582 }
1583
1584 if (indx >= num_ch)
1585 {
1586 hddLog(VOS_TRACE_LEVEL_ERROR,
1587 "%s: Invalid Channel [%d]", __func__, channel);
1588 return VOS_STATUS_E_FAILURE;
1589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 }
1591 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301592
Jeff Johnson295189b2012-06-20 16:38:30 -07001593}
1594
Viral Modi3a32cc52013-02-08 11:14:52 -08001595/**
1596 * FUNCTION: wlan_hdd_cfg80211_set_channel
1597 * This function is used to set the channel number
1598 */
1599static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1600 struct ieee80211_channel *chan,
1601 enum nl80211_channel_type channel_type
1602 )
1603{
1604 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001605 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001606 hdd_adapter_t *pAdapter = NULL;
1607 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301608 hdd_context_t *pHddCtx;
1609 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001610
1611 ENTER();
1612
1613 if( NULL == dev )
1614 {
1615 hddLog(VOS_TRACE_LEVEL_ERROR,
1616 "%s: Called with dev = NULL.\n", __func__);
1617 return -ENODEV;
1618 }
1619 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1620
1621 hddLog(VOS_TRACE_LEVEL_INFO,
1622 "%s: device_mode = %d freq = %d \n",__func__,
1623 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301624
1625 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1626 status = wlan_hdd_validate_context(pHddCtx);
1627
1628 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001629 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301630 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1631 "%s: HDD context is not valid", __func__);
1632 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001633 }
1634
1635 /*
1636 * Do freq to chan conversion
1637 * TODO: for 11a
1638 */
1639
1640 channel = ieee80211_frequency_to_channel(freq);
1641
1642 /* Check freq range */
1643 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1644 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1645 {
1646 hddLog(VOS_TRACE_LEVEL_ERROR,
1647 "%s: Channel [%d] is outside valid range from %d to %d\n",
1648 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1649 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1650 return -EINVAL;
1651 }
1652
1653 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1654
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301655 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1656 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001657 {
1658 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1659 {
1660 hddLog(VOS_TRACE_LEVEL_ERROR,
1661 "%s: Invalid Channel [%d] \n", __func__, channel);
1662 return -EINVAL;
1663 }
1664 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1665 "%s: set channel to [%d] for device mode =%d",
1666 __func__, channel,pAdapter->device_mode);
1667 }
1668 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001669 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001670 )
1671 {
1672 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1673 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1674 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1675
1676 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1677 {
1678 /* Link is up then return cant set channel*/
1679 hddLog( VOS_TRACE_LEVEL_ERROR,
1680 "%s: IBSS Associated, can't set the channel\n", __func__);
1681 return -EINVAL;
1682 }
1683
1684 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1685 pHddStaCtx->conn_info.operationChannel = channel;
1686 pRoamProfile->ChannelInfo.ChannelList =
1687 &pHddStaCtx->conn_info.operationChannel;
1688 }
1689 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001690 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001691 )
1692 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301693 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1694 {
1695 if(VOS_STATUS_SUCCESS !=
1696 wlan_hdd_validate_operation_channel(pAdapter,channel))
1697 {
1698 hddLog(VOS_TRACE_LEVEL_ERROR,
1699 "%s: Invalid Channel [%d] \n", __func__, channel);
1700 return -EINVAL;
1701 }
1702 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1703 }
1704 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001705 {
1706 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1707
1708 /* If auto channel selection is configured as enable/ 1 then ignore
1709 channel set by supplicant
1710 */
1711 if ( cfg_param->apAutoChannelSelection )
1712 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301713 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1714 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001715 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1716 "%s: set channel to auto channel (0) for device mode =%d",
1717 __func__, pAdapter->device_mode);
1718 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301719 else
1720 {
1721 if(VOS_STATUS_SUCCESS !=
1722 wlan_hdd_validate_operation_channel(pAdapter,channel))
1723 {
1724 hddLog(VOS_TRACE_LEVEL_ERROR,
1725 "%s: Invalid Channel [%d] \n", __func__, channel);
1726 return -EINVAL;
1727 }
1728 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1729 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001730 }
1731 }
1732 else
1733 {
1734 hddLog(VOS_TRACE_LEVEL_FATAL,
1735 "%s: Invalid device mode failed to set valid channel", __func__);
1736 return -EINVAL;
1737 }
1738 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301739 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001740}
1741
Jeff Johnson295189b2012-06-20 16:38:30 -07001742#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1743static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1744 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001745#else
1746static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1747 struct cfg80211_beacon_data *params,
1748 const u8 *ssid, size_t ssid_len,
1749 enum nl80211_hidden_ssid hidden_ssid)
1750#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001751{
1752 tsap_Config_t *pConfig;
1753 beacon_data_t *pBeacon = NULL;
1754 struct ieee80211_mgmt *pMgmt_frame;
1755 v_U8_t *pIe=NULL;
1756 v_U16_t capab_info;
1757 eCsrAuthType RSNAuthType;
1758 eCsrEncryptionType RSNEncryptType;
1759 eCsrEncryptionType mcRSNEncryptType;
1760 int status = VOS_STATUS_SUCCESS;
1761 tpWLAN_SAPEventCB pSapEventCallback;
1762 hdd_hostapd_state_t *pHostapdState;
1763 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1764 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301765 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 struct qc_mac_acl_entry *acl_entry = NULL;
1767 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001768 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001769
1770 ENTER();
1771
1772 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1773
1774 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1775
1776 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1777
1778 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1779
1780 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1781
1782 //channel is already set in the set_channel Call back
1783 //pConfig->channel = pCommitConfig->channel;
1784
1785 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301786 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1788
1789 pConfig->dtim_period = pBeacon->dtim_period;
1790
1791 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1792 pConfig->dtim_period);
1793
1794
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001795 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001796 {
1797 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05301799 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
1800 {
1801 tANI_BOOLEAN restartNeeded;
1802 pConfig->ieee80211d = 1;
1803 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
1804 sme_setRegInfo(hHal, pConfig->countryCode);
1805 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
1806 }
1807 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001809 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001810 pConfig->ieee80211d = 1;
1811 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1812 sme_setRegInfo(hHal, pConfig->countryCode);
1813 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001815 else
1816 {
1817 pConfig->ieee80211d = 0;
1818 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301819 /*
1820 * If auto channel is configured i.e. channel is 0,
1821 * so skip channel validation.
1822 */
1823 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1824 {
1825 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1826 {
1827 hddLog(VOS_TRACE_LEVEL_ERROR,
1828 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1829 return -EINVAL;
1830 }
1831 }
1832 else
1833 {
1834 if(1 != pHddCtx->is_dynamic_channel_range_set)
1835 {
1836 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1837 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1838 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1839 }
1840 pHddCtx->is_dynamic_channel_range_set = 0;
1841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001843 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001844 {
1845 pConfig->ieee80211d = 0;
1846 }
1847 pConfig->authType = eSAP_AUTO_SWITCH;
1848
1849 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301850
1851 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1853
1854 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1855
1856 /*Set wps station to configured*/
1857 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1858
1859 if(pIe)
1860 {
1861 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1862 {
1863 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1864 return -EINVAL;
1865 }
1866 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1867 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001868 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 /* Check 15 bit of WPS IE as it contain information for wps state
1870 * WPS state
1871 */
1872 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1873 {
1874 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1875 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1876 {
1877 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1878 }
1879 }
1880 }
1881 else
1882 {
1883 pConfig->wps_state = SAP_WPS_DISABLED;
1884 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301885 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001886
1887 pConfig->RSNWPAReqIELength = 0;
1888 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301889 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 WLAN_EID_RSN);
1891 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301892 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1894 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1895 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301896 /* The actual processing may eventually be more extensive than
1897 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 * by the app.
1899 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301900 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1902 &RSNEncryptType,
1903 &mcRSNEncryptType,
1904 &RSNAuthType,
1905 pConfig->pRSNWPAReqIE[1]+2,
1906 pConfig->pRSNWPAReqIE );
1907
1908 if( VOS_STATUS_SUCCESS == status )
1909 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301910 /* Now copy over all the security attributes you have
1911 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 * */
1913 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1914 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1915 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1916 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301917 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 "EncryptionType = %d mcEncryptionType = %d\n"),
1919 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1920 }
1921 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301922
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1924 pBeacon->tail, pBeacon->tail_len);
1925
1926 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1927 {
1928 if (pConfig->pRSNWPAReqIE)
1929 {
1930 /*Mixed mode WPA/WPA2*/
1931 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1932 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1933 }
1934 else
1935 {
1936 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1937 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1938 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301939 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1941 &RSNEncryptType,
1942 &mcRSNEncryptType,
1943 &RSNAuthType,
1944 pConfig->pRSNWPAReqIE[1]+2,
1945 pConfig->pRSNWPAReqIE );
1946
1947 if( VOS_STATUS_SUCCESS == status )
1948 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301949 /* Now copy over all the security attributes you have
1950 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 * */
1952 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1953 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1954 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1955 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301956 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001957 "EncryptionType = %d mcEncryptionType = %d\n"),
1958 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1959 }
1960 }
1961 }
1962
Jeff Johnson4416a782013-03-25 14:17:50 -07001963 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1964 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1965 return -EINVAL;
1966 }
1967
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1969
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001970#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 if (params->ssid != NULL)
1972 {
1973 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1974 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1975 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1976 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1977 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001978#else
1979 if (ssid != NULL)
1980 {
1981 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1982 pConfig->SSIDinfo.ssid.length = ssid_len;
1983 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1984 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1985 }
1986#endif
1987
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301988 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301990
Jeff Johnson295189b2012-06-20 16:38:30 -07001991 /* default value */
1992 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1993 pConfig->num_accept_mac = 0;
1994 pConfig->num_deny_mac = 0;
1995
1996 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1997 pBeacon->tail, pBeacon->tail_len);
1998
1999 /* pIe for black list is following form:
2000 type : 1 byte
2001 length : 1 byte
2002 OUI : 4 bytes
2003 acl type : 1 byte
2004 no of mac addr in black list: 1 byte
2005 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302006 */
2007 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002008 {
2009 pConfig->SapMacaddr_acl = pIe[6];
2010 pConfig->num_deny_mac = pIe[7];
2011 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
2012 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302013 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2014 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2016 for (i = 0; i < pConfig->num_deny_mac; i++)
2017 {
2018 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2019 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 }
2022 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2023 pBeacon->tail, pBeacon->tail_len);
2024
2025 /* pIe for white list is following form:
2026 type : 1 byte
2027 length : 1 byte
2028 OUI : 4 bytes
2029 acl type : 1 byte
2030 no of mac addr in white list: 1 byte
2031 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302032 */
2033 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 {
2035 pConfig->SapMacaddr_acl = pIe[6];
2036 pConfig->num_accept_mac = pIe[7];
2037 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
2038 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302039 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2040 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2042 for (i = 0; i < pConfig->num_accept_mac; i++)
2043 {
2044 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2045 acl_entry++;
2046 }
2047 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302048
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2050
Jeff Johnsone7245742012-09-05 17:12:55 -07002051#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002052 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05302053 * This is valid only if mode is set to 11n in hostapd, either AUTO or
2054 * 11ac in .ini and 11ac is supported by both host and firmware.
2055 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
2056 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002057 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2058 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302059 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002060 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
Kiet Lam0f320422013-11-21 19:29:17 +05302061 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) &&
2062 (sme_IsFeatureSupportedByDriver(DOT11AC)) && (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002063 {
2064 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002065
2066 /* Disable VHT support in 2.4 GHz band */
2067 if (pConfig->channel <= 14 &&
2068 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2069 {
2070 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2071 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002072 }
2073#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302074
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002075 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2076 {
2077 sme_SelectCBMode(hHal,
2078 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2079 pConfig->channel);
2080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002081 // ht_capab is not what the name conveys,this is used for protection bitmap
2082 pConfig->ht_capab =
2083 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2084
2085 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2086 {
2087 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2088 return -EINVAL;
2089 }
2090
2091 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302092 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2094 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302095 pConfig->obssProtEnabled =
2096 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002097
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302098 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302100 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
2102 (int)pConfig->channel);
2103 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302104 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
2105 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302107 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
2109 pConfig->protEnabled, pConfig->obssProtEnabled);
2110
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302111 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 {
2113 //Bss already started. just return.
2114 //TODO Probably it should update some beacon params.
2115 hddLog( LOGE, "Bss Already started...Ignore the request");
2116 EXIT();
2117 return 0;
2118 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302119
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 pConfig->persona = pHostapdAdapter->device_mode;
2121
2122 pSapEventCallback = hdd_hostapd_SAPEventCB;
2123 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2124 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2125 {
2126 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2127 return -EINVAL;
2128 }
2129
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302130 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2132
2133 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302134
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302136 {
2137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 ("ERROR: HDD vos wait for single_event failed!!\n"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002139 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 VOS_ASSERT(0);
2141 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302142
Jeff Johnson295189b2012-06-20 16:38:30 -07002143 //Succesfully started Bss update the state bit.
2144 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2145
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002146#ifdef WLAN_FEATURE_P2P_DEBUG
2147 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2148 {
2149 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2150 {
2151 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2152 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002153 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002154 }
2155 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2156 {
2157 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2158 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002159 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002160 }
2161 }
2162#endif
2163
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 pHostapdState->bCommit = TRUE;
2165 EXIT();
2166
2167 return 0;
2168}
2169
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002170#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302171static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2172 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 struct beacon_parameters *params)
2174{
2175 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302176 hdd_context_t *pHddCtx;
2177 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002178
2179 ENTER();
2180
2181 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
2182
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302183 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2184 status = wlan_hdd_validate_context(pHddCtx);
2185
2186 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002187 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2189 "%s: HDD context is not valid", __func__);
2190 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002191 }
2192
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302193 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 )
2196 {
2197 beacon_data_t *old,*new;
2198
2199 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302200
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 if (old)
2202 return -EALREADY;
2203
2204 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2205
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302206 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 {
2208 hddLog(VOS_TRACE_LEVEL_FATAL,
2209 "%s:Error!!! Allocating the new beacon\n",__func__);
2210 return -EINVAL;
2211 }
2212
2213 pAdapter->sessionCtx.ap.beacon = new;
2214
2215 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2216 }
2217
2218 EXIT();
2219 return status;
2220}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302221
2222static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 struct net_device *dev,
2224 struct beacon_parameters *params)
2225{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302226 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302227 hdd_context_t *pHddCtx;
2228 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002229
2230 ENTER();
2231
2232 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2233 __func__,pAdapter->device_mode);
2234
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302235 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2236 status = wlan_hdd_validate_context(pHddCtx);
2237
2238 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002239 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302240 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2241 "%s: HDD context is not valid", __func__);
2242 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002243 }
2244
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302245 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302247 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 {
2249 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302250
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302252
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 if (!old)
2254 return -ENOENT;
2255
2256 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2257
2258 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302259 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 "%s: Error!!! Allocating the new beacon\n",__func__);
2261 return -EINVAL;
2262 }
2263
2264 pAdapter->sessionCtx.ap.beacon = new;
2265
2266 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2267 }
2268
2269 EXIT();
2270 return status;
2271}
2272
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002273#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2274
2275#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002276static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2277 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002278#else
2279static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2280 struct net_device *dev)
2281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002282{
2283 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002284 hdd_context_t *pHddCtx = NULL;
2285 hdd_scaninfo_t *pScanInfo = NULL;
2286 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302287 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002288
2289 ENTER();
2290
2291 if (NULL == pAdapter)
2292 {
2293 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002294 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 return -ENODEV;
2296 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002297
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302298 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2299 status = wlan_hdd_validate_context(pHddCtx);
2300
2301 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002302 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302303 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2304 "%s: HDD context is not valid", __func__);
2305 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002306 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002307
2308 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2309 if (NULL == staAdapter)
2310 {
2311 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2312 if (NULL == staAdapter)
2313 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2315 "%s: HDD adapter context for STA/P2P-CLI is Null",
2316 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002317 }
2318 }
2319
2320 pScanInfo = &pHddCtx->scan_info;
2321
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2323 __func__,pAdapter->device_mode);
2324
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002325 if ((pScanInfo != NULL) && pScanInfo->mScanPending && staAdapter)
Jeff Johnsone7245742012-09-05 17:12:55 -07002326 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002327 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05302328 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002329 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002330 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002331 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2332 if (!status)
2333 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002334 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson902c9832012-12-10 14:28:09 -08002335 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002336 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002337 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07002338 }
2339 }
2340
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002342 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 )
2344 {
2345 beacon_data_t *old;
2346
2347 old = pAdapter->sessionCtx.ap.beacon;
2348
2349 if (!old)
2350 return -ENOENT;
2351
Jeff Johnson295189b2012-06-20 16:38:30 -07002352 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002353
2354 mutex_lock(&pHddCtx->sap_lock);
2355 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2356 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002357 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 {
2359 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2360
2361 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2362
2363 if (!VOS_IS_STATUS_SUCCESS(status))
2364 {
2365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2366 ("ERROR: HDD vos wait for single_event failed!!\n"));
2367 VOS_ASSERT(0);
2368 }
2369 }
2370 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2371 }
2372 mutex_unlock(&pHddCtx->sap_lock);
2373
2374 if(status != VOS_STATUS_SUCCESS)
2375 {
2376 hddLog(VOS_TRACE_LEVEL_FATAL,
2377 "%s:Error!!! Stopping the BSS\n",__func__);
2378 return -EINVAL;
2379 }
2380
Jeff Johnson4416a782013-03-25 14:17:50 -07002381 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2383 ==eHAL_STATUS_FAILURE)
2384 {
2385 hddLog(LOGE,
2386 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2387 }
2388
Jeff Johnson4416a782013-03-25 14:17:50 -07002389 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2391 eANI_BOOLEAN_FALSE) )
2392 {
2393 hddLog(LOGE,
2394 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2395 }
2396
2397 // Reset WNI_CFG_PROBE_RSP Flags
2398 wlan_hdd_reset_prob_rspies(pAdapter);
2399
2400 pAdapter->sessionCtx.ap.beacon = NULL;
2401 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002402#ifdef WLAN_FEATURE_P2P_DEBUG
2403 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2404 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2405 {
2406 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2407 "GO got removed");
2408 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2409 }
2410#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 }
2412 EXIT();
2413 return status;
2414}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002415
2416#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2417
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302418static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2419 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002420 struct cfg80211_ap_settings *params)
2421{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302422 hdd_adapter_t *pAdapter;
2423 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302424 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002425
2426 ENTER();
2427
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302428 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002429 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302430 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302431 "%s: Device is Null", __func__);
2432 return -ENODEV;
2433 }
2434
2435 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2436 if (NULL == pAdapter)
2437 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302438 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302439 "%s: HDD adapter is Null", __func__);
2440 return -ENODEV;
2441 }
2442
2443 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2444 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302445 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302446 "%s: HDD adapter magic is invalid", __func__);
2447 return -ENODEV;
2448 }
2449
2450 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302451 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302452
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302453 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302454 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302455 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2456 "%s: HDD context is not valid", __func__);
2457 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302458 }
2459
2460 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2461 __func__, pAdapter->device_mode);
2462
2463 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002464 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002465 )
2466 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302467 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002468
2469 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302470
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002471 if (old)
2472 return -EALREADY;
2473
2474 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2475
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302476 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002477 {
2478 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302479 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002480 return -EINVAL;
2481 }
2482 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002483#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002484 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2485#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2486 params->channel, params->channel_type);
2487#else
2488 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2489#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002490#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002491 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2492 params->ssid_len, params->hidden_ssid);
2493 }
2494
2495 EXIT();
2496 return status;
2497}
2498
2499
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302500static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002501 struct net_device *dev,
2502 struct cfg80211_beacon_data *params)
2503{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302504 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302505 hdd_context_t *pHddCtx;
2506 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002507
2508 ENTER();
2509
2510 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2511 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302512
2513 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2514 status = wlan_hdd_validate_context(pHddCtx);
2515
2516 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002517 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302518 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2519 "%s: HDD context is not valid", __func__);
2520 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002521 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002522
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302523 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002524 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302525 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002526 {
2527 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302528
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002529 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302530
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002531 if (!old)
2532 return -ENOENT;
2533
2534 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2535
2536 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302537 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002538 "%s: Error!!! Allocating the new beacon\n",__func__);
2539 return -EINVAL;
2540 }
2541
2542 pAdapter->sessionCtx.ap.beacon = new;
2543
2544 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2545 }
2546
2547 EXIT();
2548 return status;
2549}
2550
2551#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2552
Jeff Johnson295189b2012-06-20 16:38:30 -07002553
2554static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2555 struct net_device *dev,
2556 struct bss_parameters *params)
2557{
2558 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2559
2560 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302561
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2563 __func__,pAdapter->device_mode);
2564
2565 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302567 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 {
2569 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2570 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302571 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002572 {
2573 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 }
2576
2577 EXIT();
2578 return 0;
2579}
2580
Kiet Lam10841362013-11-01 11:36:50 +05302581/* FUNCTION: wlan_hdd_change_country_code_cd
2582* to wait for contry code completion
2583*/
2584void* wlan_hdd_change_country_code_cb(void *pAdapter)
2585{
2586 hdd_adapter_t *call_back_pAdapter = pAdapter;
2587 complete(&call_back_pAdapter->change_country_code);
2588 return NULL;
2589}
2590
Jeff Johnson295189b2012-06-20 16:38:30 -07002591/*
2592 * FUNCTION: wlan_hdd_cfg80211_change_iface
2593 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2594 */
2595int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2596 struct net_device *ndev,
2597 enum nl80211_iftype type,
2598 u32 *flags,
2599 struct vif_params *params
2600 )
2601{
2602 struct wireless_dev *wdev;
2603 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2604 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002605 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 tCsrRoamProfile *pRoamProfile = NULL;
2607 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302608 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 eMib_dot11DesiredBssType connectedBssType;
2610 VOS_STATUS status;
2611
2612 ENTER();
2613
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302614 status = wlan_hdd_validate_context(pHddCtx);
2615
2616 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302618 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2619 "%s: HDD context is not valid", __func__);
2620 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 }
2622
2623 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2624 __func__, pAdapter->device_mode);
2625
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302626 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 wdev = ndev->ieee80211_ptr;
2628
2629#ifdef WLAN_BTAMP_FEATURE
2630 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2631 (NL80211_IFTYPE_ADHOC == type)||
2632 (NL80211_IFTYPE_AP == type)||
2633 (NL80211_IFTYPE_P2P_GO == type))
2634 {
2635 pHddCtx->isAmpAllowed = VOS_FALSE;
2636 // stop AMP traffic
2637 status = WLANBAP_StopAmp();
2638 if(VOS_STATUS_SUCCESS != status )
2639 {
2640 pHddCtx->isAmpAllowed = VOS_TRUE;
2641 hddLog(VOS_TRACE_LEVEL_FATAL,
2642 "%s: Failed to stop AMP", __func__);
2643 return -EINVAL;
2644 }
2645 }
2646#endif //WLAN_BTAMP_FEATURE
2647 /* Reset the current device mode bit mask*/
2648 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2649
2650 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002652 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 )
2654 {
2655 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2656 pRoamProfile = &pWextState->roamProfile;
2657 LastBSSType = pRoamProfile->BSSType;
2658
2659 switch (type)
2660 {
2661 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 hddLog(VOS_TRACE_LEVEL_INFO,
2664 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2665 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002666#ifdef WLAN_FEATURE_11AC
2667 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2668 {
2669 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2670 }
2671#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302672 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002673 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002675 //Check for sub-string p2p to confirm its a p2p interface
2676 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302677 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002678 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2679 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2680 }
2681 else
2682 {
2683 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002685 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302686#ifdef FEATURE_WLAN_TDLS
2687 /* The open adapter for the p2p shall skip initializations in
2688 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2689 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2690 * tdls_init when the change_iface sets the device mode to
2691 * WLAN_HDD_P2P_CLIENT.
2692 */
2693
2694 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2695 {
2696 if (0 != wlan_hdd_tdls_init (pAdapter))
2697 {
2698 return -EINVAL;
2699 }
2700 }
2701#endif
2702
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 break;
2704 case NL80211_IFTYPE_ADHOC:
2705 hddLog(VOS_TRACE_LEVEL_INFO,
2706 "%s: setting interface Type to ADHOC", __func__);
2707 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2708 pRoamProfile->phyMode =
2709 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002710 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 wdev->iftype = type;
2712 break;
2713
2714 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 {
2717 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2718 "%s: setting interface Type to %s", __func__,
2719 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2720
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002721 //Cancel any remain on channel for GO mode
2722 if (NL80211_IFTYPE_P2P_GO == type)
2723 {
2724 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2725 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002726 if (NL80211_IFTYPE_AP == type)
2727 {
2728 /* As Loading WLAN Driver one interface being created for p2p device
2729 * address. This will take one HW STA and the max number of clients
2730 * that can connect to softAP will be reduced by one. so while changing
2731 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2732 * interface as it is not required in SoftAP mode.
2733 */
2734
2735 // Get P2P Adapter
2736 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2737
2738 if (pP2pAdapter)
2739 {
2740 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2741 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2742 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2743 }
2744 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302745#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07002746
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302747 /* A Mutex Lock is introduced while changing the mode to
2748 * protect the concurrent access for the Adapters by TDLS
2749 * module.
2750 */
2751 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2752 {
2753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2754 "%s: unable to lock list", __func__);
2755 return -EINVAL;
2756 }
2757#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 //De-init the adapter.
2759 hdd_stop_adapter( pHddCtx, pAdapter );
2760 hdd_deinit_adapter( pHddCtx, pAdapter );
2761 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2763 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302764#ifdef FEATURE_WLAN_TDLS
2765 mutex_unlock(&pHddCtx->tdls_lock);
2766#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002767
2768 //Disable BMPS and IMPS if enabled
2769 //before starting Go
2770 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2771 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302772 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002773 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2774 {
2775 //Fail to Exit BMPS
2776 VOS_ASSERT(0);
2777 }
2778 }
2779
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002780 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2781 (pConfig->apRandomBssidEnabled))
2782 {
2783 /* To meet Android requirements create a randomized
2784 MAC address of the form 02:1A:11:Fx:xx:xx */
2785 get_random_bytes(&ndev->dev_addr[3], 3);
2786 ndev->dev_addr[0] = 0x02;
2787 ndev->dev_addr[1] = 0x1A;
2788 ndev->dev_addr[2] = 0x11;
2789 ndev->dev_addr[3] |= 0xF0;
2790 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2791 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08002792 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
2793 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002794 }
2795
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 hdd_set_ap_ops( pAdapter->dev );
2797
Kiet Lam10841362013-11-01 11:36:50 +05302798 /* This is for only SAP mode where users can
2799 * control country through ini.
2800 * P2P GO follows station country code
2801 * acquired during the STA scanning. */
2802 if((NL80211_IFTYPE_AP == type) &&
2803 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
2804 {
2805 int status = 0;
2806 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
2807 "%s: setting country code from INI ", __func__);
2808 init_completion(&pAdapter->change_country_code);
2809 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
2810 (void *)(tSmeChangeCountryCallback)
2811 wlan_hdd_change_country_code_cb,
2812 pConfig->apCntryCode, pAdapter,
2813 pHddCtx->pvosContext,
2814 VOS_FALSE);
2815 if (eHAL_STATUS_SUCCESS == status)
2816 {
2817 /* Wait for completion */
2818 status = wait_for_completion_interruptible_timeout(
2819 &pAdapter->change_country_code,
2820 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
2821 if (status <= 0)
2822 {
2823 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2824 "%s: SME Timed out while setting country code ",
2825 __func__);
2826 }
2827 }
2828 else
2829 {
2830 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2831 "%s: SME Change Country code failed \n",__func__);
2832 return -EINVAL;
2833 }
2834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002835 status = hdd_init_ap_mode(pAdapter);
2836 if(status != VOS_STATUS_SUCCESS)
2837 {
2838 hddLog(VOS_TRACE_LEVEL_FATAL,
2839 "%s: Error initializing the ap mode", __func__);
2840 return -EINVAL;
2841 }
2842 hdd_set_conparam(1);
2843
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 /*interface type changed update in wiphy structure*/
2845 if(wdev)
2846 {
2847 wdev->iftype = type;
2848 pHddCtx->change_iface = type;
2849 }
2850 else
2851 {
2852 hddLog(VOS_TRACE_LEVEL_ERROR,
2853 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2854 return -EINVAL;
2855 }
2856 goto done;
2857 }
2858
2859 default:
2860 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2861 __func__);
2862 return -EOPNOTSUPP;
2863 }
2864 }
2865 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 )
2868 {
2869 switch(type)
2870 {
2871 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302874#ifdef FEATURE_WLAN_TDLS
2875
2876 /* A Mutex Lock is introduced while changing the mode to
2877 * protect the concurrent access for the Adapters by TDLS
2878 * module.
2879 */
2880 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2881 {
2882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2883 "%s: unable to lock list", __func__);
2884 return -EINVAL;
2885 }
2886#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002887 hdd_stop_adapter( pHddCtx, pAdapter );
2888 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002889 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002890 //Check for sub-string p2p to confirm its a p2p interface
2891 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002892 {
2893 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2894 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2895 }
2896 else
2897 {
2898 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002899 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 hdd_set_conparam(0);
2902 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2904 hdd_set_station_ops( pAdapter->dev );
2905 status = hdd_init_station_mode( pAdapter );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302906#ifdef FEATURE_WLAN_TDLS
2907 mutex_unlock(&pHddCtx->tdls_lock);
2908#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 if( VOS_STATUS_SUCCESS != status )
2910 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002911 /* In case of JB, for P2P-GO, only change interface will be called,
2912 * This is the right place to enable back bmps_imps()
2913 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302914 if (pHddCtx->hdd_wlan_suspended)
2915 {
2916 hdd_set_pwrparams(pHddCtx);
2917 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002918 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 goto done;
2920 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002923 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2924 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 goto done;
2926 default:
2927 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2928 __func__);
2929 return -EOPNOTSUPP;
2930
2931 }
2932
2933 }
2934 else
2935 {
2936 return -EOPNOTSUPP;
2937 }
2938
2939
2940 if(pRoamProfile)
2941 {
2942 if ( LastBSSType != pRoamProfile->BSSType )
2943 {
2944 /*interface type changed update in wiphy structure*/
2945 wdev->iftype = type;
2946
2947 /*the BSS mode changed, We need to issue disconnect
2948 if connected or in IBSS disconnect state*/
2949 if ( hdd_connGetConnectedBssType(
2950 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2951 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2952 {
2953 /*need to issue a disconnect to CSR.*/
2954 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2955 if( eHAL_STATUS_SUCCESS ==
2956 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2957 pAdapter->sessionId,
2958 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2959 {
2960 wait_for_completion_interruptible_timeout(
2961 &pAdapter->disconnect_comp_var,
2962 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2963 }
2964 }
2965 }
2966 }
2967
2968done:
2969 /*set bitmask based on updated value*/
2970 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002971
2972 /* Only STA mode support TM now
2973 * all other mode, TM feature should be disabled */
2974 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2975 (~VOS_STA & pHddCtx->concurrency_mode) )
2976 {
2977 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2978 }
2979
Jeff Johnson295189b2012-06-20 16:38:30 -07002980#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302981 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2983 {
2984 //we are ok to do AMP
2985 pHddCtx->isAmpAllowed = VOS_TRUE;
2986 }
2987#endif //WLAN_BTAMP_FEATURE
2988 EXIT();
2989 return 0;
2990}
2991
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002992#ifdef FEATURE_WLAN_TDLS
2993static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2994 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2995{
2996 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2997 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2998 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002999 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003000
3001 ENTER();
3002
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303003 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003004 {
3005 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3006 "Invalid arguments");
3007 return -EINVAL;
3008 }
Hoonki Lee27511902013-03-14 18:19:06 -07003009
3010 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
3011 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
3012 {
3013 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3014 "%s: TDLS mode is disabled OR not enabled in FW."
3015 MAC_ADDRESS_STR " Request declined.",
3016 __func__, MAC_ADDR_ARRAY(mac));
3017 return -ENOTSUPP;
3018 }
3019
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003020 if (pHddCtx->isLogpInProgress)
3021 {
3022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3023 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07003024 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003025 return -EBUSY;
3026 }
3027
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303028 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003029
3030 if ( NULL == pTdlsPeer ) {
3031 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3032 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
3033 __func__, MAC_ADDR_ARRAY(mac), update);
3034 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003035 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003036
3037 /* in add station, we accept existing valid staId if there is */
3038 if ((0 == update) &&
3039 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
3040 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003041 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003042 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003043 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003044 " link_status %d. staId %d. add station ignored.",
3045 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
3046 return 0;
3047 }
3048 /* in change station, we accept only when staId is valid */
3049 if ((1 == update) &&
3050 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
3051 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
3052 {
3053 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3054 "%s: " MAC_ADDRESS_STR
3055 " link status %d. staId %d. change station %s.",
3056 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
3057 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
3058 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003059 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003060
3061 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303062 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003063 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003064 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3065 "%s: " MAC_ADDRESS_STR
3066 " TDLS setup is ongoing. Request declined.",
3067 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003068 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003069 }
3070
3071 /* first to check if we reached to maximum supported TDLS peer.
3072 TODO: for now, return -EPERM looks working fine,
3073 but need to check if any other errno fit into this category.*/
3074 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
3075 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003076 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3077 "%s: " MAC_ADDRESS_STR
3078 " TDLS Max peer already connected. Request declined.",
3079 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003080 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003081 }
3082 else
3083 {
3084 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303085 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003086 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003087 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003088 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3089 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3090 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003091 return -EPERM;
3092 }
3093 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003094 if (0 == update)
3095 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003096
Jeff Johnsond75fe012013-04-06 10:53:06 -07003097 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303098 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003099 {
3100 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3101 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003102 if(StaParams->htcap_present)
3103 {
3104 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3105 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3106 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3107 "ht_capa->extended_capabilities: %0x",
3108 StaParams->HTCap.extendedHtCapInfo);
3109 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003110 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3111 "params->capability: %0x",StaParams->capability);
3112 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003113 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003114 if(StaParams->vhtcap_present)
3115 {
3116 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3117 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3118 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3119 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3120 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003121 {
3122 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003123 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003124 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3125 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3126 "[%d]: %x ", i, StaParams->supported_rates[i]);
3127 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003128 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303129 else if ((1 == update) && (NULL == StaParams))
3130 {
3131 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3132 "%s : update is true, but staParams is NULL. Error!", __func__);
3133 return -EPERM;
3134 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003135
3136 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3137
3138 if (!update)
3139 {
3140 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3141 pAdapter->sessionId, mac);
3142 }
3143 else
3144 {
3145 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3146 pAdapter->sessionId, mac, StaParams);
3147 }
3148
3149 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
3150 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3151
3152 if (!status)
3153 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003155 "%s: timeout waiting for tdls add station indication",
3156 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003157 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003158 }
3159 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3160 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003162 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003163 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003164 }
3165
3166 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003167
3168error:
3169 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3170 return -EPERM;
3171
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003172}
3173#endif
3174
Jeff Johnson295189b2012-06-20 16:38:30 -07003175static int wlan_hdd_change_station(struct wiphy *wiphy,
3176 struct net_device *dev,
3177 u8 *mac,
3178 struct station_parameters *params)
3179{
3180 VOS_STATUS status = VOS_STATUS_SUCCESS;
3181 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303182 hdd_context_t *pHddCtx;
3183 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003185#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003186 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003187 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003188#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003189 ENTER();
3190
Gopichand Nakkala29149562013-05-10 21:43:41 +05303191 if ((NULL == pAdapter))
3192 {
3193 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3194 "invalid adapter ");
3195 return -EINVAL;
3196 }
3197
3198 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3199 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3200
3201 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3202 {
3203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3204 "invalid HDD state or HDD station context");
3205 return -EINVAL;
3206 }
3207
3208 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003209 {
3210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3211 "%s:LOGP in Progress. Ignore!!!", __func__);
3212 return -EAGAIN;
3213 }
3214
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3216
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003217 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3218 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003220 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303222 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 WLANTL_STA_AUTHENTICATED);
3224
Gopichand Nakkala29149562013-05-10 21:43:41 +05303225 if (status != VOS_STATUS_SUCCESS)
3226 {
3227 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3228 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3229 return -EINVAL;
3230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 }
3232 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003233 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3234 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303235#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003236 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3237 StaParams.capability = params->capability;
3238 StaParams.uapsd_queues = params->uapsd_queues;
3239 StaParams.max_sp = params->max_sp;
3240
3241 if (0 != params->ext_capab_len)
3242 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3243 sizeof(StaParams.extn_capability));
3244
3245 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003246 {
3247 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003248 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003249 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003250
3251 StaParams.supported_rates_len = params->supported_rates_len;
3252
3253 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3254 * The supported_rates array , for all the structures propogating till Add Sta
3255 * to the firmware has to be modified , if the supplicant (ieee80211) is
3256 * modified to send more rates.
3257 */
3258
3259 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3260 */
3261 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3262 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3263
3264 if (0 != StaParams.supported_rates_len) {
3265 int i = 0;
3266 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3267 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003268 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003269 "Supported Rates with Length %d", StaParams.supported_rates_len);
3270 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003271 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003272 "[%d]: %0x", i, StaParams.supported_rates[i]);
3273 }
3274
3275 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003276 {
3277 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003278 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003279 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003280
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003281 if (0 != params->ext_capab_len ) {
3282 /*Define A Macro : TODO Sunil*/
3283 if ((1<<4) & StaParams.extn_capability[3]) {
3284 isBufSta = 1;
3285 }
3286 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303287 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3288 params->max_sp, isBufSta);
3289 if (VOS_STATUS_SUCCESS != status) {
3290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3291 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3292 return -EINVAL;
3293 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003294 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3295
3296 if (VOS_STATUS_SUCCESS != status) {
3297 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3298 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3299 return -EINVAL;
3300 }
3301 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003302#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303303 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003304 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 return status;
3306}
3307
3308/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 * FUNCTION: wlan_hdd_cfg80211_add_key
3310 * This function is used to initialize the key information
3311 */
3312#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003313static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 struct net_device *ndev,
3315 u8 key_index, bool pairwise,
3316 const u8 *mac_addr,
3317 struct key_params *params
3318 )
3319#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003320static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 struct net_device *ndev,
3322 u8 key_index, const u8 *mac_addr,
3323 struct key_params *params
3324 )
3325#endif
3326{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003327 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 tCsrRoamSetKey setKey;
3329 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303330 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003331 v_U32_t roamId= 0xFF;
3332 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 hdd_hostapd_state_t *pHostapdState;
3334 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003335 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303336 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003337
3338 ENTER();
3339
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303340 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3341 status = wlan_hdd_validate_context(pHddCtx);
3342
3343 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003344 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303345 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3346 "%s: HDD context is not valid", __func__);
3347 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003348 }
3349
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003350 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3351 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003352
3353 if (CSR_MAX_NUM_KEY <= key_index)
3354 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003355 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 key_index);
3357
3358 return -EINVAL;
3359 }
3360
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003361 if (CSR_MAX_KEY_LEN < params->key_len)
3362 {
3363 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3364 params->key_len);
3365
3366 return -EINVAL;
3367 }
3368
3369 hddLog(VOS_TRACE_LEVEL_INFO,
3370 "%s: called with key index = %d & key length %d",
3371 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003372
3373 /*extract key idx, key len and key*/
3374 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3375 setKey.keyId = key_index;
3376 setKey.keyLength = params->key_len;
3377 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3378
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003379 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 {
3381 case WLAN_CIPHER_SUITE_WEP40:
3382 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3383 break;
3384
3385 case WLAN_CIPHER_SUITE_WEP104:
3386 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3387 break;
3388
3389 case WLAN_CIPHER_SUITE_TKIP:
3390 {
3391 u8 *pKey = &setKey.Key[0];
3392 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3393
3394 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3395
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003396 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003397
3398 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003399 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 |--------------|----------|----------|
3401 <---16bytes---><--8bytes--><--8bytes-->
3402
3403 */
3404 /*Sme expects the 32 bytes key to be in the below order
3405
3406 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003407 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 |--------------|----------|----------|
3409 <---16bytes---><--8bytes--><--8bytes-->
3410 */
3411 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003412 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003413
3414 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003415 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003416
3417 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003418 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003419
3420
3421 break;
3422 }
3423
3424 case WLAN_CIPHER_SUITE_CCMP:
3425 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3426 break;
3427
3428#ifdef FEATURE_WLAN_WAPI
3429 case WLAN_CIPHER_SUITE_SMS4:
3430 {
3431 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3432 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3433 params->key, params->key_len);
3434 return 0;
3435 }
3436#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003437
Jeff Johnson295189b2012-06-20 16:38:30 -07003438#ifdef FEATURE_WLAN_CCX
3439 case WLAN_CIPHER_SUITE_KRK:
3440 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3441 break;
3442#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003443
3444#ifdef WLAN_FEATURE_11W
3445 case WLAN_CIPHER_SUITE_AES_CMAC:
3446 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003447 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003448#endif
3449
Jeff Johnson295189b2012-06-20 16:38:30 -07003450 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003451 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 __func__, params->cipher);
3453 return -EOPNOTSUPP;
3454 }
3455
3456 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3457 __func__, setKey.encType);
3458
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003459 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003460#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3461 (!pairwise)
3462#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003463 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003464#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003465 )
3466 {
3467 /* set group key*/
3468 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3469 "%s- %d: setting Broadcast key",
3470 __func__, __LINE__);
3471 setKey.keyDirection = eSIR_RX_ONLY;
3472 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3473 }
3474 else
3475 {
3476 /* set pairwise key*/
3477 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3478 "%s- %d: setting pairwise key",
3479 __func__, __LINE__);
3480 setKey.keyDirection = eSIR_TX_RX;
3481 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3482 }
3483 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3484 {
3485 setKey.keyDirection = eSIR_TX_RX;
3486 /*Set the group key*/
3487 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3488 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003489
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003490 if ( 0 != status )
3491 {
3492 hddLog(VOS_TRACE_LEVEL_ERROR,
3493 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3494 return -EINVAL;
3495 }
3496 /*Save the keys here and call sme_RoamSetKey for setting
3497 the PTK after peer joins the IBSS network*/
3498 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3499 &setKey, sizeof(tCsrRoamSetKey));
3500 return status;
3501 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303502 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3503 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3504 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003506 if( pHostapdState->bssState == BSS_START )
3507 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3509
3510 if ( status != eHAL_STATUS_SUCCESS )
3511 {
3512 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3513 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3514 __LINE__, status );
3515 }
3516 }
3517
3518 /* Saving WEP keys */
3519 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3520 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3521 {
3522 //Save the wep key in ap context. Issue setkey after the BSS is started.
3523 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3524 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3525 }
3526 else
3527 {
3528 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003529 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3531 }
3532 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003533 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3534 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 {
3536 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3537 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3538
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303539#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3540 if (!pairwise)
3541#else
3542 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3543#endif
3544 {
3545 /* set group key*/
3546 if (pHddStaCtx->roam_info.deferKeyComplete)
3547 {
3548 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3549 "%s- %d: Perform Set key Complete",
3550 __func__, __LINE__);
3551 hdd_PerformRoamSetKeyComplete(pAdapter);
3552 }
3553 }
3554
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3556
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003557 pWextState->roamProfile.Keys.defaultIndex = key_index;
3558
3559
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003560 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 params->key, params->key_len);
3562
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303563
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3565
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303566 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303568 __func__, setKey.peerMac[0], setKey.peerMac[1],
3569 setKey.peerMac[2], setKey.peerMac[3],
3570 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 setKey.keyDirection);
3572
3573 vos_status = wlan_hdd_check_ula_done(pAdapter);
3574
3575 if ( vos_status != VOS_STATUS_SUCCESS )
3576 {
3577 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3578 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3579 __LINE__, vos_status );
3580
3581 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3582
3583 return -EINVAL;
3584
3585 }
3586
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003587#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303588 /* The supplicant may attempt to set the PTK once pre-authentication
3589 is done. Save the key in the UMAC and include it in the ADD BSS
3590 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003591 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303592 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003593 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303594 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3595 "%s: Update PreAuth Key success", __func__);
3596 return 0;
3597 }
3598 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3599 {
3600 hddLog(VOS_TRACE_LEVEL_ERROR,
3601 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303602 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003603 }
3604#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003605
3606 /* issue set key request to SME*/
3607 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3608 pAdapter->sessionId, &setKey, &roamId );
3609
3610 if ( 0 != status )
3611 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303612 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3614 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3615 return -EINVAL;
3616 }
3617
3618
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303619 /* in case of IBSS as there was no information available about WEP keys during
3620 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303622 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3623 !( ( IW_AUTH_KEY_MGMT_802_1X
3624 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3626 )
3627 &&
3628 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3629 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3630 )
3631 )
3632 {
3633 setKey.keyDirection = eSIR_RX_ONLY;
3634 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3635
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303636 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003637 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303638 __func__, setKey.peerMac[0], setKey.peerMac[1],
3639 setKey.peerMac[2], setKey.peerMac[3],
3640 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 setKey.keyDirection);
3642
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303643 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 pAdapter->sessionId, &setKey, &roamId );
3645
3646 if ( 0 != status )
3647 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303648 hddLog(VOS_TRACE_LEVEL_ERROR,
3649 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 __func__, status);
3651 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3652 return -EINVAL;
3653 }
3654 }
3655 }
3656
3657 return 0;
3658}
3659
3660/*
3661 * FUNCTION: wlan_hdd_cfg80211_get_key
3662 * This function is used to get the key information
3663 */
3664#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303665static int wlan_hdd_cfg80211_get_key(
3666 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303668 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 const u8 *mac_addr, void *cookie,
3670 void (*callback)(void *cookie, struct key_params*)
3671 )
3672#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303673static int wlan_hdd_cfg80211_get_key(
3674 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 struct net_device *ndev,
3676 u8 key_index, const u8 *mac_addr, void *cookie,
3677 void (*callback)(void *cookie, struct key_params*)
3678 )
3679#endif
3680{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303681 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3683 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3684 struct key_params params;
3685
3686 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303687
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3689 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303690
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 memset(&params, 0, sizeof(params));
3692
3693 if (CSR_MAX_NUM_KEY <= key_index)
3694 {
3695 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003697
3698 switch(pRoamProfile->EncryptionType.encryptionType[0])
3699 {
3700 case eCSR_ENCRYPT_TYPE_NONE:
3701 params.cipher = IW_AUTH_CIPHER_NONE;
3702 break;
3703
3704 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3705 case eCSR_ENCRYPT_TYPE_WEP40:
3706 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3707 break;
3708
3709 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3710 case eCSR_ENCRYPT_TYPE_WEP104:
3711 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3712 break;
3713
3714 case eCSR_ENCRYPT_TYPE_TKIP:
3715 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3716 break;
3717
3718 case eCSR_ENCRYPT_TYPE_AES:
3719 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3720 break;
3721
3722 default:
3723 params.cipher = IW_AUTH_CIPHER_NONE;
3724 break;
3725 }
3726
3727 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3728 params.seq_len = 0;
3729 params.seq = NULL;
3730 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3731 callback(cookie, &params);
3732 return 0;
3733}
3734
3735/*
3736 * FUNCTION: wlan_hdd_cfg80211_del_key
3737 * This function is used to delete the key information
3738 */
3739#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303740static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303742 u8 key_index,
3743 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 const u8 *mac_addr
3745 )
3746#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303747static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 struct net_device *ndev,
3749 u8 key_index,
3750 const u8 *mac_addr
3751 )
3752#endif
3753{
3754 int status = 0;
3755
3756 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303757 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 //it is observed that this is invalidating peer
3759 //key index whenever re-key is done. This is affecting data link.
3760 //It should be ok to ignore del_key.
3761#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303762 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3763 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3765 tCsrRoamSetKey setKey;
3766 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303767
Jeff Johnson295189b2012-06-20 16:38:30 -07003768 ENTER();
3769
3770 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3771 __func__,pAdapter->device_mode);
3772
3773 if (CSR_MAX_NUM_KEY <= key_index)
3774 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303775 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 key_index);
3777
3778 return -EINVAL;
3779 }
3780
3781 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3782 setKey.keyId = key_index;
3783
3784 if (mac_addr)
3785 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3786 else
3787 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3788
3789 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3790
3791 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303793 )
3794 {
3795
3796 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3798 if( pHostapdState->bssState == BSS_START)
3799 {
3800 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303801
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 if ( status != eHAL_STATUS_SUCCESS )
3803 {
3804 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3805 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3806 __LINE__, status );
3807 }
3808 }
3809 }
3810 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303811 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 )
3813 {
3814 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3815
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303816 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3817
3818 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303820 __func__, setKey.peerMac[0], setKey.peerMac[1],
3821 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303823 if(pAdapter->sessionCtx.station.conn_info.connState ==
3824 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303826 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303828
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 if ( 0 != status )
3830 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303831 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 "%s: sme_RoamSetKey failure, returned %d",
3833 __func__, status);
3834 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3835 return -EINVAL;
3836 }
3837 }
3838 }
3839#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003840 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 return status;
3842}
3843
3844/*
3845 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3846 * This function is used to set the default tx key index
3847 */
3848#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3849static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3850 struct net_device *ndev,
3851 u8 key_index,
3852 bool unicast, bool multicast)
3853#else
3854static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3855 struct net_device *ndev,
3856 u8 key_index)
3857#endif
3858{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303859 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303860 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303861 hdd_wext_state_t *pWextState;
3862 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303863 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003864
3865 ENTER();
3866
Gopichand Nakkala29149562013-05-10 21:43:41 +05303867 if ((NULL == pAdapter))
3868 {
3869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3870 "invalid adapter");
3871 return -EINVAL;
3872 }
3873
3874 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3875 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3876
3877 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3878 {
3879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3880 "invalid Wext state or HDD context");
3881 return -EINVAL;
3882 }
3883
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3885 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303886
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 if (CSR_MAX_NUM_KEY <= key_index)
3888 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303889 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003890 key_index);
3891
3892 return -EINVAL;
3893 }
3894
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303895 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3896 status = wlan_hdd_validate_context(pHddCtx);
3897
3898 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003899 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303900 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3901 "%s: HDD context is not valid", __func__);
3902 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003903 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303904
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303907 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303909 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08003910 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303911 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08003912 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303914 {
3915 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303917
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 tCsrRoamSetKey setKey;
3919 v_U32_t roamId= 0xFF;
3920 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303921
3922 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303924
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 Keys->defaultIndex = (u8)key_index;
3926 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3927 setKey.keyId = key_index;
3928 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303929
3930 vos_mem_copy(&setKey.Key[0],
3931 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303933
Gopichand Nakkala29149562013-05-10 21:43:41 +05303934 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303935
3936 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 &pHddStaCtx->conn_info.bssId[0],
3938 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303939
Gopichand Nakkala29149562013-05-10 21:43:41 +05303940 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3941 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3942 eCSR_ENCRYPT_TYPE_WEP104)
3943 {
3944 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3945 even though ap is configured for WEP-40 encryption. In this canse the key length
3946 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3947 type(104) and switching encryption type to 40*/
3948 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3949 eCSR_ENCRYPT_TYPE_WEP40;
3950 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3951 eCSR_ENCRYPT_TYPE_WEP40;
3952 }
3953
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303954 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303956
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303958 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303960
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 if ( 0 != status )
3962 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303963 hddLog(VOS_TRACE_LEVEL_ERROR,
3964 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 status);
3966 return -EINVAL;
3967 }
3968 }
3969 }
3970
3971 /* In SoftAp mode setting key direction for default mode */
3972 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3973 {
3974 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3975 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3976 (eCSR_ENCRYPT_TYPE_AES !=
3977 pWextState->roamProfile.EncryptionType.encryptionType[0])
3978 )
3979 {
3980 /* Saving key direction for default key index to TX default */
3981 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3982 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3983 }
3984 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303985
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 return status;
3987}
3988
Jeff Johnson295189b2012-06-20 16:38:30 -07003989/*
3990 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3991 * This function is used to inform the BSS details to nl80211 interface.
3992 */
3993static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3994 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3995{
3996 struct net_device *dev = pAdapter->dev;
3997 struct wireless_dev *wdev = dev->ieee80211_ptr;
3998 struct wiphy *wiphy = wdev->wiphy;
3999 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
4000 int chan_no;
4001 int ie_length;
4002 const char *ie;
4003 unsigned int freq;
4004 struct ieee80211_channel *chan;
4005 int rssi = 0;
4006 struct cfg80211_bss *bss = NULL;
4007
4008 ENTER();
4009
4010 if( NULL == pBssDesc )
4011 {
4012 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
4013 return bss;
4014 }
4015
4016 chan_no = pBssDesc->channelId;
4017 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
4018 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
4019
4020 if( NULL == ie )
4021 {
4022 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
4023 return bss;
4024 }
4025
4026#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
4027 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
4028 {
4029 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4030 }
4031 else
4032 {
4033 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4034 }
4035#else
4036 freq = ieee80211_channel_to_frequency(chan_no);
4037#endif
4038
4039 chan = __ieee80211_get_channel(wiphy, freq);
4040
4041 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
4042 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
4043 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
4044 if (bss == NULL)
4045 {
4046 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
4047
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304048 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
4049 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 pBssDesc->capabilityInfo,
4051 pBssDesc->beaconInterval, ie, ie_length,
4052 rssi, GFP_KERNEL ));
4053}
4054 else
4055 {
4056 return bss;
4057 }
4058}
4059
4060
4061
4062/*
4063 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4064 * This function is used to inform the BSS details to nl80211 interface.
4065 */
4066struct cfg80211_bss*
4067wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4068 tSirBssDescription *bss_desc
4069 )
4070{
4071 /*
4072 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4073 already exists in bss data base of cfg80211 for that particular BSS ID.
4074 Using cfg80211_inform_bss_frame to update the bss entry instead of
4075 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4076 now there is no possibility to get the mgmt(probe response) frame from PE,
4077 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4078 cfg80211_inform_bss_frame.
4079 */
4080 struct net_device *dev = pAdapter->dev;
4081 struct wireless_dev *wdev = dev->ieee80211_ptr;
4082 struct wiphy *wiphy = wdev->wiphy;
4083 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004084#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4085 qcom_ie_age *qie_age = NULL;
4086 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4087#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004089#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 const char *ie =
4091 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4092 unsigned int freq;
4093 struct ieee80211_channel *chan;
4094 struct ieee80211_mgmt *mgmt =
4095 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
4096 struct cfg80211_bss *bss_status = NULL;
4097 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4098 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07004099 hdd_context_t *pHddCtx;
4100 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07004101#ifdef WLAN_OPEN_SOURCE
4102 struct timespec ts;
4103#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004104
4105 ENTER();
4106
Wilson Yangf80a0542013-10-07 13:02:37 -07004107 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4108 status = wlan_hdd_validate_context(pHddCtx);
4109
4110 /*bss_update is not allowed during wlan driver loading or unloading*/
4111 if (pHddCtx->isLoadUnloadInProgress)
4112 {
4113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4114 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4115 return NULL;
4116 }
4117
4118
4119 if (0 != status)
4120 {
4121 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4122 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004123 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004124 }
4125
4126
4127 if (!mgmt)
4128 {
4129 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4130 "%s: memory allocation failed ", __func__);
4131 return NULL;
4132 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004133
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004135
4136#ifdef WLAN_OPEN_SOURCE
4137 /* Android does not want the timestamp from the frame.
4138 Instead it wants a monotonic increasing value */
4139 get_monotonic_boottime(&ts);
4140 mgmt->u.probe_resp.timestamp =
4141 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4142#else
4143 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004144 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4145 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004146
4147#endif
4148
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4150 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004151
4152#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4153 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4154 /* Assuming this is the last IE, copy at the end */
4155 ie_length -=sizeof(qcom_ie_age);
4156 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4157 qie_age->element_id = QCOM_VENDOR_IE_ID;
4158 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4159 qie_age->oui_1 = QCOM_OUI1;
4160 qie_age->oui_2 = QCOM_OUI2;
4161 qie_age->oui_3 = QCOM_OUI3;
4162 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4163 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4164#endif
4165
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304167 if (bss_desc->fProbeRsp)
4168 {
4169 mgmt->frame_control |=
4170 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4171 }
4172 else
4173 {
4174 mgmt->frame_control |=
4175 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004177
4178#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304179 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4181 {
4182 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4183 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304184 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4186
4187 {
4188 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4189 }
4190 else
4191 {
4192 kfree(mgmt);
4193 return NULL;
4194 }
4195#else
4196 freq = ieee80211_channel_to_frequency(chan_no);
4197#endif
4198 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004199 /*when the band is changed on the fly using the GUI, three things are done
4200 * 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)
4201 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4202 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4203 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4204 * and discards the channels correponding to previous band and calls back with zero bss results.
4205 * 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
4206 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4207 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4208 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4209 * So drop the bss and continue to next bss.
4210 */
4211 if(chan == NULL)
4212 {
4213 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004214 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004215 return NULL;
4216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304218 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 * */
4220 if (( eConnectionState_Associated ==
4221 pAdapter->sessionCtx.station.conn_info.connState ) &&
4222 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4223 pAdapter->sessionCtx.station.conn_info.bssId,
4224 WNI_CFG_BSSID_LEN)))
4225 {
4226 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4227 rssi = (pAdapter->rssi * 100);
4228 }
4229 else
4230 {
4231 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4232 }
4233
4234 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4235 frame_len, rssi, GFP_KERNEL);
4236 kfree(mgmt);
4237 return bss_status;
4238}
4239
4240/*
4241 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4242 * This function is used to update the BSS data base of CFG8011
4243 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304244struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 tCsrRoamInfo *pRoamInfo
4246 )
4247{
4248 tCsrRoamConnectedProfile roamProfile;
4249 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4250 struct cfg80211_bss *bss = NULL;
4251
4252 ENTER();
4253
4254 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4255 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4256
4257 if (NULL != roamProfile.pBssDesc)
4258 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304259 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004260 &roamProfile);
4261
4262 if (NULL == bss)
4263 {
4264 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4265 __func__);
4266 }
4267
4268 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4269 }
4270 else
4271 {
4272 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4273 __func__);
4274 }
4275 return bss;
4276}
4277
4278/*
4279 * FUNCTION: wlan_hdd_cfg80211_update_bss
4280 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304281static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4282 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304284{
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4286 tCsrScanResultInfo *pScanResult;
4287 eHalStatus status = 0;
4288 tScanResultHandle pResult;
4289 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004290 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004291
4292 ENTER();
4293
Wilson Yangf80a0542013-10-07 13:02:37 -07004294 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4295
4296 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 {
Wilson Yangf80a0542013-10-07 13:02:37 -07004298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4299 "%s:LOGP in Progress. Ignore!!!",__func__);
4300 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 }
4302
Wilson Yangf80a0542013-10-07 13:02:37 -07004303
4304 /*bss_update is not allowed during wlan driver loading or unloading*/
4305 if (pHddCtx->isLoadUnloadInProgress)
4306 {
4307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4308 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4309 return VOS_STATUS_E_PERM;
4310 }
4311
4312
Jeff Johnson295189b2012-06-20 16:38:30 -07004313 /*
4314 * start getting scan results and populate cgf80211 BSS database
4315 */
4316 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4317
4318 /* no scan results */
4319 if (NULL == pResult)
4320 {
4321 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4322 return status;
4323 }
4324
4325 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4326
4327 while (pScanResult)
4328 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304329 /*
4330 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4331 * entry already exists in bss data base of cfg80211 for that
4332 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4333 * bss entry instead of cfg80211_inform_bss, But this call expects
4334 * mgmt packet as input. As of now there is no possibility to get
4335 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 * ieee80211_mgmt(probe response) and passing to c
4337 * fg80211_inform_bss_frame.
4338 * */
4339
4340 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4341 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304342
Jeff Johnson295189b2012-06-20 16:38:30 -07004343
4344 if (NULL == bss_status)
4345 {
4346 hddLog(VOS_TRACE_LEVEL_INFO,
4347 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4348 }
4349 else
4350 {
Yue Maf49ba872013-08-19 12:04:25 -07004351 cfg80211_put_bss(
4352#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4353 wiphy,
4354#endif
4355 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 }
4357
4358 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4359 }
4360
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304361 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004362
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304363 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004364}
4365
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004366void
4367hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4368{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304369 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08004370 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004371} /****** end hddPrintMacAddr() ******/
4372
4373void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004374hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004375{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304376 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004377 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4378 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4379 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4380 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004381} /****** end hddPrintPmkId() ******/
4382
4383//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4384//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4385
4386//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4387//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4388
4389#define dump_bssid(bssid) \
4390 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004391 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4392 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4393 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004394 }
4395
4396#define dump_pmkid(pMac, pmkid) \
4397 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004398 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4399 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4400 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004401 }
4402
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004403#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004404/*
4405 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4406 * This function is used to notify the supplicant of a new PMKSA candidate.
4407 */
4408int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304409 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004410 int index, bool preauth )
4411{
Jeff Johnsone7245742012-09-05 17:12:55 -07004412#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004413 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004414 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004415
4416 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004417 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004418
4419 if( NULL == pRoamInfo )
4420 {
4421 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4422 return -EINVAL;
4423 }
4424
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004425 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4426 {
4427 dump_bssid(pRoamInfo->bssid);
4428 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004429 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004430 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004431#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304432 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004433}
4434#endif //FEATURE_WLAN_LFR
4435
Yue Maef608272013-04-08 23:09:17 -07004436#ifdef FEATURE_WLAN_LFR_METRICS
4437/*
4438 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
4439 * 802.11r/LFR metrics reporting function to report preauth initiation
4440 *
4441 */
4442#define MAX_LFR_METRICS_EVENT_LENGTH 100
4443VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
4444 tCsrRoamInfo *pRoamInfo)
4445{
4446 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4447 union iwreq_data wrqu;
4448
4449 ENTER();
4450
4451 if (NULL == pAdapter)
4452 {
4453 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4454 return VOS_STATUS_E_FAILURE;
4455 }
4456
4457 /* create the event */
4458 memset(&wrqu, 0, sizeof(wrqu));
4459 memset(metrics_notification, 0, sizeof(metrics_notification));
4460
4461 wrqu.data.pointer = metrics_notification;
4462 wrqu.data.length = scnprintf(metrics_notification,
4463 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
4464 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4465
4466 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4467
4468 EXIT();
4469
4470 return VOS_STATUS_SUCCESS;
4471}
4472
4473/*
4474 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
4475 * 802.11r/LFR metrics reporting function to report preauth completion
4476 * or failure
4477 */
4478VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
4479 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
4480{
4481 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4482 union iwreq_data wrqu;
4483
4484 ENTER();
4485
4486 if (NULL == pAdapter)
4487 {
4488 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4489 return VOS_STATUS_E_FAILURE;
4490 }
4491
4492 /* create the event */
4493 memset(&wrqu, 0, sizeof(wrqu));
4494 memset(metrics_notification, 0, sizeof(metrics_notification));
4495
4496 scnprintf(metrics_notification, sizeof(metrics_notification),
4497 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
4498 MAC_ADDR_ARRAY(pRoamInfo->bssid));
4499
4500 if (1 == preauth_status)
4501 strncat(metrics_notification, " TRUE", 5);
4502 else
4503 strncat(metrics_notification, " FALSE", 6);
4504
4505 wrqu.data.pointer = metrics_notification;
4506 wrqu.data.length = strlen(metrics_notification);
4507
4508 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4509
4510 EXIT();
4511
4512 return VOS_STATUS_SUCCESS;
4513}
4514
4515/*
4516 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
4517 * 802.11r/LFR metrics reporting function to report handover initiation
4518 *
4519 */
4520VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
4521 tCsrRoamInfo *pRoamInfo)
4522{
4523 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4524 union iwreq_data wrqu;
4525
4526 ENTER();
4527
4528 if (NULL == pAdapter)
4529 {
4530 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4531 return VOS_STATUS_E_FAILURE;
4532 }
4533
4534 /* create the event */
4535 memset(&wrqu, 0, sizeof(wrqu));
4536 memset(metrics_notification, 0, sizeof(metrics_notification));
4537
4538 wrqu.data.pointer = metrics_notification;
4539 wrqu.data.length = scnprintf(metrics_notification,
4540 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
4541 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4542
4543 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4544
4545 EXIT();
4546
4547 return VOS_STATUS_SUCCESS;
4548}
4549#endif
4550
Jeff Johnson295189b2012-06-20 16:38:30 -07004551/*
4552 * FUNCTION: hdd_cfg80211_scan_done_callback
4553 * scanning callback function, called after finishing scan
4554 *
4555 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304556static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4558{
4559 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304560 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004562 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4563 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 struct cfg80211_scan_request *req = NULL;
4565 int ret = 0;
4566
4567 ENTER();
4568
4569 hddLog(VOS_TRACE_LEVEL_INFO,
4570 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304571 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004572 __func__, halHandle, pContext, (int) scanId, (int) status);
4573
Kiet Lamac06e2c2013-10-23 16:25:07 +05304574 pScanInfo->mScanPendingCounter = 0;
4575
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 //Block on scan req completion variable. Can't wait forever though.
4577 ret = wait_for_completion_interruptible_timeout(
4578 &pScanInfo->scan_req_completion_event,
4579 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4580 if (!ret)
4581 {
4582 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004583 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 }
4585
Yue Maef608272013-04-08 23:09:17 -07004586 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 {
4588 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004589 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 }
4591
4592 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304593 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 {
4595 hddLog(VOS_TRACE_LEVEL_INFO,
4596 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304597 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 (int) scanId);
4599 }
4600
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304601 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 pAdapter);
4603
4604 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304605 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004606
4607
4608 /* If any client wait scan result through WEXT
4609 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004610 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 {
4612 /* The other scan request waiting for current scan finish
4613 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004614 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004616 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 }
4618 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004619 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 {
4621 struct net_device *dev = pAdapter->dev;
4622 union iwreq_data wrqu;
4623 int we_event;
4624 char *msg;
4625
4626 memset(&wrqu, '\0', sizeof(wrqu));
4627 we_event = SIOCGIWSCAN;
4628 msg = NULL;
4629 wireless_send_event(dev, we_event, &wrqu, msg);
4630 }
4631 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004632 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004633
4634 /* Get the Scan Req */
4635 req = pAdapter->request;
4636
4637 if (!req)
4638 {
4639 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004640 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004641 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 }
4643
4644 /*
4645 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304646 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004647 req->n_ssids = 0;
4648 req->n_channels = 0;
4649 req->ie = 0;
4650
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004652 /* Scan is no longer pending */
4653 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004654
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004655 /*
4656 * cfg80211_scan_done informing NL80211 about completion
4657 * of scanning
4658 */
4659 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004660 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004661
Jeff Johnsone7245742012-09-05 17:12:55 -07004662allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004663 /* release the wake lock at the end of the scan*/
4664 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004665
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004666 /* Acquire wakelock to handle the case where APP's tries to suspend
4667 * immediatly after the driver gets connect request(i.e after scan)
4668 * from supplicant, this result in app's is suspending and not able
4669 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004670 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004671
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004672#ifdef FEATURE_WLAN_TDLS
4673 wlan_hdd_tdls_scan_done_callback(pAdapter);
4674#endif
4675
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 EXIT();
4677 return 0;
4678}
4679
4680/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004681 * FUNCTION: hdd_isScanAllowed
4682 * Go through each adapter and check if scan allowed
4683 *
4684 */
4685v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4686{
4687 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4688 hdd_station_ctx_t *pHddStaCtx = NULL;
4689 hdd_adapter_t *pAdapter = NULL;
4690 VOS_STATUS status = 0;
4691 v_U8_t staId = 0;
4692 v_U8_t *staMac = NULL;
4693
4694 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4695
4696 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4697 {
4698 pAdapter = pAdapterNode->pAdapter;
4699
4700 if( pAdapter )
4701 {
4702 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304703 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004704 __func__, pAdapter->device_mode);
4705 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4706 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4707 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4708 {
4709 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4710 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4711 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4712 {
4713 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4714 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004715 "%s: client " MAC_ADDRESS_STR
4716 " is in the middle of WPS/EAPOL exchange.", __func__,
4717 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004718 return VOS_FALSE;
4719 }
4720 }
4721 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4722 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4723 {
4724 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4725 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304726 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004727 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4728 {
4729 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4730
4731 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004732 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
4733 "middle of WPS/EAPOL exchange.", __func__,
4734 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004735 return VOS_FALSE;
4736 }
4737 }
4738 }
4739 }
4740 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4741 pAdapterNode = pNext;
4742 }
4743 hddLog(VOS_TRACE_LEVEL_INFO,
4744 "%s: Scan allowed", __func__);
4745 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304746}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004747
4748/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004749 * FUNCTION: wlan_hdd_cfg80211_scan
4750 * this scan respond to scan trigger and update cfg80211 scan database
4751 * later, scan dump command can be used to recieve scan results
4752 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004753int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4754#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4755 struct net_device *dev,
4756#endif
4757 struct cfg80211_scan_request *request)
4758{
4759#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4760 struct net_device *dev = request->wdev->netdev;
4761#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304762 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4764 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304765 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 tCsrScanRequest scanRequest;
4767 tANI_U8 *channelList = NULL, i;
4768 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304769 int status;
4770 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004772
4773 ENTER();
4774
4775 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4776 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004777
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304778 status = wlan_hdd_validate_context(pHddCtx);
4779
4780 if (0 != status)
4781 {
4782 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4783 "%s: HDD context is not valid", __func__);
4784 return status;
4785 }
4786
4787 cfg_param = pHddCtx->cfg_ini;
4788 pScanInfo = &pHddCtx->scan_info;
4789
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004790 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004791 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004792 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004793 {
4794 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004795 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4796 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004797 return -EBUSY;
4798 }
4799
Jeff Johnson295189b2012-06-20 16:38:30 -07004800#ifdef WLAN_BTAMP_FEATURE
4801 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004802 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004804 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 "%s: No scanning when AMP is on", __func__);
4806 return -EOPNOTSUPP;
4807 }
4808#endif
4809 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004810 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004812 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 "%s: Not scanning on device_mode = %d",
4814 __func__, pAdapter->device_mode);
4815 return -EOPNOTSUPP;
4816 }
4817
4818 if (TRUE == pScanInfo->mScanPending)
4819 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05304820 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
4821 {
4822 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
4823 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004824 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 }
4826
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304827 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004828 //Channel and action frame is pending
4829 //Otherwise Cancel Remain On Channel and allow Scan
4830 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004831 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004832 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05304833 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004834 return -EBUSY;
4835 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004836#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004837 /* if tdls disagree scan right now, return immediately.
4838 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4839 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4840 */
4841 status = wlan_hdd_tdls_scan_callback (pAdapter,
4842 wiphy,
4843#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4844 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004845#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004846 request);
4847 if(status <= 0)
4848 {
4849 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4850 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004851 }
4852#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004853
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4855 {
4856 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004857 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004860 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4861 {
4862 hddLog(VOS_TRACE_LEVEL_WARN,
4863 "%s: MAX TM Level Scan not allowed", __func__);
4864 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304865 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004866 }
4867 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4868
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004869 /* Check if scan is allowed at this point of time.
4870 */
4871 if (!hdd_isScanAllowed(pHddCtx))
4872 {
4873 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4874 return -EBUSY;
4875 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304876
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4878
4879 if (NULL != request)
4880 {
4881 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304882 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004883
4884 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4885 * Becasue of this, driver is assuming that this is not wildcard scan and so
4886 * is not aging out the scan results.
4887 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004888 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 {
4890 request->n_ssids = 0;
4891 }
4892
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004893 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 {
4895 tCsrSSIDInfo *SsidInfo;
4896 int j;
4897 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4898 /* Allocate num_ssid tCsrSSIDInfo structure */
4899 SsidInfo = scanRequest.SSIDs.SSIDList =
4900 ( tCsrSSIDInfo *)vos_mem_malloc(
4901 request->n_ssids*sizeof(tCsrSSIDInfo));
4902
4903 if(NULL == scanRequest.SSIDs.SSIDList)
4904 {
4905 hddLog(VOS_TRACE_LEVEL_ERROR,
4906 "memory alloc failed SSIDInfo buffer");
4907 return -ENOMEM;
4908 }
4909
4910 /* copy all the ssid's and their length */
4911 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4912 {
4913 /* get the ssid length */
4914 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4915 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4916 SsidInfo->SSID.length);
4917 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4918 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4919 j, SsidInfo->SSID.ssId);
4920 }
4921 /* set the scan type to active */
4922 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4923 }
4924 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4925 {
4926 /* set the scan type to active */
4927 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4928 }
4929 else
4930 {
4931 /*Set the scan type to default type, in this case it is ACTIVE*/
4932 scanRequest.scanType = pScanInfo->scan_mode;
4933 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304934 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4936 }
4937 else
4938 {
4939 /* set the scan type to active */
4940 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4941 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4942
4943 /* set min and max channel time to zero */
4944 scanRequest.minChnTime = 0;
4945 scanRequest.maxChnTime = 0;
4946 }
4947
4948 /* set BSSType to default type */
4949 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4950
4951 /*TODO: scan the requested channels only*/
4952
4953 /*Right now scanning all the channels */
4954 if( request )
4955 {
4956 if( request->n_channels )
4957 {
4958 channelList = vos_mem_malloc( request->n_channels );
4959 if( NULL == channelList )
4960 {
4961 status = -ENOMEM;
4962 goto free_mem;
4963 }
4964
4965 for( i = 0 ; i < request->n_channels ; i++ )
4966 channelList[i] = request->channels[i]->hw_value;
4967 }
4968
4969 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4970 scanRequest.ChannelInfo.ChannelList = channelList;
4971
4972 /* set requestType to full scan */
4973 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304974
4975 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004976 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304977 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004978 */
4979
4980 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304981 * and in that case driver shoudnt flush scan results. If
4982 * driver flushes the scan results here and unfortunately if
4983 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004984 * fails which is not desired
4985 */
4986
4987 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4988 {
4989 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4990 pAdapter->sessionId );
4991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004992
4993 if( request->ie_len )
4994 {
4995 /* save this for future association (join requires this) */
4996 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4997 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4998 pScanInfo->scanAddIE.length = request->ie_len;
4999
5000 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07005001 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
5002 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 )
5004 {
5005 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
5006 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
5007 }
5008
5009 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
5010 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
5011
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
5013 request->ie_len);
5014 if (pP2pIe != NULL)
5015 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07005016#ifdef WLAN_FEATURE_P2P_DEBUG
5017 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
5018 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
5019 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5020 {
5021 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
5022 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5023 "Go nego completed to Connection is started");
5024 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5025 "for 8way Handshake");
5026 }
5027 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
5028 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5029 {
5030 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
5031 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5032 "Disconnected state to Connection is started");
5033 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5034 "for 4way Handshake");
5035 }
5036#endif
5037
Jeff Johnsone7245742012-09-05 17:12:55 -07005038 /* no_cck will be set during p2p find to disable 11b rates */
5039 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005041 hddLog(VOS_TRACE_LEVEL_INFO,
5042 "%s: This is a P2P Search", __func__);
5043 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07005044
Jeff Johnsone7245742012-09-05 17:12:55 -07005045 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
5046 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07005047 /* set requestType to P2P Discovery */
5048 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07005049 }
5050
5051 /*
5052 Skip Dfs Channel in case of P2P Search
5053 if it is set in ini file
5054 */
5055 if(cfg_param->skipDfsChnlInP2pSearch)
5056 {
5057 scanRequest.skipDfsChnlInP2pSearch = 1;
5058 }
5059 else
5060 {
5061 scanRequest.skipDfsChnlInP2pSearch = 0;
5062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005063
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 }
5065 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005066 }
5067 }
5068
5069 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
5070
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005071 /* acquire the wakelock to avoid the apps suspend during the scan. To
5072 * address the following issues.
5073 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
5074 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
5075 * for long time, this result in apps running at full power for long time.
5076 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
5077 * be stuck in full power because of resume BMPS
5078 */
5079 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07005080
5081 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005082 pAdapter->sessionId, &scanRequest, &scanId,
5083 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07005084
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 if (eHAL_STATUS_SUCCESS != status)
5086 {
5087 hddLog(VOS_TRACE_LEVEL_ERROR,
5088 "%s: sme_ScanRequest returned error %d", __func__, status);
5089 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005090 if(eHAL_STATUS_RESOURCES == status)
5091 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07005092 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 -07005093 status = -EBUSY;
5094 } else {
5095 status = -EIO;
5096 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005097 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 goto free_mem;
5099 }
5100
5101 pScanInfo->mScanPending = TRUE;
5102 pAdapter->request = request;
5103 pScanInfo->scanId = scanId;
5104
5105 complete(&pScanInfo->scan_req_completion_event);
5106
5107free_mem:
5108 if( scanRequest.SSIDs.SSIDList )
5109 {
5110 vos_mem_free(scanRequest.SSIDs.SSIDList);
5111 }
5112
5113 if( channelList )
5114 vos_mem_free( channelList );
5115
5116 EXIT();
5117
5118 return status;
5119}
5120
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005121
5122void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
5123{
5124 v_U8_t iniDot11Mode =
5125 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
5126 eHddDot11Mode hddDot11Mode = iniDot11Mode;
5127
5128 switch ( iniDot11Mode )
5129 {
5130 case eHDD_DOT11_MODE_AUTO:
5131 case eHDD_DOT11_MODE_11ac:
5132 case eHDD_DOT11_MODE_11ac_ONLY:
5133#ifdef WLAN_FEATURE_11AC
5134 hddDot11Mode = eHDD_DOT11_MODE_11ac;
5135#else
5136 hddDot11Mode = eHDD_DOT11_MODE_11n;
5137#endif
5138 break;
5139 case eHDD_DOT11_MODE_11n:
5140 case eHDD_DOT11_MODE_11n_ONLY:
5141 hddDot11Mode = eHDD_DOT11_MODE_11n;
5142 break;
5143 default:
5144 hddDot11Mode = iniDot11Mode;
5145 break;
5146 }
5147 /* This call decides required channel bonding mode */
5148 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
5149 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
5150 operationChannel);
5151}
5152
Jeff Johnson295189b2012-06-20 16:38:30 -07005153/*
5154 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305155 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07005156 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305157int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005158 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005159{
5160 int status = 0;
5161 hdd_wext_state_t *pWextState;
5162 v_U32_t roamId;
5163 tCsrRoamProfile *pRoamProfile;
5164 eMib_dot11DesiredBssType connectedBssType;
5165 eCsrAuthType RSNAuthType;
5166
5167 ENTER();
5168
5169 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305170
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
5172 {
5173 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
5174 return -EINVAL;
5175 }
5176
5177 pRoamProfile = &pWextState->roamProfile;
5178
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305179 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005181 int ret = 0;
5182 hdd_station_ctx_t *pHddStaCtx;
5183 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5184 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
5185
5186 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
5187 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
5188 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07005189 {
5190 /* Issue disconnect to CSR */
5191 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305192 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5194 pAdapter->sessionId,
5195 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
5196 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005197 ret = wait_for_completion_interruptible_timeout(
5198 &pAdapter->disconnect_comp_var,
5199 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5200 if (0 == ret)
5201 {
5202 VOS_ASSERT(0);
5203 }
5204 }
5205 }
5206 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
5207 {
5208 ret = wait_for_completion_interruptible_timeout(
5209 &pAdapter->disconnect_comp_var,
5210 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5211 if (0 == ret)
5212 {
5213 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005214 }
5215 }
5216
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305217 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005218 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5219 {
5220 /*QoS not enabled in cfg file*/
5221 pRoamProfile->uapsd_mask = 0;
5222 }
5223 else
5224 {
5225 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305226 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5228 }
5229
5230 pRoamProfile->SSIDs.numOfSSIDs = 1;
5231 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5232 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305233 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5235 ssid, ssid_len);
5236
5237 if (bssid)
5238 {
5239 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5240 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5241 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305242 /* Save BSSID in seperate variable as well, as RoamProfile
5243 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 case of join failure we should send valid BSSID to supplicant
5245 */
5246 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5247 WNI_CFG_BSSID_LEN);
5248 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005249 else
5250 {
5251 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005253
5254 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5255 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305256 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 /*set gen ie*/
5258 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5259 /*set auth*/
5260 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005262#ifdef FEATURE_WLAN_WAPI
5263 if (pAdapter->wapi_info.nWapiMode)
5264 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005265 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 switch (pAdapter->wapi_info.wapiAuthMode)
5267 {
5268 case WAPI_AUTH_MODE_PSK:
5269 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005270 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005271 pAdapter->wapi_info.wapiAuthMode);
5272 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5273 break;
5274 }
5275 case WAPI_AUTH_MODE_CERT:
5276 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005277 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 pAdapter->wapi_info.wapiAuthMode);
5279 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5280 break;
5281 }
5282 } // End of switch
5283 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5284 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5285 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005286 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 pRoamProfile->AuthType.numEntries = 1;
5288 pRoamProfile->EncryptionType.numEntries = 1;
5289 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5290 pRoamProfile->mcEncryptionType.numEntries = 1;
5291 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5292 }
5293 }
5294#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305295#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305296 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305297 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5298 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5299 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305300 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5301 sizeof (tSirGtkOffloadParams));
5302 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305303 }
5304#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005305 pRoamProfile->csrPersona = pAdapter->device_mode;
5306
Jeff Johnson32d95a32012-09-10 13:15:23 -07005307 if( operatingChannel )
5308 {
5309 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5310 pRoamProfile->ChannelInfo.numOfChannels = 1;
5311 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005312 else
5313 {
5314 pRoamProfile->ChannelInfo.ChannelList = NULL;
5315 pRoamProfile->ChannelInfo.numOfChannels = 0;
5316 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005317 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5318 {
5319 hdd_select_cbmode(pAdapter,operatingChannel);
5320 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005321 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5322 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305323 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005324 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005325 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5326 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305327 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5328 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005329 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5330 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305331
5332 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 pAdapter->sessionId, pRoamProfile, &roamId);
5334
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305335 if ((eHAL_STATUS_SUCCESS != status) &&
5336 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5337 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305338
5339 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005340 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5341 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5342 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305343 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005344 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305345 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005346
5347 pRoamProfile->ChannelInfo.ChannelList = NULL;
5348 pRoamProfile->ChannelInfo.numOfChannels = 0;
5349
Jeff Johnson295189b2012-06-20 16:38:30 -07005350 }
5351 else
5352 {
5353 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5354 return -EINVAL;
5355 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005356 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005357 return status;
5358}
5359
5360/*
5361 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5362 * This function is used to set the authentication type (OPEN/SHARED).
5363 *
5364 */
5365static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5366 enum nl80211_auth_type auth_type)
5367{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305368 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5370
5371 ENTER();
5372
5373 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305374 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005376 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305377 hddLog(VOS_TRACE_LEVEL_INFO,
5378 "%s: set authentication type to AUTOSWITCH", __func__);
5379 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5380 break;
5381
5382 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005383#ifdef WLAN_FEATURE_VOWIFI_11R
5384 case NL80211_AUTHTYPE_FT:
5385#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305386 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005387 "%s: set authentication type to OPEN", __func__);
5388 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5389 break;
5390
5391 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305392 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005393 "%s: set authentication type to SHARED", __func__);
5394 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5395 break;
5396#ifdef FEATURE_WLAN_CCX
5397 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305398 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 "%s: set authentication type to CCKM WPA", __func__);
5400 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5401 break;
5402#endif
5403
5404
5405 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305406 hddLog(VOS_TRACE_LEVEL_ERROR,
5407 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 auth_type);
5409 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5410 return -EINVAL;
5411 }
5412
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305413 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 pHddStaCtx->conn_info.authType;
5415 return 0;
5416}
5417
5418/*
5419 * FUNCTION: wlan_hdd_set_akm_suite
5420 * This function is used to set the key mgmt type(PSK/8021x).
5421 *
5422 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305423static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 u32 key_mgmt
5425 )
5426{
5427 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5428 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305429
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 /*set key mgmt type*/
5431 switch(key_mgmt)
5432 {
5433 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305434#ifdef WLAN_FEATURE_VOWIFI_11R
5435 case WLAN_AKM_SUITE_FT_PSK:
5436#endif
5437 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 __func__);
5439 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5440 break;
5441
5442 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305443#ifdef WLAN_FEATURE_VOWIFI_11R
5444 case WLAN_AKM_SUITE_FT_8021X:
5445#endif
5446 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 __func__);
5448 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5449 break;
5450#ifdef FEATURE_WLAN_CCX
5451#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5452#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5453 case WLAN_AKM_SUITE_CCKM:
5454 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5455 __func__);
5456 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5457 break;
5458#endif
5459
5460 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305461 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 __func__, key_mgmt);
5463 return -EINVAL;
5464
5465 }
5466 return 0;
5467}
5468
5469/*
5470 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305471 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 * (NONE/WEP40/WEP104/TKIP/CCMP).
5473 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305474static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5475 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005476 bool ucast
5477 )
5478{
5479 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305480 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5482
5483 ENTER();
5484
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305485 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005486 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305487 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 __func__, cipher);
5489 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5490 }
5491 else
5492 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305493
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305495 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 {
5497 case IW_AUTH_CIPHER_NONE:
5498 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5499 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305500
Jeff Johnson295189b2012-06-20 16:38:30 -07005501 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305502 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305504
Jeff Johnson295189b2012-06-20 16:38:30 -07005505 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305506 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305508
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 case WLAN_CIPHER_SUITE_TKIP:
5510 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5511 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305512
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 case WLAN_CIPHER_SUITE_CCMP:
5514 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5515 break;
5516#ifdef FEATURE_WLAN_WAPI
5517 case WLAN_CIPHER_SUITE_SMS4:
5518 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5519 break;
5520#endif
5521
5522#ifdef FEATURE_WLAN_CCX
5523 case WLAN_CIPHER_SUITE_KRK:
5524 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5525 break;
5526#endif
5527 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305528 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005529 __func__, cipher);
5530 return -EOPNOTSUPP;
5531 }
5532 }
5533
5534 if (ucast)
5535 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305536 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 __func__, encryptionType);
5538 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5539 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305540 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005541 encryptionType;
5542 }
5543 else
5544 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305545 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 __func__, encryptionType);
5547 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5548 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5549 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5550 }
5551
5552 return 0;
5553}
5554
5555
5556/*
5557 * FUNCTION: wlan_hdd_cfg80211_set_ie
5558 * This function is used to parse WPA/RSN IE's.
5559 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305560int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5561 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 size_t ie_len
5563 )
5564{
5565 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5566 u8 *genie = ie;
5567 v_U16_t remLen = ie_len;
5568#ifdef FEATURE_WLAN_WAPI
5569 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5570 u16 *tmp;
5571 v_U16_t akmsuiteCount;
5572 int *akmlist;
5573#endif
5574 ENTER();
5575
5576 /* clear previous assocAddIE */
5577 pWextState->assocAddIE.length = 0;
5578 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5579
5580 while (remLen >= 2)
5581 {
5582 v_U16_t eLen = 0;
5583 v_U8_t elementId;
5584 elementId = *genie++;
5585 eLen = *genie++;
5586 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305587
5588 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305590
5591 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305593 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005594 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 -07005595 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305596 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 "%s: Invalid WPA IE", __func__);
5598 return -EINVAL;
5599 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305600 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 {
5602 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305603 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305605
Jeff Johnson295189b2012-06-20 16:38:30 -07005606 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5607 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005608 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5609 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 VOS_ASSERT(0);
5611 return -ENOMEM;
5612 }
5613 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5614 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5615 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305616
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5618 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5619 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5620 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305621 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5622 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5624 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5625 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5626 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5627 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5628 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305629 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +05305630 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 {
5632 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305633 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305635
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5637 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005638 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5639 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 VOS_ASSERT(0);
5641 return -ENOMEM;
5642 }
5643 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5644 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5645 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305646
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5648 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005650#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305651 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5652 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 /*Consider WFD IE, only for P2P Client */
5654 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5655 {
5656 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305657 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305659
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5661 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005662 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5663 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 VOS_ASSERT(0);
5665 return -ENOMEM;
5666 }
5667 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5668 // WPS IE + P2P IE + WFD IE
5669 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5670 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305671
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5673 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5674 }
5675#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005676 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305677 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005678 HS20_OUI_TYPE_SIZE)) )
5679 {
5680 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305681 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005682 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005683
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005684 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5685 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005686 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5687 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005688 VOS_ASSERT(0);
5689 return -ENOMEM;
5690 }
5691 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5692 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005693
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005694 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5695 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5696 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005697
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07005698 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
5699
5700 /* populating as ADDIE in beacon frames */
5701 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5702 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
5703 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
5704 {
5705 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5706 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5707 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5708 {
5709 hddLog(LOGE,
5710 "Coldn't pass "
5711 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
5712 }
5713 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
5714 else
5715 hddLog(LOGE,
5716 "Could not pass on "
5717 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
5718
5719 /* IBSS mode doesn't contain params->proberesp_ies still
5720 beaconIE's need to be populated in probe response frames */
5721 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
5722 {
5723 u16 rem_probe_resp_ie_len = eLen + 2;
5724 u8 probe_rsp_ie_len[3] = {0};
5725 u8 counter = 0;
5726
5727 /* Check Probe Resp Length if it is greater then 255 then
5728 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
5729 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
5730 not able Store More then 255 bytes into One Variable */
5731
5732 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5733 {
5734 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5735 {
5736 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5737 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5738 }
5739 else
5740 {
5741 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5742 rem_probe_resp_ie_len = 0;
5743 }
5744 }
5745
5746 rem_probe_resp_ie_len = 0;
5747
5748 if (probe_rsp_ie_len[0] > 0)
5749 {
5750 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5751 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5752 (tANI_U8*)(genie - 2),
5753 probe_rsp_ie_len[0], NULL,
5754 eANI_BOOLEAN_FALSE)
5755 == eHAL_STATUS_FAILURE)
5756 {
5757 hddLog(LOGE,
5758 "Could not pass"
5759 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
5760 }
5761 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5762 }
5763
5764 if (probe_rsp_ie_len[1] > 0)
5765 {
5766 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5767 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5768 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5769 probe_rsp_ie_len[1], NULL,
5770 eANI_BOOLEAN_FALSE)
5771 == eHAL_STATUS_FAILURE)
5772 {
5773 hddLog(LOGE,
5774 "Could not pass"
5775 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
5776 }
5777 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5778 }
5779
5780 if (probe_rsp_ie_len[2] > 0)
5781 {
5782 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5783 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5784 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5785 probe_rsp_ie_len[2], NULL,
5786 eANI_BOOLEAN_FALSE)
5787 == eHAL_STATUS_FAILURE)
5788 {
5789 hddLog(LOGE,
5790 "Could not pass"
5791 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
5792 }
5793 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5794 }
5795
5796 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5797 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5798 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5799 {
5800 hddLog(LOGE,
5801 "Could not pass"
5802 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
5803 }
5804 }
5805 else
5806 {
5807 // Reset WNI_CFG_PROBE_RSP Flags
5808 wlan_hdd_reset_prob_rspies(pAdapter);
5809
5810 hddLog(VOS_TRACE_LEVEL_INFO,
5811 "%s: No Probe Response IE received in set beacon",
5812 __func__);
5813 }
5814 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 break;
5816 case DOT11F_EID_RSN:
5817 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5818 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5819 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5820 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5821 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5822 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005823 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5824 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305825 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005826 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305827 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005828 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305829
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005830 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5831 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005832 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5833 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005834 VOS_ASSERT(0);
5835 return -ENOMEM;
5836 }
5837 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5838 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305839
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005840 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5841 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5842 break;
5843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005844#ifdef FEATURE_WLAN_WAPI
5845 case WLAN_EID_WAPI:
5846 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005847 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 pAdapter->wapi_info.nWapiMode);
5849 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305850 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 akmsuiteCount = WPA_GET_LE16(tmp);
5852 tmp = tmp + 1;
5853 akmlist = (int *)(tmp);
5854 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5855 {
5856 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5857 }
5858 else
5859 {
5860 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5861 VOS_ASSERT(0);
5862 return -EINVAL;
5863 }
5864
5865 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5866 {
5867 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005868 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305872 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005873 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005874 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5876 }
5877 break;
5878#endif
5879 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305880 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005882 /* when Unknown IE is received we should break and continue
5883 * to the next IE in the buffer instead we were returning
5884 * so changing this to break */
5885 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 }
5887 genie += eLen;
5888 remLen -= eLen;
5889 }
5890 EXIT();
5891 return 0;
5892}
5893
5894/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305895 * FUNCTION: hdd_isWPAIEPresent
5896 * Parse the received IE to find the WPA IE
5897 *
5898 */
5899static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5900{
5901 v_U8_t eLen = 0;
5902 v_U16_t remLen = ie_len;
5903 v_U8_t elementId = 0;
5904
5905 while (remLen >= 2)
5906 {
5907 elementId = *ie++;
5908 eLen = *ie++;
5909 remLen -= 2;
5910 if (eLen > remLen)
5911 {
5912 hddLog(VOS_TRACE_LEVEL_ERROR,
5913 "%s: IE length is wrong %d", __func__, eLen);
5914 return FALSE;
5915 }
5916 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5917 {
5918 /* OUI - 0x00 0X50 0XF2
5919 WPA Information Element - 0x01
5920 WPA version - 0x01*/
5921 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5922 return TRUE;
5923 }
5924 ie += eLen;
5925 remLen -= eLen;
5926 }
5927 return FALSE;
5928}
5929
5930/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305932 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 * parameters during connect operation.
5934 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305935int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 struct cfg80211_connect_params *req
5937 )
5938{
5939 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305940 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 ENTER();
5942
5943 /*set wpa version*/
5944 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5945
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305946 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305948 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 {
5950 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5951 }
5952 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5953 {
5954 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5955 }
5956 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305957
5958 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 pWextState->wpaVersion);
5960
5961 /*set authentication type*/
5962 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5963
5964 if (0 > status)
5965 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305966 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 "%s: failed to set authentication type ", __func__);
5968 return status;
5969 }
5970
5971 /*set key mgmt type*/
5972 if (req->crypto.n_akm_suites)
5973 {
5974 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5975 if (0 > status)
5976 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305977 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 __func__);
5979 return status;
5980 }
5981 }
5982
5983 /*set pairwise cipher type*/
5984 if (req->crypto.n_ciphers_pairwise)
5985 {
5986 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5987 req->crypto.ciphers_pairwise[0], true);
5988 if (0 > status)
5989 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305990 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005991 "%s: failed to set unicast cipher type", __func__);
5992 return status;
5993 }
5994 }
5995 else
5996 {
5997 /*Reset previous cipher suite to none*/
5998 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5999 if (0 > status)
6000 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306001 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 "%s: failed to set unicast cipher type", __func__);
6003 return status;
6004 }
6005 }
6006
6007 /*set group cipher type*/
6008 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
6009 false);
6010
6011 if (0 > status)
6012 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306013 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 __func__);
6015 return status;
6016 }
6017
Chet Lanctot186b5732013-03-18 10:26:30 -07006018#ifdef WLAN_FEATURE_11W
6019 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
6020#endif
6021
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
6023 if (req->ie_len)
6024 {
6025 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
6026 if ( 0 > status)
6027 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306028 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 __func__);
6030 return status;
6031 }
6032 }
6033
6034 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306035 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 {
6037 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
6038 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
6039 )
6040 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306041 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
6043 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306044 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 __func__);
6046 return -EOPNOTSUPP;
6047 }
6048 else
6049 {
6050 u8 key_len = req->key_len;
6051 u8 key_idx = req->key_idx;
6052
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306053 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 && (CSR_MAX_NUM_KEY > key_idx)
6055 )
6056 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306057 hddLog(VOS_TRACE_LEVEL_INFO,
6058 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 __func__, key_idx, key_len);
6060 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306061 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306063 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 (u8)key_len;
6065 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
6066 }
6067 }
6068 }
6069 }
6070
6071 return status;
6072}
6073
6074/*
6075 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306076 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 * parameters during connect operation.
6078 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306079static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006080 struct net_device *ndev,
6081 struct cfg80211_connect_params *req
6082 )
6083{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306084 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306085 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
6087 hdd_context_t *pHddCtx = NULL;
6088
6089 ENTER();
6090
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306091 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006092 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6093
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306094 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6095 status = wlan_hdd_validate_context(pHddCtx);
6096
6097 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306099 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6100 "%s: HDD context is not valid", __func__);
6101 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 }
6103
6104#ifdef WLAN_BTAMP_FEATURE
6105 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306106 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306108 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08006110 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 }
6112#endif
6113 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306114 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07006115
6116 if ( 0 > status)
6117 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306118 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07006119 __func__);
6120 return status;
6121 }
6122
6123 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006124 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
6126 (vos_concurrent_sessions_running()))
6127 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306128 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 }
6130
Mohit Khanna765234a2012-09-11 15:08:35 -07006131 if ( req->channel )
6132 {
6133 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
6134 req->ssid_len, req->bssid,
6135 req->channel->hw_value);
6136 }
6137 else
6138 {
6139 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306140 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07006141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006142
6143 if (0 > status)
6144 {
6145 //ReEnable BMPS if disabled
6146 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
6147 (NULL != pHddCtx))
6148 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306149 if (pHddCtx->hdd_wlan_suspended)
6150 {
6151 hdd_set_pwrparams(pHddCtx);
6152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 //ReEnable Bmps and Imps back
6154 hdd_enable_bmps_imps(pHddCtx);
6155 }
6156
6157 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6158 return status;
6159 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306160 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 EXIT();
6162 return status;
6163}
6164
6165
6166/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306167 * FUNCTION: wlan_hdd_disconnect
6168 * This function is used to issue a disconnect request to SME
6169 */
6170int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
6171{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306172 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306173 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306174 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6175
6176 status = wlan_hdd_validate_context(pHddCtx);
6177
6178 if (0 != status)
6179 {
6180 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6181 "%s: HDD context is not valid", __func__);
6182 return status;
6183 }
6184
6185 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306186 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306187 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306188
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306189 /*issue disconnect*/
6190 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6191 pAdapter->sessionId, reason);
6192
6193 if ( 0 != status )
6194 {
6195 hddLog(VOS_TRACE_LEVEL_ERROR,
6196 "%s csrRoamDisconnect failure, returned %d \n",
6197 __func__, (int)status );
6198 return -EINVAL;
6199 }
6200 wait_for_completion_interruptible_timeout(
6201 &pAdapter->disconnect_comp_var,
6202 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6203 /*stop tx queues*/
6204 netif_tx_disable(pAdapter->dev);
6205 netif_carrier_off(pAdapter->dev);
6206 return status;
6207}
6208
6209
6210/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 * FUNCTION: wlan_hdd_cfg80211_disconnect
6212 * This function is used to issue a disconnect request to SME
6213 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306214static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006215 struct net_device *dev,
6216 u16 reason
6217 )
6218{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306219 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6220 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306222 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006224 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306225#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006226 tANI_U8 staIdx;
6227#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306228
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306230
6231 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006232 __func__,pAdapter->device_mode);
6233
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306234 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6235 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006236
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306237 status = wlan_hdd_validate_context(pHddCtx);
6238
6239 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306241 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6242 "%s: HDD context is not valid", __func__);
6243 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306245
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 if (NULL != pRoamProfile)
6247 {
6248 /*issue disconnect request to SME, if station is in connected state*/
6249 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
6250 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306251 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006252 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306253 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006254 switch(reason)
6255 {
6256 case WLAN_REASON_MIC_FAILURE:
6257 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6258 break;
6259
6260 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6261 case WLAN_REASON_DISASSOC_AP_BUSY:
6262 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6263 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6264 break;
6265
6266 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6267 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6268 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6269 break;
6270
6271 case WLAN_REASON_DEAUTH_LEAVING:
6272 default:
6273 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6274 break;
6275 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306276 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6277 pScanInfo = &pHddCtx->scan_info;
6278 if (pScanInfo->mScanPending)
6279 {
6280 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
6281 "Aborting Scan");
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306282 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006284
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006285#ifdef FEATURE_WLAN_TDLS
6286 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006287 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006288 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006289 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6290 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006291 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006292 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006293 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006294 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006295 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006296 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006297 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006298 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006299 pAdapter->sessionId,
6300 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006301 }
6302 }
6303#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306304 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6305 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 {
6307 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306308 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 __func__, (int)status );
6310 return -EINVAL;
6311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006312 }
6313 }
6314 else
6315 {
6316 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6317 }
6318
6319 return status;
6320}
6321
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306322
Jeff Johnson295189b2012-06-20 16:38:30 -07006323/*
6324 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306325 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 * settings in IBSS mode.
6327 */
6328static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306329 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 struct cfg80211_ibss_params *params
6331 )
6332{
6333 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306334 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6336 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306337
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 ENTER();
6339
6340 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -07006341 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006342
6343 if (params->ie_len && ( NULL != params->ie) )
6344 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006345 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6346 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 {
6348 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6349 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6350 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006351 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006353 tDot11fIEWPA dot11WPAIE;
6354 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006355 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006356
Wilson Yang00256342013-10-10 23:13:38 -07006357 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006358 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6359 params->ie_len, DOT11F_EID_WPA);
6360 if ( NULL != ie )
6361 {
6362 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6363 // Unpack the WPA IE
6364 //Skip past the EID byte and length byte - and four byte WiFi OUI
6365 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6366 &ie[2+4],
6367 ie[1] - 4,
6368 &dot11WPAIE);
6369 /*Extract the multicast cipher, the encType for unicast
6370 cipher for wpa-none is none*/
6371 encryptionType =
6372 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006375
Jeff Johnson295189b2012-06-20 16:38:30 -07006376 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6377
6378 if (0 > status)
6379 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306380 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 __func__);
6382 return status;
6383 }
6384 }
6385
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306386 pWextState->roamProfile.AuthType.authType[0] =
6387 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006388 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6389
6390 if (params->privacy)
6391 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306392 /* Security enabled IBSS, At this time there is no information available
6393 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006394 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306395 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306397 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 *enable privacy bit in beacons */
6399
6400 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6401 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006402 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6403 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6405 pWextState->roamProfile.EncryptionType.numEntries = 1;
6406 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 return status;
6408}
6409
6410/*
6411 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306412 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306414static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006415 struct net_device *dev,
6416 struct cfg80211_ibss_params *params
6417 )
6418{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306419 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6421 tCsrRoamProfile *pRoamProfile;
6422 int status;
krunal sonie9002db2013-11-25 14:24:17 -08006423 bool alloc_bssid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006424 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306425 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006426
6427 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306428
6429 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6431
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306432 status = wlan_hdd_validate_context(pHddCtx);
6433
6434 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006435 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306436 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6437 "%s: HDD context is not valid", __func__);
6438 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 }
6440
6441 if (NULL == pWextState)
6442 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306443 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006444 __func__);
6445 return -EIO;
6446 }
6447
6448 pRoamProfile = &pWextState->roamProfile;
6449
6450 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6451 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306452 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 "%s Interface type is not set to IBSS \n", __func__);
6454 return -EINVAL;
6455 }
6456
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006457 /* BSSID is provided by upper layers hence no need to AUTO generate */
6458 if (NULL != params->bssid) {
6459 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6460 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
6461 hddLog (VOS_TRACE_LEVEL_ERROR,
6462 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6463 return -EIO;
6464 }
6465 }
krunal sonie9002db2013-11-25 14:24:17 -08006466 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
6467 {
6468 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6469 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6470 {
6471 hddLog (VOS_TRACE_LEVEL_ERROR,
6472 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6473 return -EIO;
6474 }
6475 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
6476 if (!params->bssid)
6477 {
6478 hddLog (VOS_TRACE_LEVEL_ERROR,
6479 "%s:Failed memory allocation", __func__);
6480 return -EIO;
6481 }
6482 vos_mem_copy((v_U8_t *)params->bssid,
6483 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
6484 VOS_MAC_ADDR_SIZE);
6485 alloc_bssid = VOS_TRUE;
6486 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006487
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006489 if (NULL !=
6490#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6491 params->chandef.chan)
6492#else
6493 params->channel)
6494#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006495 {
6496 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006497 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6498 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6499 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6500 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006501
6502 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306503 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006504 ieee80211_frequency_to_channel(
6505#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6506 params->chandef.chan->center_freq);
6507#else
6508 params->channel->center_freq);
6509#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006510
6511 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6512 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006513 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006514 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6515 __func__);
6516 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006517 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006518
6519 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006521 if (channelNum == validChan[indx])
6522 {
6523 break;
6524 }
6525 }
6526 if (indx >= numChans)
6527 {
6528 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 __func__, channelNum);
6530 return -EINVAL;
6531 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006532 /* Set the Operational Channel */
6533 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6534 channelNum);
6535 pRoamProfile->ChannelInfo.numOfChannels = 1;
6536 pHddStaCtx->conn_info.operationChannel = channelNum;
6537 pRoamProfile->ChannelInfo.ChannelList =
6538 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 }
6540
6541 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306542 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006543 if (status < 0)
6544 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306545 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006546 __func__);
6547 return status;
6548 }
6549
6550 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306551 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006552 params->ssid_len, params->bssid,
6553 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006554
6555 if (0 > status)
6556 {
6557 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6558 return status;
6559 }
6560
krunal sonie9002db2013-11-25 14:24:17 -08006561 if (NULL != params->bssid &&
6562 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
6563 alloc_bssid == VOS_TRUE)
6564 {
6565 vos_mem_free(params->bssid);
6566 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 return 0;
6568}
6569
6570/*
6571 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306572 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006573 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306574static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 struct net_device *dev
6576 )
6577{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306578 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6580 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306581 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6582 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006583
6584 ENTER();
6585
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306586 status = wlan_hdd_validate_context(pHddCtx);
6587
6588 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006589 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306590 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6591 "%s: HDD context is not valid", __func__);
6592 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006593 }
6594
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6596 if (NULL == pWextState)
6597 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306598 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006599 __func__);
6600 return -EIO;
6601 }
6602
6603 pRoamProfile = &pWextState->roamProfile;
6604
6605 /* Issue disconnect only if interface type is set to IBSS */
6606 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6607 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306608 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 __func__);
6610 return -EINVAL;
6611 }
6612
6613 /* Issue Disconnect request */
6614 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6615 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6616 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6617
6618 return 0;
6619}
6620
6621/*
6622 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6623 * This function is used to set the phy parameters
6624 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6625 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306626static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 u32 changed)
6628{
6629 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6630 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306631 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006632
6633 ENTER();
6634
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306635 status = wlan_hdd_validate_context(pHddCtx);
6636
6637 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006638 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306639 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6640 "%s: HDD context is not valid", __func__);
6641 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006642 }
6643
Jeff Johnson295189b2012-06-20 16:38:30 -07006644 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6645 {
6646 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6647 WNI_CFG_RTS_THRESHOLD_STAMAX :
6648 wiphy->rts_threshold;
6649
6650 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306651 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306653 hddLog(VOS_TRACE_LEVEL_ERROR,
6654 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 __func__, rts_threshold);
6656 return -EINVAL;
6657 }
6658
6659 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6660 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306661 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306663 hddLog(VOS_TRACE_LEVEL_ERROR,
6664 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 __func__, rts_threshold);
6666 return -EIO;
6667 }
6668
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306669 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 rts_threshold);
6671 }
6672
6673 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6674 {
6675 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6676 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6677 wiphy->frag_threshold;
6678
6679 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306680 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306682 hddLog(VOS_TRACE_LEVEL_ERROR,
6683 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 frag_threshold);
6685 return -EINVAL;
6686 }
6687
6688 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6689 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306690 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306692 hddLog(VOS_TRACE_LEVEL_ERROR,
6693 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006694 __func__, frag_threshold);
6695 return -EIO;
6696 }
6697
6698 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6699 frag_threshold);
6700 }
6701
6702 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6703 || (changed & WIPHY_PARAM_RETRY_LONG))
6704 {
6705 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6706 wiphy->retry_short :
6707 wiphy->retry_long;
6708
6709 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6710 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6711 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306712 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006713 __func__, retry_value);
6714 return -EINVAL;
6715 }
6716
6717 if (changed & WIPHY_PARAM_RETRY_SHORT)
6718 {
6719 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6720 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306721 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306723 hddLog(VOS_TRACE_LEVEL_ERROR,
6724 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006725 __func__, retry_value);
6726 return -EIO;
6727 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306728 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006729 __func__, retry_value);
6730 }
6731 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6732 {
6733 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6734 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306735 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306737 hddLog(VOS_TRACE_LEVEL_ERROR,
6738 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 __func__, retry_value);
6740 return -EIO;
6741 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306742 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006743 __func__, retry_value);
6744 }
6745 }
6746
6747 return 0;
6748}
6749
6750/*
6751 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6752 * This function is used to set the txpower
6753 */
6754static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006755#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6756 struct wireless_dev *wdev,
6757#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006758#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306759 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006760#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306761 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006762#endif
6763 int dbm)
6764{
6765 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306766 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006767 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6768 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306769 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006770
6771 ENTER();
6772
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306773 status = wlan_hdd_validate_context(pHddCtx);
6774
6775 if (0 != status)
6776 {
6777 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6778 "%s: HDD context is not valid", __func__);
6779 return status;
6780 }
6781
6782 hHal = pHddCtx->hHal;
6783
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306784 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6785 dbm, ccmCfgSetCallback,
6786 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006787 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306788 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006789 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6790 return -EIO;
6791 }
6792
6793 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6794 dbm);
6795
6796 switch(type)
6797 {
6798 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6799 /* Fall through */
6800 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6801 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6802 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306803 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6804 __func__);
6805 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 }
6807 break;
6808 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306809 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006810 __func__);
6811 return -EOPNOTSUPP;
6812 break;
6813 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306814 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6815 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006816 return -EIO;
6817 }
6818
6819 return 0;
6820}
6821
6822/*
6823 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6824 * This function is used to read the txpower
6825 */
Yue Maf49ba872013-08-19 12:04:25 -07006826static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6827#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6828 struct wireless_dev *wdev,
6829#endif
6830 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006831{
6832
6833 hdd_adapter_t *pAdapter;
6834 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306835 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006836
Jeff Johnsone7245742012-09-05 17:12:55 -07006837 ENTER();
6838
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306839 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006840
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306841 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006842 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6844 "%s: HDD context is not valid", __func__);
6845 *dbm = 0;
6846 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006847 }
6848
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6850 if (NULL == pAdapter)
6851 {
6852 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6853 return -ENOENT;
6854 }
6855
6856 wlan_hdd_get_classAstats(pAdapter);
6857 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6858
Jeff Johnsone7245742012-09-05 17:12:55 -07006859 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006860 return 0;
6861}
6862
6863static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6864 u8* mac, struct station_info *sinfo)
6865{
6866 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6867 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6868 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6869 tANI_U8 rate_flags;
6870
6871 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6872 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006873
6874 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6875 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6876 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6877 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6878 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6879 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6880 tANI_U16 maxRate = 0;
6881 tANI_U16 myRate;
6882 tANI_U16 currentRate = 0;
6883 tANI_U8 maxSpeedMCS = 0;
6884 tANI_U8 maxMCSIdx = 0;
6885 tANI_U8 rateFlag = 1;
6886 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006887 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306888 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006889
Leo Chang6f8870f2013-03-26 18:11:36 -07006890#ifdef WLAN_FEATURE_11AC
6891 tANI_U32 vht_mcs_map;
6892 eDataRate11ACMaxMcs vhtMaxMcs;
6893#endif /* WLAN_FEATURE_11AC */
6894
Jeff Johnsone7245742012-09-05 17:12:55 -07006895 ENTER();
6896
Jeff Johnson295189b2012-06-20 16:38:30 -07006897 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6898 (0 == ssidlen))
6899 {
6900 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6901 " Invalid ssidlen, %d", __func__, ssidlen);
6902 /*To keep GUI happy*/
6903 return 0;
6904 }
6905
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306906 status = wlan_hdd_validate_context(pHddCtx);
6907
6908 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006909 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306910 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6911 "%s: HDD context is not valid", __func__);
6912 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006913 }
6914
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006915 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006916 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6917
Kiet Lam3b17fc82013-09-27 05:24:08 +05306918 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6919 sinfo->filled |= STATION_INFO_SIGNAL;
6920
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 //convert to the UI units of 100kbps
6922 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6923
6924#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006925 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 -07006926 sinfo->signal,
6927 pCfg->reportMaxLinkSpeed,
6928 myRate,
6929 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006930 (int) pCfg->linkSpeedRssiMid,
6931 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006932 (int) rate_flags,
6933 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006934#endif //LINKSPEED_DEBUG_ENABLED
6935
6936 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6937 {
6938 // we do not want to necessarily report the current speed
6939 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6940 {
6941 // report the max possible speed
6942 rssidx = 0;
6943 }
6944 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6945 {
6946 // report the max possible speed with RSSI scaling
6947 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6948 {
6949 // report the max possible speed
6950 rssidx = 0;
6951 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006952 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006953 {
6954 // report middle speed
6955 rssidx = 1;
6956 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006957 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6958 {
6959 // report middle speed
6960 rssidx = 2;
6961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006962 else
6963 {
6964 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006965 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006966 }
6967 }
6968 else
6969 {
6970 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6971 hddLog(VOS_TRACE_LEVEL_ERROR,
6972 "%s: Invalid value for reportMaxLinkSpeed: %u",
6973 __func__, pCfg->reportMaxLinkSpeed);
6974 rssidx = 0;
6975 }
6976
6977 maxRate = 0;
6978
6979 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306980 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6981 OperationalRates, &ORLeng))
6982 {
6983 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6984 /*To keep GUI happy*/
6985 return 0;
6986 }
6987
Jeff Johnson295189b2012-06-20 16:38:30 -07006988 for (i = 0; i < ORLeng; i++)
6989 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006990 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006991 {
6992 /* Validate Rate Set */
6993 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6994 {
6995 currentRate = supported_data_rate[j].supported_rate[rssidx];
6996 break;
6997 }
6998 }
6999 /* Update MAX rate */
7000 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7001 }
7002
7003 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307004 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
7005 ExtendedRates, &ERLeng))
7006 {
7007 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7008 /*To keep GUI happy*/
7009 return 0;
7010 }
7011
Jeff Johnson295189b2012-06-20 16:38:30 -07007012 for (i = 0; i < ERLeng; i++)
7013 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007014 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 {
7016 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
7017 {
7018 currentRate = supported_data_rate[j].supported_rate[rssidx];
7019 break;
7020 }
7021 }
7022 /* Update MAX rate */
7023 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7024 }
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307025 /* Get MCS Rate Set --
7026 only if we are connected at MCS rates (or)
7027 if we are always reporting max speed (or)
7028 if we have good rssi */
7029 if (((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) ||
7030 (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed))
Jeff Johnson295189b2012-06-20 16:38:30 -07007031 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307032 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
7033 MCSRates, &MCSLeng))
7034 {
7035 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7036 /*To keep GUI happy*/
7037 return 0;
7038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007039 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07007040#ifdef WLAN_FEATURE_11AC
7041 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307042 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07007043 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007044 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307045 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07007046 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07007047 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007048 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007049 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007050 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07007051 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007052 maxMCSIdx = 7;
7053 }
7054 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
7055 {
7056 maxMCSIdx = 8;
7057 }
7058 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
7059 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307060 //VHT20 is supporting 0~8
7061 if (rate_flags & eHAL_TX_RATE_VHT20)
7062 maxMCSIdx = 8;
7063 else
7064 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07007065 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307066
7067 if (rate_flags & eHAL_TX_RATE_VHT80)
7068 {
7069 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
7070 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
7071 }
7072 else if (rate_flags & eHAL_TX_RATE_VHT40)
7073 {
7074 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
7075 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
7076 }
7077 else if (rate_flags & eHAL_TX_RATE_VHT20)
7078 {
7079 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
7080 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
7081 }
7082
Leo Chang6f8870f2013-03-26 18:11:36 -07007083 maxSpeedMCS = 1;
7084 if (currentRate > maxRate)
7085 {
7086 maxRate = currentRate;
7087 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307088
Leo Chang6f8870f2013-03-26 18:11:36 -07007089 }
7090 else
7091#endif /* WLAN_FEATURE_11AC */
7092 {
7093 if (rate_flags & eHAL_TX_RATE_HT40)
7094 {
7095 rateFlag |= 1;
7096 }
7097 if (rate_flags & eHAL_TX_RATE_SGI)
7098 {
7099 rateFlag |= 2;
7100 }
7101
7102 for (i = 0; i < MCSLeng; i++)
7103 {
7104 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
7105 for (j = 0; j < temp; j++)
7106 {
7107 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
7108 {
7109 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
7110 break;
7111 }
7112 }
7113 if ((j < temp) && (currentRate > maxRate))
7114 {
7115 maxRate = currentRate;
7116 maxSpeedMCS = 1;
7117 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
7118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 }
7120 }
7121 }
7122
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307123 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
7124 {
7125 maxRate = myRate;
7126 maxSpeedMCS = 1;
7127 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7128 }
7129
Jeff Johnson295189b2012-06-20 16:38:30 -07007130 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007131 if (((maxRate < myRate) && (0 == rssidx)) ||
7132 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 {
7134 maxRate = myRate;
7135 if (rate_flags & eHAL_TX_RATE_LEGACY)
7136 {
7137 maxSpeedMCS = 0;
7138 }
7139 else
7140 {
7141 maxSpeedMCS = 1;
7142 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7143 }
7144 }
7145
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307146 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 {
7148 sinfo->txrate.legacy = maxRate;
7149#ifdef LINKSPEED_DEBUG_ENABLED
7150 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7151#endif //LINKSPEED_DEBUG_ENABLED
7152 }
7153 else
7154 {
7155 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007156#ifdef WLAN_FEATURE_11AC
7157 sinfo->txrate.nss = 1;
7158 if (rate_flags & eHAL_TX_RATE_VHT80)
7159 {
7160 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307161 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007162 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307163 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007164 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307165 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7166 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7167 }
7168 else if (rate_flags & eHAL_TX_RATE_VHT20)
7169 {
7170 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7171 }
7172#endif /* WLAN_FEATURE_11AC */
7173 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7174 {
7175 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7176 if (rate_flags & eHAL_TX_RATE_HT40)
7177 {
7178 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7179 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007180 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007181 if (rate_flags & eHAL_TX_RATE_SGI)
7182 {
7183 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7184 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307185
Jeff Johnson295189b2012-06-20 16:38:30 -07007186#ifdef LINKSPEED_DEBUG_ENABLED
7187 pr_info("Reporting MCS rate %d flags %x\n",
7188 sinfo->txrate.mcs,
7189 sinfo->txrate.flags );
7190#endif //LINKSPEED_DEBUG_ENABLED
7191 }
7192 }
7193 else
7194 {
7195 // report current rate instead of max rate
7196
7197 if (rate_flags & eHAL_TX_RATE_LEGACY)
7198 {
7199 //provide to the UI in units of 100kbps
7200 sinfo->txrate.legacy = myRate;
7201#ifdef LINKSPEED_DEBUG_ENABLED
7202 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7203#endif //LINKSPEED_DEBUG_ENABLED
7204 }
7205 else
7206 {
7207 //must be MCS
7208 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007209#ifdef WLAN_FEATURE_11AC
7210 sinfo->txrate.nss = 1;
7211 if (rate_flags & eHAL_TX_RATE_VHT80)
7212 {
7213 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7214 }
7215 else
7216#endif /* WLAN_FEATURE_11AC */
7217 {
7218 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7219 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007220 if (rate_flags & eHAL_TX_RATE_SGI)
7221 {
7222 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7223 }
7224 if (rate_flags & eHAL_TX_RATE_HT40)
7225 {
7226 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7227 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007228#ifdef WLAN_FEATURE_11AC
7229 else if (rate_flags & eHAL_TX_RATE_VHT80)
7230 {
7231 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7232 }
7233#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007234#ifdef LINKSPEED_DEBUG_ENABLED
7235 pr_info("Reporting actual MCS rate %d flags %x\n",
7236 sinfo->txrate.mcs,
7237 sinfo->txrate.flags );
7238#endif //LINKSPEED_DEBUG_ENABLED
7239 }
7240 }
7241 sinfo->filled |= STATION_INFO_TX_BITRATE;
7242
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007243 sinfo->tx_packets =
7244 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7245 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7246 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7247 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7248
7249 sinfo->tx_retries =
7250 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7251 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7252 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7253 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7254
7255 sinfo->tx_failed =
7256 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7257 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7258 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7259 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7260
7261 sinfo->filled |=
7262 STATION_INFO_TX_PACKETS |
7263 STATION_INFO_TX_RETRIES |
7264 STATION_INFO_TX_FAILED;
7265
7266 EXIT();
7267 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007268}
7269
7270static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007271 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007272{
7273 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307274 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307276 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007277
Jeff Johnsone7245742012-09-05 17:12:55 -07007278 ENTER();
7279
Jeff Johnson295189b2012-06-20 16:38:30 -07007280 if (NULL == pAdapter)
7281 {
7282 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7283 return -ENODEV;
7284 }
7285
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307286 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307287 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307288
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307289 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307290 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307291 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7292 "%s: HDD context is not valid", __func__);
7293 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307294 }
7295
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307296 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7297 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7298 (pHddCtx->cfg_ini->fhostArpOffload) &&
7299 (eConnectionState_Associated ==
7300 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7301 {
Amar Singhald53568e2013-09-26 11:03:45 -07007302
7303 hddLog(VOS_TRACE_LEVEL_INFO,
7304 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307305 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307306 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7307 {
7308 hddLog(VOS_TRACE_LEVEL_INFO,
7309 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
7310 __func__, vos_status);
7311 }
7312 }
7313
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 /**The get power cmd from the supplicant gets updated by the nl only
7315 *on successful execution of the function call
7316 *we are oppositely mapped w.r.t mode in the driver
7317 **/
7318 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7319
Jeff Johnsone7245742012-09-05 17:12:55 -07007320 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007321 if (VOS_STATUS_E_FAILURE == vos_status)
7322 {
7323 return -EINVAL;
7324 }
7325 return 0;
7326}
7327
7328
7329#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7330static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7331 struct net_device *netdev,
7332 u8 key_index)
7333{
Jeff Johnsone7245742012-09-05 17:12:55 -07007334 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 return 0;
7336}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307337#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007338
7339#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7340static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7341 struct net_device *dev,
7342 struct ieee80211_txq_params *params)
7343{
Jeff Johnsone7245742012-09-05 17:12:55 -07007344 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 return 0;
7346}
7347#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7348static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7349 struct ieee80211_txq_params *params)
7350{
Jeff Johnsone7245742012-09-05 17:12:55 -07007351 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007352 return 0;
7353}
7354#endif //LINUX_VERSION_CODE
7355
7356static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7357 struct net_device *dev, u8 *mac)
7358{
7359 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307360 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007361 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307362 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007363 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007364
Jeff Johnsone7245742012-09-05 17:12:55 -07007365 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307366 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007367 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307368 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007369 return -EINVAL;
7370 }
7371
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307372 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7373 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007374
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307375 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007376 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307377 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7378 "%s: HDD context is not valid", __func__);
7379 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007380 }
7381
Jeff Johnson295189b2012-06-20 16:38:30 -07007382 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 )
7385 {
7386 if( NULL == mac )
7387 {
7388 v_U16_t i;
7389 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7390 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007391 if ((pAdapter->aStaInfo[i].isUsed) &&
7392 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007393 {
7394 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7395 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007396 "%s: Delete STA with MAC::"
7397 MAC_ADDRESS_STR,
7398 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007399 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7400 if (VOS_IS_STATUS_SUCCESS(vos_status))
7401 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007402 }
7403 }
7404 }
7405 else
7406 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007407
7408 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7409 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7410 {
7411 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007412 "%s: Skip this DEL STA as this is not used::"
7413 MAC_ADDRESS_STR,
7414 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007415 return -ENOENT;
7416 }
7417
7418 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7419 {
7420 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007421 "%s: Skip this DEL STA as deauth is in progress::"
7422 MAC_ADDRESS_STR,
7423 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007424 return -ENOENT;
7425 }
7426
7427 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7428
Jeff Johnson295189b2012-06-20 16:38:30 -07007429 hddLog(VOS_TRACE_LEVEL_INFO,
7430 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007431 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007432 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007433 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007434
7435 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7436 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7437 {
7438 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7439 hddLog(VOS_TRACE_LEVEL_INFO,
7440 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007441 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007442 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007443 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007444 return -ENOENT;
7445 }
7446
Jeff Johnson295189b2012-06-20 16:38:30 -07007447 }
7448 }
7449
7450 EXIT();
7451
7452 return 0;
7453}
7454
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007455static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7456 struct net_device *dev, u8 *mac, struct station_parameters *params)
7457{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007458 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007459#ifdef FEATURE_WLAN_TDLS
7460 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007461 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007462 mask = params->sta_flags_mask;
7463
7464 set = params->sta_flags_set;
7465
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007466#ifdef WLAN_FEATURE_TDLS_DEBUG
7467 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7468 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7469 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7470#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007471
7472 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7473 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007474 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007475 }
7476 }
7477#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007478 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007479}
7480
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007481
7482#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07007483#define MAX_PMKSAIDS_IN_CACHE 8
7484
7485static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
7486static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
7487
7488
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007489static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007490 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007491{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307492 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007493 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7494 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307495 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307496 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007497 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307498 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307499
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007500 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
7501 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07007502
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307503 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307504 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007505 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307506 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007507 return -EINVAL;
7508 }
7509
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307510 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7511 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007512
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307513 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007514 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307515 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7516 "%s: HDD context is not valid", __func__);
7517 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007518 }
7519
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307520 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007521 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7522
Wilson Yang6507c4e2013-10-01 20:11:19 -07007523 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007524 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307525 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007526 pmksa->bssid, WNI_CFG_BSSID_LEN))
7527 {
7528 /* BSSID matched previous entry. Overwrite it. */
7529 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307530 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007531 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307532 vos_mem_copy(PMKIDCache[j].PMKID,
7533 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007534 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307535 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007536 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007537 dump_bssid(pmksa->bssid);
7538 dump_pmkid(halHandle, pmksa->pmkid);
7539 break;
7540 }
7541 }
7542
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007543 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07007544 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007545
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007546 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307547 {
7548 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07007549 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307550 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007551 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307552 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007553 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307554 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007555 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007556 dump_bssid(pmksa->bssid);
7557 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307558 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007559 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07007560 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007561 }
7562
7563
7564 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307565 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007566 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307567 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007568 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007569 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307570 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7571 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007572 PMKIDCacheIndex);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007573 return 0;
7574}
7575
7576
Wilson Yang6507c4e2013-10-01 20:11:19 -07007577
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007578static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007579 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007580{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007581 tANI_U32 j=0;
7582 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7583 tHalHandle halHandle;
7584 int status;
7585 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07007586 hdd_context_t *pHddCtx;
7587 int result = 0;
7588
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007589 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
7590 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07007591
7592 /* Validate pAdapter */
7593 if (NULL == pAdapter)
7594 {
7595 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
7596 return -EINVAL;
7597 }
7598
7599 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7600 status = wlan_hdd_validate_context(pHddCtx);
7601
7602 if (0 != status)
7603 {
7604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7605 "%s: HDD context is not valid", __func__);
7606 return status;
7607 }
7608
7609 /*Retrieve halHandle*/
7610 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7611
7612 /*in case index is 0,no entry to delete*/
7613 if (0 == PMKIDCacheIndex)
7614 {
7615 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7616 __func__);
7617 return -EINVAL;
7618 }
7619
7620 /*find the matching PMKSA entry from j=0 to (index-1),
7621 * and delete the matched one
7622 */
7623 for (j = 0; j<PMKIDCacheIndex; j++)
7624 {
7625 if (vos_mem_compare(PMKIDCache[j].BSSID,
7626 pmksa->bssid,
7627 WNI_CFG_BSSID_LEN))
7628 {
7629 /* BSSID matched entry */
7630 BSSIDMatched = 1;
7631
7632 if (j<PMKIDCacheIndex-1)
7633 {
7634 /*replace the matching entry with the last entry in HDD local cache*/
7635 vos_mem_copy(PMKIDCache[j].BSSID,
7636 PMKIDCache[PMKIDCacheIndex-1].BSSID,
7637 WNI_CFG_BSSID_LEN);
7638 vos_mem_copy(PMKIDCache[j].PMKID,
7639 PMKIDCache[PMKIDCacheIndex-1].PMKID,
7640 CSR_RSN_PMKID_SIZE);
7641 }
7642
7643 /*clear the last entry in HDD cache ---[index-1]*/
Wilson Yang6507c4e2013-10-01 20:11:19 -07007644 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
7645 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
7646
7647 /*reduce the PMKID array index*/
7648 PMKIDCacheIndex--;
7649
7650 /*delete the last PMKID cache in CSR*/
Kiet Lam8d21d5b2013-10-31 17:18:29 +05307651 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007652 if (0 != result)
7653 {
7654 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
7655 __func__,PMKIDCacheIndex);
7656 }
7657
7658 dump_bssid(pmksa->bssid);
7659 dump_pmkid(halHandle,pmksa->pmkid);
7660
7661 break;
7662 }
7663 }
7664
7665 /* we compare all entries,but cannot find matching entry */
7666 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
7667 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007668 hddLog(VOS_TRACE_LEVEL_FATAL,
7669 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
7670 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07007671 dump_bssid(pmksa->bssid);
7672 dump_pmkid(halHandle, pmksa->pmkid);
7673 return -EINVAL;
7674 }
7675 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007676}
7677
Wilson Yang6507c4e2013-10-01 20:11:19 -07007678
7679
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007680static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7681{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007682 tANI_U32 j=0;
7683 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7684 tHalHandle halHandle;
7685 hdd_context_t *pHddCtx;
7686 tANI_U8 *pBSSId;
7687 int status;
7688 int result;
7689
7690 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
7691
7692 /* Validate pAdapter */
7693 if (NULL == pAdapter)
7694 {
7695 hddLog(VOS_TRACE_LEVEL_ERROR,
7696 "%s: Invalid Adapter" ,__func__);
7697 return -EINVAL;
7698 }
7699
7700 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7701 status = wlan_hdd_validate_context(pHddCtx);
7702
7703 if (0 != status)
7704 {
7705 hddLog(VOS_TRACE_LEVEL_ERROR,
7706 "%s: HDD context is not valid", __func__);
7707 return status;
7708 }
7709
7710 /*Retrieve halHandle*/
7711 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7712
7713 /*in case index is 0,no entry to delete*/
7714 if (0 == PMKIDCacheIndex)
7715 {
7716 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7717 __func__);
7718 return -EINVAL;
7719 }
7720
7721 /*delete all the PMKSA one by one */
7722 for (j = 0; j<PMKIDCacheIndex; j++)
7723 {
Wilson Yang6507c4e2013-10-01 20:11:19 -07007724 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007725
7726 /*delete the PMKID in CSR*/
7727 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7728
7729 if (0!= result)
7730 {
7731 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
7732 __func__,j);
7733 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +05307734 /*clear the entry in HDD cache 0--index-1 */
7735 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
7736 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007737 }
7738
7739 PMKIDCacheIndex = 0;
7740 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007741}
7742#endif
7743
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007744#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307745static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007746 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7747{
7748 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7749 hdd_station_ctx_t *pHddStaCtx;
7750
7751 if (NULL == pAdapter)
7752 {
7753 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7754 return -ENODEV;
7755 }
7756
7757 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7758
7759 // Added for debug on reception of Re-assoc Req.
7760 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7761 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307762 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007763 ftie->ie_len);
7764 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7765 }
7766
7767#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307768 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007769 ftie->ie_len);
7770#endif
7771
7772 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307773 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7774 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007775 ftie->ie_len);
7776 return 0;
7777}
7778#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007779
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307780#ifdef FEATURE_WLAN_SCAN_PNO
7781
7782void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7783 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7784{
7785 int ret;
7786 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7787 hdd_context_t *pHddCtx;
7788
7789 if (NULL == pAdapter)
7790 {
7791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7792 "%s: HDD adapter is Null", __func__);
7793 return ;
7794 }
7795
7796 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7797 if (NULL == pHddCtx)
7798 {
7799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7800 "%s: HDD context is Null!!!", __func__);
7801 return ;
7802 }
7803
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307804 spin_lock(&pHddCtx->schedScan_lock);
7805 if (TRUE == pHddCtx->isWiphySuspended)
7806 {
7807 pHddCtx->isSchedScanUpdatePending = TRUE;
7808 spin_unlock(&pHddCtx->schedScan_lock);
7809 hddLog(VOS_TRACE_LEVEL_INFO,
7810 "%s: Update cfg80211 scan database after it resume", __func__);
7811 return ;
7812 }
7813 spin_unlock(&pHddCtx->schedScan_lock);
7814
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307815 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7816
7817 if (0 > ret)
7818 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7819
7820 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7822 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307823}
7824
7825/*
7826 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7827 * NL interface to enable PNO
7828 */
7829static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7830 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7831{
7832 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7833 tpSirPNOScanReq pPnoRequest = NULL;
7834 hdd_context_t *pHddCtx;
7835 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307836 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307837 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7838 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7839 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7840 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307841 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307842
7843 if (NULL == pAdapter)
7844 {
7845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7846 "%s: HDD adapter is Null", __func__);
7847 return -ENODEV;
7848 }
7849
7850 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307851 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307852
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307853 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307854 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7856 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307857 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307858 }
7859
7860 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7861 if (NULL == hHal)
7862 {
7863 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7864 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307865 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307866 }
7867
7868 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7869 if (NULL == pPnoRequest)
7870 {
7871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7872 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307873 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307874 }
7875
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05307876 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307877 pPnoRequest->enable = 1; /*Enable PNO */
7878 pPnoRequest->ucNetworksCount = request->n_match_sets;
7879
7880 if (( !pPnoRequest->ucNetworksCount ) ||
7881 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7882 {
7883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7884 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307885 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307886 goto error;
7887 }
7888
7889 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7890 {
7891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7892 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307893 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307894 goto error;
7895 }
7896
7897 /* Framework provides one set of channels(all)
7898 * common for all saved profile */
7899 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7900 channels_allowed, &num_channels_allowed))
7901 {
7902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7903 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307904 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307905 goto error;
7906 }
7907 /* Checking each channel against allowed channel list */
7908 num_ch = 0;
7909 for (i = 0; i < request->n_channels; i++)
7910 {
7911 for (indx = 0; indx < num_channels_allowed; indx++)
7912 {
7913 if (request->channels[i]->hw_value == channels_allowed[indx])
7914 {
7915 valid_ch[num_ch++] = request->channels[i]->hw_value;
7916 break ;
7917 }
7918 }
7919 }
7920
7921 /* Filling per profile params */
7922 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7923 {
7924 pPnoRequest->aNetworks[i].ssId.length =
7925 request->match_sets[i].ssid.ssid_len;
7926
7927 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7928 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7929 {
7930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7931 "SSID Len %d is not correct for network %d",
7932 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307933 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307934 goto error;
7935 }
7936
7937 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7938 request->match_sets[i].ssid.ssid,
7939 request->match_sets[i].ssid.ssid_len);
7940 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7941 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7942 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7943
7944 /*Copying list of valid channel into request */
7945 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7946 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7947
7948 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7949 }
7950
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05307951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7952 "request->ie_len = %d", request->ie_len);
7953 if ((0 < request->ie_len) && (NULL != request->ie))
7954 {
7955 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
7956 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
7957 pPnoRequest->us24GProbeTemplateLen);
7958
7959 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
7960 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
7961 pPnoRequest->us5GProbeTemplateLen);
7962 }
7963
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307964 /* Driver gets only one time interval which is hardcoded in
7965 * supplicant for 10000ms. Taking power consumption into account 6 timers
7966 * will be used, Timervalue is increased exponentially i.e 10,20,40,
7967 * 80,160,320 secs. And number of scan cycle for each timer
7968 * is configurable through INI param gPNOScanTimerRepeatValue.
7969 * If it is set to 0 only one timer will be used and PNO scan cycle
7970 * will be repeated after each interval specified by supplicant
7971 * till PNO is disabled.
7972 */
7973 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
7974 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
7975 else
7976 pPnoRequest->scanTimers.ucScanTimersCount =
7977 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
7978
7979 tempInterval = (request->interval)/1000;
7980 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7981 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
7982 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
7983 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
7984 {
7985 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
7986 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
7987 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
7988 tempInterval *= 2;
7989 }
7990 //Repeat last timer until pno disabled.
7991 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
7992
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05307993 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307994
7995 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7996 pPnoRequest, pAdapter->sessionId,
7997 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7998 if (eHAL_STATUS_SUCCESS != status)
7999 {
8000 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8001 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308002 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308003 goto error;
8004 }
8005
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8007 "PNO scanRequest offloaded");
8008
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308009error:
8010 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308011 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308012}
8013
8014/*
8015 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
8016 * NL interface to disable PNO
8017 */
8018static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
8019 struct net_device *dev)
8020{
8021 eHalStatus status = eHAL_STATUS_FAILURE;
8022 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8023 hdd_context_t *pHddCtx;
8024 tHalHandle hHal;
8025 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308026 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308027
8028 ENTER();
8029
8030 if (NULL == pAdapter)
8031 {
8032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8033 "%s: HDD adapter is Null", __func__);
8034 return -ENODEV;
8035 }
8036
8037 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308038
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308039 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308040 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308041 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308042 "%s: HDD context is Null", __func__);
8043 return -ENODEV;
8044 }
8045
8046 /* The return 0 is intentional when isLogpInProgress and
8047 * isLoadUnloadInProgress. We did observe a crash due to a return of
8048 * failure in sched_scan_stop , especially for a case where the unload
8049 * of the happens at the same time. The function __cfg80211_stop_sched_scan
8050 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
8051 * success. If it returns a failure , then its next invocation due to the
8052 * clean up of the second interface will have the dev pointer corresponding
8053 * to the first one leading to a crash.
8054 */
8055 if (pHddCtx->isLogpInProgress)
8056 {
8057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8058 "%s: LOGP in Progress. Ignore!!!", __func__);
8059 return ret;
8060 }
8061
8062 if (pHddCtx->isLoadUnloadInProgress)
8063 {
8064 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8065 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8066 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308067 }
8068
8069 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8070 if (NULL == hHal)
8071 {
8072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8073 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308074 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308075 }
8076
8077 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8078 if (NULL == pPnoRequest)
8079 {
8080 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8081 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308082 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308083 }
8084
8085 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
8086 pPnoRequest->enable = 0; /* Disable PNO */
8087 pPnoRequest->ucNetworksCount = 0;
8088
8089 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
8090 pAdapter->sessionId,
8091 NULL, pAdapter);
8092 if (eHAL_STATUS_SUCCESS != status)
8093 {
8094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8095 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308096 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308097 }
8098
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308099 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8100 "%s: PNO scan disabled", __func__);
8101
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308102 vos_mem_free(pPnoRequest);
8103
8104 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308105 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308106}
8107
8108#endif /*FEATURE_WLAN_SCAN_PNO*/
8109
8110
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008111#ifdef FEATURE_WLAN_TDLS
8112static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
8113 u8 *peer, u8 action_code, u8 dialog_token,
8114 u16 status_code, const u8 *buf, size_t len)
8115{
8116
8117 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8118 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008119 u8 peerMac[6];
8120 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008121 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08008122 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008123 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008124
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008125 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008126 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308127 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008128 "Invalid arguments");
8129 return -EINVAL;
8130 }
8131
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008132 if (pHddCtx->isLogpInProgress)
8133 {
8134 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8135 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008136 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008137 return -EBUSY;
8138 }
8139
Hoonki Lee27511902013-03-14 18:19:06 -07008140 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008141 {
Hoonki Lee27511902013-03-14 18:19:06 -07008142 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8143 "%s: TDLS mode is disabled OR not enabled in FW."
8144 MAC_ADDRESS_STR " action %d declined.",
8145 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008146 return -ENOTSUPP;
8147 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008148
Hoonki Lee27511902013-03-14 18:19:06 -07008149 /* other than teardown frame, other mgmt frames are not sent if disabled */
8150 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8151 {
8152 /* if tdls_mode is disabled to respond to peer's request */
8153 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8154 {
8155 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8156 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008157 " TDLS mode is disabled. action %d declined.",
8158 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008159
8160 return -ENOTSUPP;
8161 }
8162 }
8163
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008164 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8165 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308166 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008167 {
8168 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008169 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008170 " TDLS setup is ongoing. action %d declined.",
8171 __func__, MAC_ADDR_ARRAY(peer), action_code);
8172 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008173 }
8174 }
8175
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008176 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8177 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008178 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008179 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008180 {
8181 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
8182 we return error code at 'add_station()'. Hence we have this
8183 check again in addtion to add_station().
8184 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008185 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008186 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008187 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8188 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008189 " TDLS Max peer already connected. action %d declined.",
8190 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008191 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08008192 }
8193 else
8194 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008195 /* maximum reached. tweak to send error code to peer and return
8196 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008197 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008198 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8199 "%s: " MAC_ADDRESS_STR
8200 " TDLS Max peer already connected send response status %d",
8201 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008202 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008203 /* fall through to send setup resp with failure status
8204 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008205 }
8206 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008207 else
8208 {
8209 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308210 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008211 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008212 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008213 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008214 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
8215 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008216 return -EPERM;
8217 }
8218 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008219 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008220 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008221
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008222#ifdef WLAN_FEATURE_TDLS_DEBUG
8223 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008224 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
8225 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
8226 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008227#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008228
Hoonki Leea34dd892013-02-05 22:56:02 -08008229 /*Except teardown responder will not be used so just make 0*/
8230 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008231 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08008232 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008233
8234 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308235 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008236
8237 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
8238 responder = pTdlsPeer->is_responder;
8239 else
Hoonki Leea34dd892013-02-05 22:56:02 -08008240 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008241 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8242 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
8243 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
8244 dialog_token, status_code, len);
8245 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08008246 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008247 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008248
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308249 /* For explicit trigger of DIS_REQ come out of BMPS for
8250 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008251 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308252 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8253 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008254 {
8255 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8256 {
8257 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308258 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008259 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8260 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308261 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8262 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008263 }
8264
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008265 /* make sure doesn't call send_mgmt() while it is pending */
8266 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8267 {
8268 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8269 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
8270 __func__, MAC_ADDR_ARRAY(peer), action_code);
8271 return -EBUSY;
8272 }
8273
8274 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008275 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
8276
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008277 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08008278 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008279
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008280 if (VOS_STATUS_SUCCESS != status)
8281 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8283 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008284 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07008285 wlan_hdd_tdls_check_bmps(pAdapter);
8286 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008287 }
8288
Hoonki Leed37cbb32013-04-20 00:31:14 -07008289 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
8290 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
8291
8292 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008293 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07008294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008295 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -07008296 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008297 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008298 wlan_hdd_tdls_check_bmps(pAdapter);
8299 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008300 }
8301
Gopichand Nakkala05922802013-03-14 12:23:19 -07008302 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07008303 {
8304 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008305 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07008306 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008307
Hoonki Leea34dd892013-02-05 22:56:02 -08008308 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
8309 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008310 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008311 }
8312 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
8313 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008314 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008315 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008316
8317 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008318error:
8319 /* max_sta_failed ; we didn't set to CONNECTING for this case,
8320 because we already know that this transaction will be failed,
8321 but we weren't sure if supplicant call DISABLE_LINK or not. So,
8322 to be safe, do not change the state mahine.
8323 */
8324 if(max_sta_failed == 0 &&
8325 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
8326 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
8327 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008328}
8329
8330static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
8331 u8 *peer, enum nl80211_tdls_operation oper)
8332{
8333 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8334 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308335 int status;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008336#ifdef WLAN_FEATURE_TDLS_DEBUG
8337 const char *tdls_oper_str[]= {
8338 "NL80211_TDLS_DISCOVERY_REQ",
8339 "NL80211_TDLS_SETUP",
8340 "NL80211_TDLS_TEARDOWN",
8341 "NL80211_TDLS_ENABLE_LINK",
8342 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05308343 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008344#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008345 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008346
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308347 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008348 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008349 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008350 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008351 return -EINVAL;
8352 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008353
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308354 status = wlan_hdd_validate_context(pHddCtx);
8355
8356 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008357 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308358 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8359 "%s: HDD context is not valid", __func__);
8360 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008361 }
8362
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308363 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008364
8365 if ( NULL == pTdlsPeer ) {
8366 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
8367 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8368 return -EINVAL;
8369 }
8370
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008371#ifdef WLAN_FEATURE_TDLS_DEBUG
8372 if((int)oper > 4)
8373 oper = 5;
8374
8375 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008376 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8377 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008378 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008379#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008380
8381 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008382 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008383 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008384 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008385 "TDLS Disabled in INI OR not enabled in FW. "
8386 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008387 return -ENOTSUPP;
8388 }
8389
8390 switch (oper) {
8391 case NL80211_TDLS_ENABLE_LINK:
8392 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008393 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308394 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008395
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07008396 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
8397 {
8398 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
8399 MAC_ADDRESS_STR " failed",
8400 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
8401 return -EINVAL;
8402 }
8403
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008404 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008405 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308406 long ret;
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308407 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308408
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308409 if (0 != wlan_hdd_tdls_get_link_establish_params(
8410 pAdapter, peer,&tdlsLinkEstablishParams)) {
8411 return -EINVAL;
8412 }
8413 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308414
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308415 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
8416 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
8417 /* Send TDLS peer UAPSD capabilities to the firmware and
8418 * register with the TL on after the response for this operation
8419 * is received .
8420 */
8421 ret = wait_for_completion_interruptible_timeout(
8422 &pAdapter->tdls_link_establish_req_comp,
8423 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
8424 if (ret <= 0)
8425 {
8426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8427 "%s: Link Establish Request Faled Status %ld",
8428 __func__, ret);
8429 return -EINVAL;
8430 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308431 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008432 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05308433 /* Mark TDLS client Authenticated .*/
8434 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
8435 pTdlsPeer->staId,
8436 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008437 if (VOS_STATUS_SUCCESS == status)
8438 {
Hoonki Lee14621352013-04-16 17:51:19 -07008439 if (pTdlsPeer->is_responder == 0)
8440 {
8441 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
8442
8443 wlan_hdd_tdls_timer_restart(pAdapter,
8444 &pTdlsPeer->initiatorWaitTimeoutTimer,
8445 WAIT_TIME_TDLS_INITIATOR);
8446 /* suspend initiator TX until it receives direct packet from the
8447 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
8448 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8449 &staId, NULL);
8450 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008451 wlan_hdd_tdls_increment_peer_count(pAdapter);
8452 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008453 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308454
8455 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308456 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
8457 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308458 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308459 int ac;
8460 uint8 ucAc[4] = { WLANTL_AC_VO,
8461 WLANTL_AC_VI,
8462 WLANTL_AC_BK,
8463 WLANTL_AC_BE };
8464 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
8465 for(ac=0; ac < 4; ac++)
8466 {
8467 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8468 pTdlsPeer->staId, ucAc[ac],
8469 tlTid[ac], tlTid[ac], 0, 0,
8470 WLANTL_BI_DIR );
8471 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308472 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008473 }
8474
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008475 }
8476 break;
8477 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08008478 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008479 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008480 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008481 long status;
8482
8483 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
8484
Lee Hoonkic1262f22013-01-24 21:59:00 -08008485 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
8486 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008487
8488 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
8489 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
8490 if (status <= 0)
8491 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008492 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8494 "%s: Del station failed status %ld",
8495 __func__, status);
8496 return -EPERM;
8497 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008498 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008499 }
8500 else
8501 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008502 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8503 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008504 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008505 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008506 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008507 case NL80211_TDLS_TEARDOWN:
8508 case NL80211_TDLS_SETUP:
8509 case NL80211_TDLS_DISCOVERY_REQ:
8510 /* We don't support in-driver setup/teardown/discovery */
8511 return -ENOTSUPP;
8512 default:
8513 return -ENOTSUPP;
8514 }
8515 return 0;
8516}
Chilam NG571c65a2013-01-19 12:27:36 +05308517
8518int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
8519 struct net_device *dev, u8 *peer)
8520{
Arif Hussaina7c8e412013-11-20 11:06:42 -08008521 hddLog(VOS_TRACE_LEVEL_INFO,
8522 "tdls send discover req: "MAC_ADDRESS_STR,
8523 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +05308524
8525 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
8526 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
8527}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008528#endif
8529
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308530#ifdef WLAN_FEATURE_GTK_OFFLOAD
8531/*
8532 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
8533 * Callback rountine called upon receiving response for
8534 * get offload info
8535 */
8536void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
8537 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
8538{
8539
8540 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308541 tANI_U8 tempReplayCounter[8];
8542 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308543
8544 ENTER();
8545
8546 if (NULL == pAdapter)
8547 {
8548 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8549 "%s: HDD adapter is Null", __func__);
8550 return ;
8551 }
8552
8553 if (NULL == pGtkOffloadGetInfoRsp)
8554 {
8555 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8556 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
8557 return ;
8558 }
8559
8560 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
8561 {
8562 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8563 "%s: wlan Failed to get replay counter value",
8564 __func__);
8565 return ;
8566 }
8567
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308568 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8569 /* Update replay counter */
8570 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
8571 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8572
8573 {
8574 /* changing from little to big endian since supplicant
8575 * works on big endian format
8576 */
8577 int i;
8578 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8579
8580 for (i = 0; i < 8; i++)
8581 {
8582 tempReplayCounter[7-i] = (tANI_U8)p[i];
8583 }
8584 }
8585
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308586 /* Update replay counter to NL */
8587 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308588 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308589}
8590
8591/*
8592 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
8593 * This function is used to offload GTK rekeying job to the firmware.
8594 */
8595int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
8596 struct cfg80211_gtk_rekey_data *data)
8597{
8598 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8599 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8600 hdd_station_ctx_t *pHddStaCtx;
8601 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308602 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308603 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308604 eHalStatus status = eHAL_STATUS_FAILURE;
8605
8606 ENTER();
8607
8608 if (NULL == pAdapter)
8609 {
8610 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8611 "%s: HDD adapter is Null", __func__);
8612 return -ENODEV;
8613 }
8614
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308615 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308616
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308617 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308618 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308619 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8620 "%s: HDD context is not valid", __func__);
8621 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308622 }
8623
8624 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8625 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8626 if (NULL == hHal)
8627 {
8628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8629 "%s: HAL context is Null!!!", __func__);
8630 return -EAGAIN;
8631 }
8632
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308633 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8634 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8635 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8636 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308637 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308638 {
8639 /* changing from big to little endian since driver
8640 * works on little endian format
8641 */
8642 tANI_U8 *p =
8643 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8644 int i;
8645
8646 for (i = 0; i < 8; i++)
8647 {
8648 p[7-i] = data->replay_ctr[i];
8649 }
8650 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308651
8652 if (TRUE == pHddCtx->hdd_wlan_suspended)
8653 {
8654 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308655 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8656 sizeof (tSirGtkOffloadParams));
8657 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308658 pAdapter->sessionId);
8659
8660 if (eHAL_STATUS_SUCCESS != status)
8661 {
8662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8663 "%s: sme_SetGTKOffload failed, returned %d",
8664 __func__, status);
8665 return status;
8666 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8668 "%s: sme_SetGTKOffload successfull", __func__);
8669 }
8670 else
8671 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308672 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8673 "%s: wlan not suspended GTKOffload request is stored",
8674 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308675 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308676
8677 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308678}
8679#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8680
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308681/*
8682 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8683 * This function is used to set access control policy
8684 */
8685static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8686 struct net_device *dev, const struct cfg80211_acl_data *params)
8687{
8688 int i;
8689 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8690 hdd_hostapd_state_t *pHostapdState;
8691 tsap_Config_t *pConfig;
8692 v_CONTEXT_t pVosContext = NULL;
8693 hdd_context_t *pHddCtx;
8694 int status;
8695
8696 ENTER();
8697
8698 if (NULL == pAdapter)
8699 {
8700 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8701 "%s: HDD adapter is Null", __func__);
8702 return -ENODEV;
8703 }
8704
8705 if (NULL == params)
8706 {
8707 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8708 "%s: params is Null", __func__);
8709 return -EINVAL;
8710 }
8711
8712 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8713 status = wlan_hdd_validate_context(pHddCtx);
8714
8715 if (0 != status)
8716 {
8717 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8718 "%s: HDD context is not valid", __func__);
8719 return status;
8720 }
8721
8722 pVosContext = pHddCtx->pvosContext;
8723 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8724
8725 if (NULL == pHostapdState)
8726 {
8727 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8728 "%s: pHostapdState is Null", __func__);
8729 return -EINVAL;
8730 }
8731
8732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8733 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8734
8735 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8736 {
8737 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8738
8739 /* default value */
8740 pConfig->num_accept_mac = 0;
8741 pConfig->num_deny_mac = 0;
8742
8743 /**
8744 * access control policy
8745 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8746 * listed in hostapd.deny file.
8747 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8748 * listed in hostapd.accept file.
8749 */
8750 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8751 {
8752 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8753 }
8754 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8755 {
8756 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8757 }
8758 else
8759 {
8760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8761 "%s:Acl Policy : %d is not supported",
8762 __func__, params->acl_policy);
8763 return -ENOTSUPP;
8764 }
8765
8766 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8767 {
8768 pConfig->num_accept_mac = params->n_acl_entries;
8769 for (i = 0; i < params->n_acl_entries; i++)
8770 {
8771 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8772 "** Add ACL MAC entry %i in WhiletList :"
8773 MAC_ADDRESS_STR, i,
8774 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8775
8776 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8777 sizeof(qcmacaddr));
8778 }
8779 }
8780 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8781 {
8782 pConfig->num_deny_mac = params->n_acl_entries;
8783 for (i = 0; i < params->n_acl_entries; i++)
8784 {
8785 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8786 "** Add ACL MAC entry %i in BlackList :"
8787 MAC_ADDRESS_STR, i,
8788 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8789
8790 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8791 sizeof(qcmacaddr));
8792 }
8793 }
8794
8795 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8796 {
8797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8798 "%s: SAP Set Mac Acl fail", __func__);
8799 return -EINVAL;
8800 }
8801 }
8802 else
8803 {
8804 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8805 "%s: Invalid device_mode = %d",
8806 __func__, pAdapter->device_mode);
8807 return -EINVAL;
8808 }
8809
8810 return 0;
8811}
8812
Leo Chang9056f462013-08-01 19:21:11 -07008813#ifdef WLAN_NL80211_TESTMODE
8814#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07008815void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07008816(
8817 void *pAdapter,
8818 void *indCont
8819)
8820{
Leo Changd9df8aa2013-09-26 13:32:26 -07008821 tSirLPHBInd *lphbInd;
8822 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07008823
8824 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008825 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07008826
8827 if (NULL == indCont)
8828 {
8829 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008830 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07008831 return;
8832 }
8833
Leo Changd9df8aa2013-09-26 13:32:26 -07008834 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07008835 skb = cfg80211_testmode_alloc_event_skb(
8836 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07008837 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07008838 GFP_ATOMIC);
8839 if (!skb)
8840 {
8841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8842 "LPHB timeout, NL buffer alloc fail");
8843 return;
8844 }
8845
Leo Changac3ba772013-10-07 09:47:04 -07008846 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -07008847 {
8848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8849 "WLAN_HDD_TM_ATTR_CMD put fail");
8850 goto nla_put_failure;
8851 }
Leo Changac3ba772013-10-07 09:47:04 -07008852 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -07008853 {
8854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8855 "WLAN_HDD_TM_ATTR_TYPE put fail");
8856 goto nla_put_failure;
8857 }
Leo Changac3ba772013-10-07 09:47:04 -07008858 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -07008859 sizeof(tSirLPHBInd), lphbInd))
8860 {
8861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8862 "WLAN_HDD_TM_ATTR_DATA put fail");
8863 goto nla_put_failure;
8864 }
Leo Chang9056f462013-08-01 19:21:11 -07008865 cfg80211_testmode_event(skb, GFP_ATOMIC);
8866 return;
8867
8868nla_put_failure:
8869 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8870 "NLA Put fail");
8871 kfree_skb(skb);
8872
8873 return;
8874}
8875#endif /* FEATURE_WLAN_LPHB */
8876
8877static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8878{
8879 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8880 int err = 0;
8881#ifdef FEATURE_WLAN_LPHB
8882 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07008883 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07008884#endif /* FEATURE_WLAN_LPHB */
8885
8886 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8887 if (err)
8888 {
8889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8890 "%s Testmode INV ATTR", __func__);
8891 return err;
8892 }
8893
8894 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8895 {
8896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8897 "%s Testmode INV CMD", __func__);
8898 return -EINVAL;
8899 }
8900
8901 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8902 {
8903#ifdef FEATURE_WLAN_LPHB
8904 /* Low Power Heartbeat configuration request */
8905 case WLAN_HDD_TM_CMD_WLAN_HB:
8906 {
8907 int buf_len;
8908 void *buf;
8909 tSirLPHBReq *hb_params = NULL;
8910
8911 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8912 {
8913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8914 "%s Testmode INV DATA", __func__);
8915 return -EINVAL;
8916 }
8917
8918 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8919 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8920 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8921 if (NULL == hb_params)
8922 {
8923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8924 "%s Request Buffer Alloc Fail", __func__);
8925 return -EINVAL;
8926 }
8927
8928 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07008929 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8930 hb_params,
8931 wlan_hdd_cfg80211_lphb_ind_handler);
8932 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07008933 {
Leo Changd9df8aa2013-09-26 13:32:26 -07008934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8935 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07008936 vos_mem_free(hb_params);
8937 }
Leo Chang9056f462013-08-01 19:21:11 -07008938 return 0;
8939 }
8940#endif /* FEATURE_WLAN_LPHB */
8941 default:
8942 return -EOPNOTSUPP;
8943 }
8944
8945 return err;
8946}
8947#endif /* CONFIG_NL80211_TESTMODE */
8948
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308949static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8950 struct net_device *dev,
8951 int idx, struct survey_info *survey)
8952{
8953 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8954 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308955 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308956 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308957 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308958 v_S7_t snr,rssi;
8959 int status, i, j, filled = 0;
8960
8961 ENTER();
8962
8963
8964 if (NULL == pAdapter)
8965 {
8966 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8967 "%s: HDD adapter is Null", __func__);
8968 return -ENODEV;
8969 }
8970
8971 if (NULL == wiphy)
8972 {
8973 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8974 "%s: wiphy is Null", __func__);
8975 return -ENODEV;
8976 }
8977
8978 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8979 status = wlan_hdd_validate_context(pHddCtx);
8980
8981 if (0 != status)
8982 {
8983 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8984 "%s: HDD context is not valid", __func__);
8985 return status;
8986 }
8987
Mihir Sheted9072e02013-08-21 17:02:29 +05308988 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8989
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308990 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308991 0 != pAdapter->survey_idx ||
8992 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308993 {
8994 /* The survey dump ops when implemented completely is expected to
8995 * return a survey of all channels and the ops is called by the
8996 * kernel with incremental values of the argument 'idx' till it
8997 * returns -ENONET. But we can only support the survey for the
8998 * operating channel for now. survey_idx is used to track
8999 * that the ops is called only once and then return -ENONET for
9000 * the next iteration
9001 */
9002 pAdapter->survey_idx = 0;
9003 return -ENONET;
9004 }
9005
9006 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
9007
9008 wlan_hdd_get_snr(pAdapter, &snr);
9009 wlan_hdd_get_rssi(pAdapter, &rssi);
9010
9011 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
9012 hdd_wlan_get_freq(channel, &freq);
9013
9014
9015 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
9016 {
9017 if (NULL == wiphy->bands[i])
9018 {
9019 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9020 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
9021 continue;
9022 }
9023
9024 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9025 {
9026 struct ieee80211_supported_band *band = wiphy->bands[i];
9027
9028 if (band->channels[j].center_freq == (v_U16_t)freq)
9029 {
9030 survey->channel = &band->channels[j];
9031 /* The Rx BDs contain SNR values in dB for the received frames
9032 * while the supplicant expects noise. So we calculate and
9033 * return the value of noise (dBm)
9034 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
9035 */
9036 survey->noise = rssi - snr;
9037 survey->filled = SURVEY_INFO_NOISE_DBM;
9038 filled = 1;
9039 }
9040 }
9041 }
9042
9043 if (filled)
9044 pAdapter->survey_idx = 1;
9045 else
9046 {
9047 pAdapter->survey_idx = 0;
9048 return -ENONET;
9049 }
9050
9051 return 0;
9052}
9053
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309054/*
9055 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
9056 * this is called when cfg80211 driver resume
9057 * driver updates latest sched_scan scan result(if any) to cfg80211 database
9058 */
9059int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
9060{
9061 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9062 hdd_adapter_t *pAdapter;
9063 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9064 VOS_STATUS status = VOS_STATUS_SUCCESS;
9065
9066 ENTER();
9067
9068 if ( NULL == pHddCtx )
9069 {
9070 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9071 "%s: HddCtx validation failed", __func__);
9072 return 0;
9073 }
9074
9075 if (pHddCtx->isLogpInProgress)
9076 {
9077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9078 "%s: LOGP in Progress. Ignore!!!", __func__);
9079 return 0;
9080 }
9081
9082 if (pHddCtx->isLoadUnloadInProgress)
9083 {
9084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9085 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
9086 return 0;
9087 }
9088
9089 spin_lock(&pHddCtx->schedScan_lock);
9090 pHddCtx->isWiphySuspended = FALSE;
9091 if (TRUE != pHddCtx->isSchedScanUpdatePending)
9092 {
9093 spin_unlock(&pHddCtx->schedScan_lock);
9094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9095 "%s: Return resume is not due to PNO indication", __func__);
9096 return 0;
9097 }
9098 // Reset flag to avoid updatating cfg80211 data old results again
9099 pHddCtx->isSchedScanUpdatePending = FALSE;
9100 spin_unlock(&pHddCtx->schedScan_lock);
9101
9102 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9103
9104 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9105 {
9106 pAdapter = pAdapterNode->pAdapter;
9107 if ( (NULL != pAdapter) &&
9108 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
9109 {
9110 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
9111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9112 "%s: NO SCAN result", __func__);
9113 else
9114 cfg80211_sched_scan_results(pHddCtx->wiphy);
9115
9116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9117 "%s : cfg80211 scan result database updated", __func__);
9118
9119 return 0;
9120
9121 }
9122 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9123 pAdapterNode = pNext;
9124 }
9125
9126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9127 "%s: Failed to find Adapter", __func__);
9128 return 0;
9129}
9130
9131/*
9132 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
9133 * this is called when cfg80211 driver suspends
9134 */
9135int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
9136 struct cfg80211_wowlan *wow)
9137{
9138 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9139
9140 ENTER();
9141 if (NULL == pHddCtx)
9142 {
9143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9144 "%s: HddCtx validation failed", __func__);
9145 return 0;
9146 }
9147
9148 pHddCtx->isWiphySuspended = TRUE;
9149
9150 EXIT();
9151
9152 return 0;
9153}
9154
Jeff Johnson295189b2012-06-20 16:38:30 -07009155/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309156static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07009157{
9158 .add_virtual_intf = wlan_hdd_add_virtual_intf,
9159 .del_virtual_intf = wlan_hdd_del_virtual_intf,
9160 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
9161 .change_station = wlan_hdd_change_station,
9162#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9163 .add_beacon = wlan_hdd_cfg80211_add_beacon,
9164 .del_beacon = wlan_hdd_cfg80211_del_beacon,
9165 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009166#else
9167 .start_ap = wlan_hdd_cfg80211_start_ap,
9168 .change_beacon = wlan_hdd_cfg80211_change_beacon,
9169 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07009170#endif
9171 .change_bss = wlan_hdd_cfg80211_change_bss,
9172 .add_key = wlan_hdd_cfg80211_add_key,
9173 .get_key = wlan_hdd_cfg80211_get_key,
9174 .del_key = wlan_hdd_cfg80211_del_key,
9175 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009176#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009177 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009178#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009179 .scan = wlan_hdd_cfg80211_scan,
9180 .connect = wlan_hdd_cfg80211_connect,
9181 .disconnect = wlan_hdd_cfg80211_disconnect,
9182 .join_ibss = wlan_hdd_cfg80211_join_ibss,
9183 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
9184 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
9185 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
9186 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07009187 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
9188 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
9189 .mgmt_tx = wlan_hdd_action,
9190#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9191 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
9192 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
9193 .set_txq_params = wlan_hdd_set_txq_params,
9194#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009195 .get_station = wlan_hdd_cfg80211_get_station,
9196 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
9197 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009198 .add_station = wlan_hdd_cfg80211_add_station,
9199#ifdef FEATURE_WLAN_LFR
9200 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
9201 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
9202 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
9203#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009204#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
9205 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
9206#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009207#ifdef FEATURE_WLAN_TDLS
9208 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
9209 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
9210#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309211#ifdef WLAN_FEATURE_GTK_OFFLOAD
9212 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
9213#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309214#ifdef FEATURE_WLAN_SCAN_PNO
9215 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
9216 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
9217#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309218 .resume = wlan_hdd_cfg80211_resume_wlan,
9219 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309220 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07009221#ifdef WLAN_NL80211_TESTMODE
9222 .testmode_cmd = wlan_hdd_cfg80211_testmode,
9223#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309224 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009225};
9226