blob: 58abfeef7d267e6c8bc4c6b999c7e0fe9c0a391d [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnson32d95a32012-09-10 13:15:23 -07002 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -07003 *
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 */
21
22/**========================================================================
23
24 \file wlan_hdd_cfg80211.c
25
26 \brief WLAN Host Device Driver implementation
27
28 Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
29
30 Qualcomm Confidential and Proprietary.
31
32 ========================================================================*/
33
34/**=========================================================================
35
36 EDIT HISTORY FOR FILE
37
38
39 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
41
42
43 $Header:$ $DateTime: $ $Author: $
44
45
46 when who what, where, why
47 -------- --- --------------------------------------------------------
48 21/12/09 Ashwani Created module.
49
50 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
51 Ganesh K
52 ==========================================================================*/
53
54#ifdef CONFIG_CFG80211
55
56#include <linux/version.h>
57#include <linux/module.h>
58#include <linux/kernel.h>
59#include <linux/init.h>
60#include <linux/wireless.h>
61#include <wlan_hdd_includes.h>
62#include <net/arp.h>
63#include <net/cfg80211.h>
64#include <linux/wireless.h>
65#include <wlan_hdd_wowl.h>
66#include <aniGlobal.h>
67#include "ccmApi.h"
68#include "sirParams.h"
69#include "dot11f.h"
70#include "wlan_hdd_assoc.h"
71#include "wlan_hdd_wext.h"
72#include "sme_Api.h"
73#include "wlan_hdd_p2p.h"
74#include "wlan_hdd_cfg80211.h"
75#include "wlan_hdd_hostapd.h"
76#include "sapInternal.h"
77#include "wlan_hdd_softap_tx_rx.h"
78#include "wlan_hdd_main.h"
79#ifdef WLAN_BTAMP_FEATURE
80#include "bap_hdd_misc.h"
81#endif
82#include <qc_sap_ioctl.h>
83
84#define g_mode_rates_size (12)
85#define a_mode_rates_size (8)
86#define FREQ_BASE_80211G (2407)
87#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070088#define MAX_SCAN_SSID 9
Jeff Johnson295189b2012-06-20 16:38:30 -070089#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
90 ((int) OFFSET_OF( tSirBssDescription, ieFields)))
91
92#define HDD2GHZCHAN(freq, chan, flag) { \
93 .band = IEEE80211_BAND_2GHZ, \
94 .center_freq = (freq), \
95 .hw_value = (chan),\
96 .flags = (flag), \
97 .max_antenna_gain = 0 ,\
98 .max_power = 30, \
99}
100
101#define HDD5GHZCHAN(freq, chan, flag) { \
102 .band = IEEE80211_BAND_5GHZ, \
103 .center_freq = (freq), \
104 .hw_value = (chan),\
105 .flags = (flag), \
106 .max_antenna_gain = 0 ,\
107 .max_power = 30, \
108}
109
110#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
111{\
112 .bitrate = rate, \
113 .hw_value = rate_id, \
114 .flags = flag, \
115}
116
117static const u32 hdd_cipher_suites[] =
118{
119 WLAN_CIPHER_SUITE_WEP40,
120 WLAN_CIPHER_SUITE_WEP104,
121 WLAN_CIPHER_SUITE_TKIP,
122#ifdef FEATURE_WLAN_CCX
123#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
124 WLAN_CIPHER_SUITE_KRK,
125 WLAN_CIPHER_SUITE_CCMP,
126#else
127 WLAN_CIPHER_SUITE_CCMP,
128#endif
129#ifdef FEATURE_WLAN_WAPI
130 WLAN_CIPHER_SUITE_SMS4,
131#endif
132};
133
134static inline int is_broadcast_ether_addr(const u8 *addr)
135{
136 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
137 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
138}
139
140static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
141{
142 HDD2GHZCHAN(2412, 1, 0) ,
143 HDD2GHZCHAN(2417, 2, 0) ,
144 HDD2GHZCHAN(2422, 3, 0) ,
145 HDD2GHZCHAN(2427, 4, 0) ,
146 HDD2GHZCHAN(2432, 5, 0) ,
147 HDD2GHZCHAN(2437, 6, 0) ,
148 HDD2GHZCHAN(2442, 7, 0) ,
149 HDD2GHZCHAN(2447, 8, 0) ,
150 HDD2GHZCHAN(2452, 9, 0) ,
151 HDD2GHZCHAN(2457, 10, 0) ,
152 HDD2GHZCHAN(2462, 11, 0) ,
153 HDD2GHZCHAN(2467, 12, 0) ,
154 HDD2GHZCHAN(2472, 13, 0) ,
155 HDD2GHZCHAN(2484, 14, 0) ,
156};
157
158#ifdef WLAN_FEATURE_P2P
159static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
160{
161 HDD2GHZCHAN(2412, 1, 0) ,
162 HDD2GHZCHAN(2437, 6, 0) ,
163 HDD2GHZCHAN(2462, 11, 0) ,
164};
165#endif
166
167static struct ieee80211_channel hdd_channels_5_GHZ[] =
168{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700169 HDD5GHZCHAN(4920, 240, 0) ,
170 HDD5GHZCHAN(4940, 244, 0) ,
171 HDD5GHZCHAN(4960, 248, 0) ,
172 HDD5GHZCHAN(4980, 252, 0) ,
173 HDD5GHZCHAN(5040, 208, 0) ,
174 HDD5GHZCHAN(5060, 212, 0) ,
175 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700176 HDD5GHZCHAN(5180, 36, 0) ,
177 HDD5GHZCHAN(5200, 40, 0) ,
178 HDD5GHZCHAN(5220, 44, 0) ,
179 HDD5GHZCHAN(5240, 48, 0) ,
180 HDD5GHZCHAN(5260, 52, 0) ,
181 HDD5GHZCHAN(5280, 56, 0) ,
182 HDD5GHZCHAN(5300, 60, 0) ,
183 HDD5GHZCHAN(5320, 64, 0) ,
184 HDD5GHZCHAN(5500,100, 0) ,
185 HDD5GHZCHAN(5520,104, 0) ,
186 HDD5GHZCHAN(5540,108, 0) ,
187 HDD5GHZCHAN(5560,112, 0) ,
188 HDD5GHZCHAN(5580,116, 0) ,
189 HDD5GHZCHAN(5600,120, 0) ,
190 HDD5GHZCHAN(5620,124, 0) ,
191 HDD5GHZCHAN(5640,128, 0) ,
192 HDD5GHZCHAN(5660,132, 0) ,
193 HDD5GHZCHAN(5680,136, 0) ,
194 HDD5GHZCHAN(5700,140, 0) ,
195 HDD5GHZCHAN(5745,149, 0) ,
196 HDD5GHZCHAN(5765,153, 0) ,
197 HDD5GHZCHAN(5785,157, 0) ,
198 HDD5GHZCHAN(5805,161, 0) ,
199 HDD5GHZCHAN(5825,165, 0) ,
200};
201
202static struct ieee80211_rate g_mode_rates[] =
203{
204 HDD_G_MODE_RATETAB(10, 0x1, 0),
205 HDD_G_MODE_RATETAB(20, 0x2, 0),
206 HDD_G_MODE_RATETAB(55, 0x4, 0),
207 HDD_G_MODE_RATETAB(110, 0x8, 0),
208 HDD_G_MODE_RATETAB(60, 0x10, 0),
209 HDD_G_MODE_RATETAB(90, 0x20, 0),
210 HDD_G_MODE_RATETAB(120, 0x40, 0),
211 HDD_G_MODE_RATETAB(180, 0x80, 0),
212 HDD_G_MODE_RATETAB(240, 0x100, 0),
213 HDD_G_MODE_RATETAB(360, 0x200, 0),
214 HDD_G_MODE_RATETAB(480, 0x400, 0),
215 HDD_G_MODE_RATETAB(540, 0x800, 0),
216};
217
218static struct ieee80211_rate a_mode_rates[] =
219{
220 HDD_G_MODE_RATETAB(60, 0x10, 0),
221 HDD_G_MODE_RATETAB(90, 0x20, 0),
222 HDD_G_MODE_RATETAB(120, 0x40, 0),
223 HDD_G_MODE_RATETAB(180, 0x80, 0),
224 HDD_G_MODE_RATETAB(240, 0x100, 0),
225 HDD_G_MODE_RATETAB(360, 0x200, 0),
226 HDD_G_MODE_RATETAB(480, 0x400, 0),
227 HDD_G_MODE_RATETAB(540, 0x800, 0),
228};
229
230static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
231{
232 .channels = hdd_channels_2_4_GHZ,
233 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
234 .band = IEEE80211_BAND_2GHZ,
235 .bitrates = g_mode_rates,
236 .n_bitrates = g_mode_rates_size,
237 .ht_cap.ht_supported = 1,
238 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
239 | IEEE80211_HT_CAP_GRN_FLD
240 | IEEE80211_HT_CAP_DSSSCCK40
241 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
242 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
243 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
244 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
245 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
246 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
247};
248
249#ifdef WLAN_FEATURE_P2P
250static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
251{
252 .channels = hdd_social_channels_2_4_GHZ,
253 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
254 .band = IEEE80211_BAND_2GHZ,
255 .bitrates = g_mode_rates,
256 .n_bitrates = g_mode_rates_size,
257 .ht_cap.ht_supported = 1,
258 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
259 | IEEE80211_HT_CAP_GRN_FLD
260 | IEEE80211_HT_CAP_DSSSCCK40
261 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
262 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
263 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
264 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
265 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
266 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
267};
268#endif
269
270static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
271{
272 .channels = hdd_channels_5_GHZ,
273 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
274 .band = IEEE80211_BAND_5GHZ,
275 .bitrates = a_mode_rates,
276 .n_bitrates = a_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 | IEEE80211_HT_CAP_SGI_40
283 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
284 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
285 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
286 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
287 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
288 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
289};
290
291/* This structure contain information what kind of frame are expected in
292 TX/RX direction for each kind of interface */
293static const struct ieee80211_txrx_stypes
294wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
295 [NL80211_IFTYPE_STATION] = {
296 .tx = 0xffff,
297 .rx = BIT(SIR_MAC_MGMT_ACTION) |
298 BIT(SIR_MAC_MGMT_PROBE_REQ),
299 },
300 [NL80211_IFTYPE_AP] = {
301 .tx = 0xffff,
302 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
303 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
304 BIT(SIR_MAC_MGMT_PROBE_REQ) |
305 BIT(SIR_MAC_MGMT_DISASSOC) |
306 BIT(SIR_MAC_MGMT_AUTH) |
307 BIT(SIR_MAC_MGMT_DEAUTH) |
308 BIT(SIR_MAC_MGMT_ACTION),
309 },
310#ifdef WLAN_FEATURE_P2P
311 [NL80211_IFTYPE_P2P_CLIENT] = {
312 .tx = 0xffff,
313 .rx = BIT(SIR_MAC_MGMT_ACTION) |
314 BIT(SIR_MAC_MGMT_PROBE_REQ),
315 },
316 [NL80211_IFTYPE_P2P_GO] = {
317 /* This is also same as for SoftAP */
318 .tx = 0xffff,
319 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
320 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
321 BIT(SIR_MAC_MGMT_PROBE_REQ) |
322 BIT(SIR_MAC_MGMT_DISASSOC) |
323 BIT(SIR_MAC_MGMT_AUTH) |
324 BIT(SIR_MAC_MGMT_DEAUTH) |
325 BIT(SIR_MAC_MGMT_ACTION),
326 },
327#endif
328};
329
330static struct cfg80211_ops wlan_hdd_cfg80211_ops;
331
332/* Data rate 100KBPS based on IE Index */
333struct index_data_rate_type
334{
335 v_U8_t beacon_rate_index;
336 v_U16_t supported_rate[4];
337};
338
339/* 11B, 11G Rate table include Basic rate and Extended rate
340 The IDX field is the rate index
341 The HI field is the rate when RSSI is strong or being ignored
342 (in this case we report actual rate)
343 The MID field is the rate when RSSI is moderate
344 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
345 The LO field is the rate when RSSI is low
346 (in this case we don't report rates, actual current rate used)
347 */
348static const struct
349{
350 v_U8_t beacon_rate_index;
351 v_U16_t supported_rate[3];
352} supported_data_rate[] =
353{
354/* IDX HI MID LO (RSSI-based index */
355 {2, { 10, 10, 0}},
356 {4, { 20, 20, 0}},
357 {11, { 55, 55, 0}},
358 {12, { 60, 60, 0}},
359 {18, { 90, 90, 0}},
360 {22, {110, 55, 0}},
361 {24, {120, 120, 0}},
362 {36, {180, 180, 0}},
363 {44, {220, 220, 0}},
364 {48, {240, 240, 0}},
365 {66, {330, 240, 0}},
366 {72, {360, 240, 0}},
367 {96, {480, 240, 0}},
368 {108, {540, 240, 0}}
369};
370
371/* MCS Based rate table */
372static struct index_data_rate_type supported_mcs_rate[] =
373{
374/* MCS L20 L40 S20 S40 */
375 {0, {65, 135, 72, 150}},
376 {1, {130, 270, 144, 300}},
377 {2, {195, 405, 217, 450}},
378 {3, {260, 540, 289, 600}},
379 {4, {390, 810, 433, 900}},
380 {5, {520, 1080, 578, 1200}},
381 {6, {585, 1215, 650, 1350}},
382 {7, {650, 1350, 722, 1500}}
383};
384
385extern struct net_device_ops net_ops_struct;
386
387/*
388 * FUNCTION: wlan_hdd_cfg80211_init
389 * This function is called by hdd_wlan_startup()
390 * during initialization.
391 * This function is used to initialize and register wiphy structure.
392 */
393struct wiphy *wlan_hdd_cfg80211_init(int priv_size)
394{
395 struct wiphy *wiphy;
396 ENTER();
397
398 /*
399 * Create wiphy device
400 */
401 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
402
403 if (!wiphy)
404 {
405 /* Print error and jump into err label and free the memory */
406 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
407 return NULL;
408 }
409
410 return wiphy;
411}
412
413/*
414 * FUNCTION: wlan_hdd_cfg80211_update_band
415 * This function is called from the supplicant through a
416 * private ioctl to change the band value
417 */
418int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
419{
Jeff Johnsone7245742012-09-05 17:12:55 -0700420 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 switch(eBand)
422 {
423 case eCSR_BAND_24:
424 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
425 wiphy->bands[IEEE80211_BAND_5GHZ] = NULL;
426 break;
427 case eCSR_BAND_5G:
Madan Mohan Koyyalamudi6f6390c2012-09-24 13:57:46 -0700428#ifdef WLAN_FEATURE_P2P
429 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_p2p_2_4_GHZ;
430#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700431 wiphy->bands[IEEE80211_BAND_2GHZ] = NULL;
Madan Mohan Koyyalamudi6f6390c2012-09-24 13:57:46 -0700432#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700433 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
434 break;
435 case eCSR_BAND_ALL:
436 default:
437 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
438 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
439 }
440 return 0;
441}
442/*
443 * FUNCTION: wlan_hdd_cfg80211_init
444 * This function is called by hdd_wlan_startup()
445 * during initialization.
446 * This function is used to initialize and register wiphy structure.
447 */
448int wlan_hdd_cfg80211_register(struct device *dev,
449 struct wiphy *wiphy,
450 hdd_config_t *pCfg
451 )
452{
Jeff Johnsone7245742012-09-05 17:12:55 -0700453 ENTER();
454
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 /* Now bind the underlying wlan device with wiphy */
456 set_wiphy_dev(wiphy, dev);
457
458 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
459
460 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
461 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
462 | WIPHY_FLAG_CUSTOM_REGULATORY;
463
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700464#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnsone7245742012-09-05 17:12:55 -0700465 wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
466 | WIPHY_FLAG_OFFCHAN_TX;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700467#endif
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700468 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
469 driver can still register regulatory callback and
470 it will get CRDA setting in wiphy->band[], but
471 driver need to determine what to do with both
472 regulatory settings */
473 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700474
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 wiphy->max_scan_ssids = MAX_SCAN_SSID;
476
477 wiphy->max_scan_ie_len = 200 ; //TODO: define a macro
478
479 /* Supports STATION & AD-HOC modes right now */
480 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
481 | BIT(NL80211_IFTYPE_ADHOC)
482#ifdef WLAN_FEATURE_P2P
483 | BIT(NL80211_IFTYPE_P2P_CLIENT)
484 | BIT(NL80211_IFTYPE_P2P_GO)
485#endif
486 | BIT(NL80211_IFTYPE_AP);
487
488 /* Before registering we need to update the ht capabilitied based
489 * on ini values*/
490 if( !pCfg->ShortGI20MhzEnable )
491 {
492 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
493 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
494 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
495 }
496
497 if( !pCfg->ShortGI40MhzEnable )
498 {
499 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
500 }
501
502 if( !pCfg->nChannelBondingMode5GHz )
503 {
504 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
505 }
506
507 /*Initialize band capability*/
508 switch(pCfg->nBandCapability)
509 {
510 case eCSR_BAND_24:
511 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
512 break;
513 case eCSR_BAND_5G:
514#ifdef WLAN_FEATURE_P2P
515 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_p2p_2_4_GHZ;
516#endif
517 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
518 break;
519 case eCSR_BAND_ALL:
520 default:
521 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
522 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
523 }
524 /*Initialise the supported cipher suite details*/
525 wiphy->cipher_suites = hdd_cipher_suites;
526 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
527
528 /*signal strength in mBm (100*dBm) */
529 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
530
531#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
532#ifdef WLAN_FEATURE_P2P
533 wiphy->max_remain_on_channel_duration = 1000;
534#endif
535#endif
536
537 /* Register our wiphy dev with cfg80211 */
538 if (0 > wiphy_register(wiphy))
539 {
540 /* print eror */
541 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
542 return -EIO;
543 }
544
545 EXIT();
546 return 0;
547}
548
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700549/* In this function we will try to get default country code from crda.
550 If the gCrdaDefaultCountryCode is configured in ini file,
551 we will try to call user space crda to get the regulatory settings for
552 that country. We will timeout if we can't get it from crda.
553 It's called by hdd_wlan_startup() after wlan_hdd_cfg80211_register.
554*/
555int wlan_hdd_get_crda_regd_entry(struct wiphy *wiphy, hdd_config_t *pCfg)
556{
557 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
558 if (memcmp(pCfg->crdaDefaultCountryCode,
559 CFG_CRDA_DEFAULT_COUNTRY_CODE_DEFAULT , 2) != 0)
560 {
561 init_completion(&pHddCtx->driver_crda_req);
562 regulatory_hint(wiphy, pCfg->crdaDefaultCountryCode);
563 wait_for_completion_interruptible_timeout(&pHddCtx->driver_crda_req,
564 CRDA_WAIT_TIME);
565 }
566 return 0;
567}
568
Jeff Johnson295189b2012-06-20 16:38:30 -0700569/* In this function we will do all post VOS start initialization.
570 In this function we will register for all frame in which supplicant
571 is interested.
572*/
573void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
574{
575#ifdef WLAN_FEATURE_P2P
576 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
577 /* Register for all P2P action, public action etc frames */
578 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
579
Jeff Johnsone7245742012-09-05 17:12:55 -0700580 ENTER();
581
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 /* Right now we are registering these frame when driver is getting
583 initialized. Once we will move to 2.6.37 kernel, in which we have
584 frame register ops, we will move this code as a part of that */
585 /* GAS Initial Request */
586 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
587 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
588
589 /* GAS Initial Response */
590 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
591 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
592
593 /* GAS Comeback Request */
594 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
595 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
596
597 /* GAS Comeback Response */
598 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
599 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
600
601 /* P2P Public Action */
602 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
603 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
604 P2P_PUBLIC_ACTION_FRAME_SIZE );
605
606 /* P2P Action */
607 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
608 (v_U8_t*)P2P_ACTION_FRAME,
609 P2P_ACTION_FRAME_SIZE );
610#endif /* WLAN_FEATURE_P2P */
611}
612
613void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
614{
615#ifdef WLAN_FEATURE_P2P
616 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
617 /* Register for all P2P action, public action etc frames */
618 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
619
Jeff Johnsone7245742012-09-05 17:12:55 -0700620 ENTER();
621
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 /* Right now we are registering these frame when driver is getting
623 initialized. Once we will move to 2.6.37 kernel, in which we have
624 frame register ops, we will move this code as a part of that */
625 /* GAS Initial Request */
626
627 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
628 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
629
630 /* GAS Initial Response */
631 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
632 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
633
634 /* GAS Comeback Request */
635 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
636 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
637
638 /* GAS Comeback Response */
639 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
640 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
641
642 /* P2P Public Action */
643 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
644 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
645 P2P_PUBLIC_ACTION_FRAME_SIZE );
646
647 /* P2P Action */
648 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
649 (v_U8_t*)P2P_ACTION_FRAME,
650 P2P_ACTION_FRAME_SIZE );
651#endif /* WLAN_FEATURE_P2P */
652}
653
654#ifdef FEATURE_WLAN_WAPI
655void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
656 const u8 *mac_addr, u8 *key , int key_Len)
657{
658 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
659 tCsrRoamSetKey setKey;
660 v_BOOL_t isConnected = TRUE;
661 int status = 0;
662 v_U32_t roamId= 0xFF;
663 tANI_U8 *pKeyPtr = NULL;
664 int n = 0;
665
666 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
667 __func__,pAdapter->device_mode);
668
669 setKey.keyId = key_index; // Store Key ID
670 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
671 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
672 setKey.paeRole = 0 ; // the PAE role
673 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
674 {
675 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
676 }
677 else
678 {
679 isConnected = hdd_connIsConnected(pHddStaCtx);
680 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
681 }
682 setKey.keyLength = key_Len;
683 pKeyPtr = setKey.Key;
684 memcpy( pKeyPtr, key, key_Len);
685
686 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
687 __func__, key_Len);
688 for (n = 0 ; n < key_Len; n++)
689 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
690 __func__,n,setKey.Key[n]);
691
692 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
693 if ( isConnected )
694 {
695 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
696 pAdapter->sessionId, &setKey, &roamId );
697 }
698 if ( status != 0 )
699 {
700 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
701 "[%4d] sme_RoamSetKey returned ERROR status= %d",
702 __LINE__, status );
703 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
704 }
705}
706#endif /* FEATURE_WLAN_WAPI*/
707
708#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
709int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
710 beacon_data_t **ppBeacon,
711 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700712#else
713int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
714 beacon_data_t **ppBeacon,
715 struct cfg80211_beacon_data *params,
716 int dtim_period)
717#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700718{
719 int size;
720 beacon_data_t *beacon = NULL;
721 beacon_data_t *old = NULL;
722 int head_len,tail_len;
723
Jeff Johnsone7245742012-09-05 17:12:55 -0700724 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -0700725 if (params->head && !params->head_len)
726 return -EINVAL;
727
728 old = pAdapter->sessionCtx.ap.beacon;
729
730 if (!params->head && !old)
731 return -EINVAL;
732
733 if (params->tail && !params->tail_len)
734 return -EINVAL;
735
736#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
737 /* Kernel 3.0 is not updating dtim_period for set beacon */
738 if (!params->dtim_period)
739 return -EINVAL;
740#endif
741
742 if(params->head)
743 head_len = params->head_len;
744 else
745 head_len = old->head_len;
746
747 if(params->tail || !old)
748 tail_len = params->tail_len;
749 else
750 tail_len = old->tail_len;
751
752 size = sizeof(beacon_data_t) + head_len + tail_len;
753
754 beacon = kzalloc(size, GFP_KERNEL);
755
756 if( beacon == NULL )
757 return -ENOMEM;
758
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700759#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -0700760 if(params->dtim_period || !old )
761 beacon->dtim_period = params->dtim_period;
762 else
763 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700764#else
765 if(dtim_period || !old )
766 beacon->dtim_period = dtim_period;
767 else
768 beacon->dtim_period = old->dtim_period;
769#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700770
771 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
772 beacon->tail = beacon->head + head_len;
773 beacon->head_len = head_len;
774 beacon->tail_len = tail_len;
775
776 if(params->head) {
777 memcpy (beacon->head,params->head,beacon->head_len);
778 }
779 else {
780 if(old)
781 memcpy (beacon->head,old->head,beacon->head_len);
782 }
783
784 if(params->tail) {
785 memcpy (beacon->tail,params->tail,beacon->tail_len);
786 }
787 else {
788 if(old)
789 memcpy (beacon->tail,old->tail,beacon->tail_len);
790 }
791
792 *ppBeacon = beacon;
793
794 kfree(old);
795
796 return 0;
797
798}
Jeff Johnson295189b2012-06-20 16:38:30 -0700799
800v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
801{
802 int left = length;
803 v_U8_t *ptr = pIes;
804 v_U8_t elem_id,elem_len;
805
806 while(left >= 2)
807 {
808 elem_id = ptr[0];
809 elem_len = ptr[1];
810 left -= 2;
811 if(elem_len > left)
812 {
813 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700814 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 eid,elem_len,left);
816 return NULL;
817 }
818 if (elem_id == eid)
819 {
820 return ptr;
821 }
822
823 left -= elem_len;
824 ptr += (elem_len + 2);
825 }
826 return NULL;
827}
828
Jeff Johnson295189b2012-06-20 16:38:30 -0700829/* Check if rate is 11g rate or not */
830static int wlan_hdd_rate_is_11g(u8 rate)
831{
832 u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 104}; /* actual rate * 2 */
833 u8 i;
834 for (i = 0; i < 8; i++)
835 {
836 if(rate == gRateArray[i])
837 return TRUE;
838 }
839 return FALSE;
840}
841
842/* Check for 11g rate and set proper 11g only mode */
843static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
844 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
845{
846 u8 i, num_rates = pIe[0];
847
848 pIe += 1;
849 for ( i = 0; i < num_rates; i++)
850 {
851 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
852 {
853 /* If rate set have 11g rate than change the mode to 11G */
854 *pSapHw_mode = eSAP_DOT11_MODE_11g;
855 if (pIe[i] & BASIC_RATE_MASK)
856 {
857 /* If we have 11g rate as basic rate, it means mode
858 is 11g only mode.
859 */
860 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
861 *pCheckRatesfor11g = FALSE;
862 }
863 }
864 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
865 {
866 *require_ht = TRUE;
867 }
868 }
869 return;
870}
871
872static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
873{
874 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
875 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
876 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
877 u8 checkRatesfor11g = TRUE;
878 u8 require_ht = FALSE;
879 u8 *pIe=NULL;
880
881 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
882
883 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
884 pBeacon->head_len, WLAN_EID_SUPP_RATES);
885 if (pIe != NULL)
886 {
887 pIe += 1;
888 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
889 &pConfig->SapHw_mode);
890 }
891
892 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
893 WLAN_EID_EXT_SUPP_RATES);
894 if (pIe != NULL)
895 {
896
897 pIe += 1;
898 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
899 &pConfig->SapHw_mode);
900 }
901
902 if( pConfig->channel > 14 )
903 {
904 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
905 }
906
907 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
908 WLAN_EID_HT_CAPABILITY);
909
910 if(pIe)
911 {
912 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
913 if(require_ht)
914 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
915 }
916}
917
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700918#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -0700919static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
920 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700921#else
922static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
923 struct cfg80211_beacon_data *params)
924#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700925{
926 v_U8_t *genie;
927 v_U8_t total_ielen = 0, ielen = 0;
928 v_U8_t *pIe = NULL;
929 v_U8_t addIE[1] = {0};
930 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
Jeff Johnsone7245742012-09-05 17:12:55 -0700931 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700932
933 genie = vos_mem_malloc(MAX_GENIE_LEN);
934
935 if(genie == NULL) {
936
937 return -ENOMEM;
938 }
939
940 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
941
942 if(pIe)
943 {
944 /*Copy the wps IE*/
945 ielen = pIe[1] + 2;
946 if( ielen <=MAX_GENIE_LEN)
947 {
948 vos_mem_copy(genie, pIe, ielen);
949 }
950 else
951 {
952 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too big***\n");
Jeff Johnsone7245742012-09-05 17:12:55 -0700953 ret = -EINVAL;
954 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 }
956 total_ielen = ielen;
957 }
958
959#ifdef WLAN_FEATURE_WFD
960 pIe = wlan_hdd_get_wfd_ie_ptr(pBeacon->tail,pBeacon->tail_len);
961
962 if(pIe)
963 {
964 ielen = pIe[1] + 2;
965 if(total_ielen + ielen <= MAX_GENIE_LEN) {
966 vos_mem_copy(&genie[total_ielen],pIe,(pIe[1] + 2));
967 }
968 else {
969 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie + P2p Ie + Wfd Ie Length is too big***\n");
Jeff Johnsone7245742012-09-05 17:12:55 -0700970 ret = -EINVAL;
971 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 }
973 total_ielen += ielen;
974 }
975#endif
976
977#ifdef WLAN_FEATURE_P2P
978 pIe = wlan_hdd_get_p2p_ie_ptr(pBeacon->tail,pBeacon->tail_len);
979
980 if(pIe)
981 {
982 ielen = pIe[1] + 2;
983 if(total_ielen + ielen <= MAX_GENIE_LEN)
984 {
985 vos_mem_copy(&genie[total_ielen], pIe, (pIe[1] + 2));
986 }
987 else
988 {
989 hddLog( VOS_TRACE_LEVEL_ERROR,
990 "**Wps Ie+ P2pIE Length is too big***\n");
Jeff Johnsone7245742012-09-05 17:12:55 -0700991 ret = -EINVAL;
992 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -0700993 }
994 total_ielen += ielen;
995 }
996#endif
997
998 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
999 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1000 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1001 {
1002 hddLog(LOGE,
1003 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001004 ret = -EINVAL;
1005 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 }
1007
1008 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1009 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1010 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1011 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1012 ==eHAL_STATUS_FAILURE)
1013 {
1014 hddLog(LOGE,
1015 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001016 ret = -EINVAL;
1017 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 }
1019
1020 // Added for ProResp IE
1021 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1022 {
1023 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1024 u8 probe_rsp_ie_len[3] = {0};
1025 u8 counter = 0;
1026 /* Check Probe Resp Length if it is greater then 255 then Store
1027 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1028 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1029 Store More then 255 bytes into One Variable.
1030 */
1031 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1032 {
1033 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1034 {
1035 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1036 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1037 }
1038 else
1039 {
1040 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1041 rem_probe_resp_ie_len = 0;
1042 }
1043 }
1044
1045 rem_probe_resp_ie_len = 0;
1046
1047 if (probe_rsp_ie_len[0] > 0)
1048 {
1049 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1050 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1051 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1052 probe_rsp_ie_len[0], NULL,
1053 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1054 {
1055 hddLog(LOGE,
1056 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001057 ret = -EINVAL;
1058 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 }
1060 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1061 }
1062
1063 if (probe_rsp_ie_len[1] > 0)
1064 {
1065 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1066 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1067 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1068 probe_rsp_ie_len[1], NULL,
1069 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1070 {
1071 hddLog(LOGE,
1072 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001073 ret = -EINVAL;
1074 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 }
1076 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1077 }
1078
1079 if (probe_rsp_ie_len[2] > 0)
1080 {
1081 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1082 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1083 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1084 probe_rsp_ie_len[2], NULL,
1085 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1086 {
1087 hddLog(LOGE,
1088 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001089 ret = -EINVAL;
1090 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 }
1092 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1093 }
1094
1095 if (probe_rsp_ie_len[1] == 0 )
1096 {
1097 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1098 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1099 eANI_BOOLEAN_FALSE) )
1100 {
1101 hddLog(LOGE,
1102 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1103 }
1104 }
1105
1106 if (probe_rsp_ie_len[2] == 0 )
1107 {
1108 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1109 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1110 eANI_BOOLEAN_FALSE) )
1111 {
1112 hddLog(LOGE,
1113 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1114 }
1115 }
1116
1117 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1118 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1119 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1120 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1121 == eHAL_STATUS_FAILURE)
1122 {
1123 hddLog(LOGE,
1124 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001125 ret = -EINVAL;
1126 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001127 }
1128 }
1129 else
1130 {
1131 // Reset WNI_CFG_PROBE_RSP Flags
1132 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1133
1134 hddLog(VOS_TRACE_LEVEL_INFO,
1135 "%s: No Probe Response IE received in set beacon",
1136 __func__);
1137 }
1138
1139 // Added for AssocResp IE
1140 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1141 {
1142 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1143 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1144 params->assocresp_ies_len, NULL,
1145 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1146 {
1147 hddLog(LOGE,
1148 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001149 ret = -EINVAL;
1150 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001151 }
1152
1153 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1154 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1155 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1156 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1157 == eHAL_STATUS_FAILURE)
1158 {
1159 hddLog(LOGE,
1160 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001161 ret = -EINVAL;
1162 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 }
1164 }
1165 else
1166 {
1167 hddLog(VOS_TRACE_LEVEL_INFO,
1168 "%s: No Assoc Response IE received in set beacon",
1169 __func__);
1170
1171 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1172 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1173 eANI_BOOLEAN_FALSE) )
1174 {
1175 hddLog(LOGE,
1176 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1177 }
1178 }
1179
Jeff Johnsone7245742012-09-05 17:12:55 -07001180done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 vos_mem_free(genie);
1182 return 0;
1183}
Jeff Johnson295189b2012-06-20 16:38:30 -07001184
1185/*
1186 * FUNCTION: wlan_hdd_validate_operation_channel
1187 * called by wlan_hdd_cfg80211_start_bss() and
1188 * wlan_hdd_cfg80211_set_channel()
1189 * This function validates whether given channel is part of valid
1190 * channel list.
1191 */
1192static VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
1193{
1194
1195 v_U32_t num_ch = 0;
1196 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1197 u32 indx = 0;
1198 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1199
1200 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1201
1202 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1203 valid_ch, &num_ch))
1204 {
1205 hddLog(VOS_TRACE_LEVEL_ERROR,
1206 "%s: failed to get valid channel list\n", __func__);
1207 return VOS_STATUS_E_FAILURE;
1208 }
1209
1210 for (indx = 0; indx < num_ch; indx++)
1211 {
1212 if (channel == valid_ch[indx])
1213 {
1214 break;
1215 }
1216 }
1217
1218 if (indx >= num_ch)
1219 {
1220 hddLog(VOS_TRACE_LEVEL_ERROR,
1221 "%s: Invalid Channel [%d] \n", __func__, channel);
1222 return VOS_STATUS_E_FAILURE;
1223 }
1224 return VOS_STATUS_SUCCESS;
1225
1226}
1227
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001228
Jeff Johnson295189b2012-06-20 16:38:30 -07001229#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1230static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1231 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001232#else
1233static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1234 struct cfg80211_beacon_data *params,
1235 const u8 *ssid, size_t ssid_len,
1236 enum nl80211_hidden_ssid hidden_ssid)
1237#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001238{
1239 tsap_Config_t *pConfig;
1240 beacon_data_t *pBeacon = NULL;
1241 struct ieee80211_mgmt *pMgmt_frame;
1242 v_U8_t *pIe=NULL;
1243 v_U16_t capab_info;
1244 eCsrAuthType RSNAuthType;
1245 eCsrEncryptionType RSNEncryptType;
1246 eCsrEncryptionType mcRSNEncryptType;
1247 int status = VOS_STATUS_SUCCESS;
1248 tpWLAN_SAPEventCB pSapEventCallback;
1249 hdd_hostapd_state_t *pHostapdState;
1250 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1251 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
1252 struct qc_mac_acl_entry *acl_entry = NULL;
1253 v_SINT_t i;
1254
1255 ENTER();
1256
1257 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1258
1259 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1260
1261 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1262
1263 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1264
1265 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1266
1267 //channel is already set in the set_channel Call back
1268 //pConfig->channel = pCommitConfig->channel;
1269
1270 /*Protection parameter to enable or disable*/
1271 pConfig->protEnabled =
1272 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1273
1274 pConfig->dtim_period = pBeacon->dtim_period;
1275
1276 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1277 pConfig->dtim_period);
1278
1279
Jeff Johnson32d95a32012-09-10 13:15:23 -07001280 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
1281 {
1282 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001283 WLAN_EID_COUNTRY);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001284 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001285 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001286 tANI_BOOLEAN restartNeeded;
1287 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
1288 pConfig->ieee80211d = 1;
1289 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1290 sme_setRegInfo(hHal, pConfig->countryCode);
1291 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
1292 /*
1293 * If auto channel is configured i.e. channel is 0,
1294 * so skip channel validation.
1295 */
1296 if( AUTO_CHANNEL_SELECT != pConfig->channel )
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001298 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1299 {
1300 hddLog(VOS_TRACE_LEVEL_ERROR,
1301 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1302 return -EINVAL;
1303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001304 }
1305 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001306 else
1307 {
1308 pConfig->ieee80211d = 0;
1309 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001311 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001312 {
1313 pConfig->ieee80211d = 0;
1314 }
1315 pConfig->authType = eSAP_AUTO_SWITCH;
1316
1317 capab_info = pMgmt_frame->u.beacon.capab_info;
1318
1319 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
1320 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1321
1322 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1323
1324 /*Set wps station to configured*/
1325 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1326
1327 if(pIe)
1328 {
1329 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1330 {
1331 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1332 return -EINVAL;
1333 }
1334 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1335 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001336 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 /* Check 15 bit of WPS IE as it contain information for wps state
1338 * WPS state
1339 */
1340 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1341 {
1342 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1343 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1344 {
1345 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1346 }
1347 }
1348 }
1349 else
1350 {
1351 pConfig->wps_state = SAP_WPS_DISABLED;
1352 }
1353 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
1354
1355 pConfig->RSNWPAReqIELength = 0;
1356 pConfig->pRSNWPAReqIE = NULL;
1357 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1358 WLAN_EID_RSN);
1359 if(pIe && pIe[1])
1360 {
1361 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1362 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1363 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
1364 /* The actual processing may eventually be more extensive than
1365 * this. Right now, just consume any PMKIDs that are sent in
1366 * by the app.
1367 * */
1368 status = hdd_softap_unpackIE(
1369 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1370 &RSNEncryptType,
1371 &mcRSNEncryptType,
1372 &RSNAuthType,
1373 pConfig->pRSNWPAReqIE[1]+2,
1374 pConfig->pRSNWPAReqIE );
1375
1376 if( VOS_STATUS_SUCCESS == status )
1377 {
1378 /* Now copy over all the security attributes you have
1379 * parsed out
1380 * */
1381 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1382 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1383 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1384 = RSNEncryptType;
1385 hddLog( LOG1, FL("%s: CSR AuthType = %d, "
1386 "EncryptionType = %d mcEncryptionType = %d\n"),
1387 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1388 }
1389 }
1390
1391 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1392 pBeacon->tail, pBeacon->tail_len);
1393
1394 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1395 {
1396 if (pConfig->pRSNWPAReqIE)
1397 {
1398 /*Mixed mode WPA/WPA2*/
1399 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1400 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1401 }
1402 else
1403 {
1404 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1405 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1406 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
1407 status = hdd_softap_unpackIE(
1408 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1409 &RSNEncryptType,
1410 &mcRSNEncryptType,
1411 &RSNAuthType,
1412 pConfig->pRSNWPAReqIE[1]+2,
1413 pConfig->pRSNWPAReqIE );
1414
1415 if( VOS_STATUS_SUCCESS == status )
1416 {
1417 /* Now copy over all the security attributes you have
1418 * parsed out
1419 * */
1420 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1421 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1422 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1423 = RSNEncryptType;
1424 hddLog( LOG1, FL("%s: CSR AuthType = %d, "
1425 "EncryptionType = %d mcEncryptionType = %d\n"),
1426 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1427 }
1428 }
1429 }
1430
1431 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1432
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001433#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001434 if (params->ssid != NULL)
1435 {
1436 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1437 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1438 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1439 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1440 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001441#else
1442 if (ssid != NULL)
1443 {
1444 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1445 pConfig->SSIDinfo.ssid.length = ssid_len;
1446 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1447 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1448 }
1449#endif
1450
Jeff Johnson295189b2012-06-20 16:38:30 -07001451 vos_mem_copy(pConfig->self_macaddr.bytes,
1452 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1453
1454 /* default value */
1455 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1456 pConfig->num_accept_mac = 0;
1457 pConfig->num_deny_mac = 0;
1458
1459 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1460 pBeacon->tail, pBeacon->tail_len);
1461
1462 /* pIe for black list is following form:
1463 type : 1 byte
1464 length : 1 byte
1465 OUI : 4 bytes
1466 acl type : 1 byte
1467 no of mac addr in black list: 1 byte
1468 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
1469 */
1470 if ((pIe != NULL) && (pIe[1] != 0))
1471 {
1472 pConfig->SapMacaddr_acl = pIe[6];
1473 pConfig->num_deny_mac = pIe[7];
1474 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
1475 pIe[6], pIe[7]);
1476 if (pConfig->num_deny_mac > MAX_MAC_ADDRESS_DENIED)
1477 pConfig->num_deny_mac = MAX_MAC_ADDRESS_DENIED;
1478 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
1479 for (i = 0; i < pConfig->num_deny_mac; i++)
1480 {
1481 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
1482 acl_entry++;
1483 }
1484 }
1485 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1486 pBeacon->tail, pBeacon->tail_len);
1487
1488 /* pIe for white list is following form:
1489 type : 1 byte
1490 length : 1 byte
1491 OUI : 4 bytes
1492 acl type : 1 byte
1493 no of mac addr in white list: 1 byte
1494 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
1495 */
1496 if ((pIe != NULL) && (pIe[1] != 0))
1497 {
1498 pConfig->SapMacaddr_acl = pIe[6];
1499 pConfig->num_accept_mac = pIe[7];
1500 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
1501 pIe[6], pIe[7]);
1502 if (pConfig->num_accept_mac > MAX_MAC_ADDRESS_ACCEPTED)
1503 pConfig->num_accept_mac = MAX_MAC_ADDRESS_ACCEPTED;
1504 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
1505 for (i = 0; i < pConfig->num_accept_mac; i++)
1506 {
1507 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
1508 acl_entry++;
1509 }
1510 }
1511 wlan_hdd_set_sapHwmode(pHostapdAdapter);
1512
Jeff Johnsone7245742012-09-05 17:12:55 -07001513#ifdef WLAN_FEATURE_11AC
1514 if(((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
1515 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
1516 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) )
1517 {
1518 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
1519 }
1520#endif
1521
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 // ht_capab is not what the name conveys,this is used for protection bitmap
1523 pConfig->ht_capab =
1524 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
1525
1526 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
1527 {
1528 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
1529 return -EINVAL;
1530 }
1531
1532 //Uapsd Enabled Bit
1533 pConfig->UapsdEnable =
1534 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
1535 //Enable OBSS protection
1536 pConfig->obssProtEnabled =
1537 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
1538
1539 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
1540 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
1541 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
1542 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
1543 (int)pConfig->channel);
1544 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
1545 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
1546 pConfig->authType);
1547 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
1548 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
1549 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
1550 pConfig->protEnabled, pConfig->obssProtEnabled);
1551
1552 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
1553 {
1554 //Bss already started. just return.
1555 //TODO Probably it should update some beacon params.
1556 hddLog( LOGE, "Bss Already started...Ignore the request");
1557 EXIT();
1558 return 0;
1559 }
1560
1561 pConfig->persona = pHostapdAdapter->device_mode;
1562
1563 pSapEventCallback = hdd_hostapd_SAPEventCB;
1564 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
1565 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
1566 {
1567 hddLog(LOGE,FL("SAP Start Bss fail\n"));
1568 return -EINVAL;
1569 }
1570
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001571 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
1573
1574 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
1575
1576 if (!VOS_IS_STATUS_SUCCESS(status))
1577 {
1578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1579 ("ERROR: HDD vos wait for single_event failed!!\n"));
1580 VOS_ASSERT(0);
1581 }
1582
1583 //Succesfully started Bss update the state bit.
1584 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
1585
1586 pHostapdState->bCommit = TRUE;
1587 EXIT();
1588
1589 return 0;
1590}
1591
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001592#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001593static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
1594 struct net_device *dev,
1595 struct beacon_parameters *params)
1596{
1597 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1598 int status=VOS_STATUS_SUCCESS;
1599
1600 ENTER();
1601
1602 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
1603
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001604 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
1605 {
1606 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1607 "%s:LOGP in Progress. Ignore!!!", __func__);
1608 return -EAGAIN;
1609 }
1610
Jeff Johnson295189b2012-06-20 16:38:30 -07001611 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
1612#ifdef WLAN_FEATURE_P2P
1613 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
1614#endif
1615 )
1616 {
1617 beacon_data_t *old,*new;
1618
1619 old = pAdapter->sessionCtx.ap.beacon;
1620
1621 if (old)
1622 return -EALREADY;
1623
1624 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
1625
1626 if(status != VOS_STATUS_SUCCESS)
1627 {
1628 hddLog(VOS_TRACE_LEVEL_FATAL,
1629 "%s:Error!!! Allocating the new beacon\n",__func__);
1630 return -EINVAL;
1631 }
1632
1633 pAdapter->sessionCtx.ap.beacon = new;
1634
1635 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
1636 }
1637
1638 EXIT();
1639 return status;
1640}
1641
1642static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
1643 struct net_device *dev,
1644 struct beacon_parameters *params)
1645{
1646 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1647 int status=VOS_STATUS_SUCCESS;
1648
1649 ENTER();
1650
1651 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
1652 __func__,pAdapter->device_mode);
1653
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001654 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
1655 {
1656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1657 "%s:LOGP in Progress. Ignore!!!", __func__);
1658 return -EAGAIN;
1659 }
1660
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
1662#ifdef WLAN_FEATURE_P2P
1663 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
1664#endif
1665 )
1666 {
1667 beacon_data_t *old,*new;
1668
1669 old = pAdapter->sessionCtx.ap.beacon;
1670
1671 if (!old)
1672 return -ENOENT;
1673
1674 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
1675
1676 if(status != VOS_STATUS_SUCCESS) {
1677 hddLog(VOS_TRACE_LEVEL_FATAL,
1678 "%s: Error!!! Allocating the new beacon\n",__func__);
1679 return -EINVAL;
1680 }
1681
1682 pAdapter->sessionCtx.ap.beacon = new;
1683
1684 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
1685 }
1686
1687 EXIT();
1688 return status;
1689}
1690
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001691#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1692
1693#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001694static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
1695 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001696#else
1697static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
1698 struct net_device *dev)
1699#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001700{
1701 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07001702 hdd_context_t *pHddCtx = NULL;
1703 hdd_scaninfo_t *pScanInfo = NULL;
1704 hdd_adapter_t *staAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 VOS_STATUS status = 0;
1706
Jeff Johnsone7245742012-09-05 17:12:55 -07001707 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
1708
1709 if (!staAdapter)
1710 {
1711 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
1712 }
1713
1714 if (staAdapter != NULL)
1715 {
1716 pScanInfo = &staAdapter->scan_info;
1717 }
1718
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 ENTER();
1720
1721 if (NULL == pAdapter)
1722 {
1723 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1724 "%s: HDD adapter context is Null", __FUNCTION__);
1725 return -ENODEV;
1726 }
1727 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1728 {
1729 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1730 return -EAGAIN;
1731 }
1732
1733 pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1734
1735 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
1736 __func__,pAdapter->device_mode);
1737
Jeff Johnsone7245742012-09-05 17:12:55 -07001738 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
1739 {
1740 INIT_COMPLETION(staAdapter->abortscan_event_var);
1741 hdd_abort_mac_scan(staAdapter->pHddCtx);
1742 status = wait_for_completion_interruptible_timeout(
1743 &staAdapter->abortscan_event_var,
1744 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
1745 if (!status)
1746 {
1747 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
1748 "%s: Timeout occured while waiting for abortscan" ,
1749 __FUNCTION__);
1750 VOS_ASSERT(pScanInfo->mScanPending);
1751 return 0;
1752 }
1753 }
1754
Jeff Johnson295189b2012-06-20 16:38:30 -07001755 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
1756#ifdef WLAN_FEATURE_P2P
1757 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
1758#endif
1759 )
1760 {
1761 beacon_data_t *old;
1762
1763 old = pAdapter->sessionCtx.ap.beacon;
1764
1765 if (!old)
1766 return -ENOENT;
1767
1768#ifdef CONFIG_CFG80211
1769 hdd_cleanup_actionframe(pHddCtx, pAdapter);
1770#endif
1771
1772 mutex_lock(&pHddCtx->sap_lock);
1773 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
1774 {
1775 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss((WLAN_HDD_GET_CTX(pAdapter))->pvosContext) ) )
1776 {
1777 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
1778
1779 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
1780
1781 if (!VOS_IS_STATUS_SUCCESS(status))
1782 {
1783 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1784 ("ERROR: HDD vos wait for single_event failed!!\n"));
1785 VOS_ASSERT(0);
1786 }
1787 }
1788 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
1789 }
1790 mutex_unlock(&pHddCtx->sap_lock);
1791
1792 if(status != VOS_STATUS_SUCCESS)
1793 {
1794 hddLog(VOS_TRACE_LEVEL_FATAL,
1795 "%s:Error!!! Stopping the BSS\n",__func__);
1796 return -EINVAL;
1797 }
1798
1799 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
1800 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
1801 ==eHAL_STATUS_FAILURE)
1802 {
1803 hddLog(LOGE,
1804 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
1805 }
1806
1807 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pAdapter))->hHal,
1808 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1809 eANI_BOOLEAN_FALSE) )
1810 {
1811 hddLog(LOGE,
1812 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1813 }
1814
1815 // Reset WNI_CFG_PROBE_RSP Flags
1816 wlan_hdd_reset_prob_rspies(pAdapter);
1817
1818 pAdapter->sessionCtx.ap.beacon = NULL;
1819 kfree(old);
1820 }
1821 EXIT();
1822 return status;
1823}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001824
1825#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
1826
1827static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
1828 struct net_device *dev,
1829 struct cfg80211_ap_settings *params)
1830{
1831 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1832 int status = VOS_STATUS_SUCCESS;
1833
1834 ENTER();
1835
1836 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n", pAdapter->device_mode);
1837
1838 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
1839#ifdef WLAN_FEATURE_P2P
1840 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
1841#endif
1842 )
1843 {
1844 beacon_data_t *old,*new;
1845
1846 old = pAdapter->sessionCtx.ap.beacon;
1847
1848 if (old)
1849 return -EALREADY;
1850
1851 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
1852
1853 if(status != VOS_STATUS_SUCCESS)
1854 {
1855 hddLog(VOS_TRACE_LEVEL_FATAL,
1856 "%s:Error!!! Allocating the new beacon\n",__func__);
1857 return -EINVAL;
1858 }
1859 pAdapter->sessionCtx.ap.beacon = new;
1860 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
1861 params->ssid_len, params->hidden_ssid);
1862 }
1863
1864 EXIT();
1865 return status;
1866}
1867
1868
1869static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
1870 struct net_device *dev,
1871 struct cfg80211_beacon_data *params)
1872{
1873 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1874 int status=VOS_STATUS_SUCCESS;
1875
1876 ENTER();
1877
1878 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
1879 __func__, pAdapter->device_mode);
1880
1881 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
1882#ifdef WLAN_FEATURE_P2P
1883 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
1884#endif
1885 )
1886 {
1887 beacon_data_t *old,*new;
1888
1889 old = pAdapter->sessionCtx.ap.beacon;
1890
1891 if (!old)
1892 return -ENOENT;
1893
1894 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
1895
1896 if(status != VOS_STATUS_SUCCESS) {
1897 hddLog(VOS_TRACE_LEVEL_FATAL,
1898 "%s: Error!!! Allocating the new beacon\n",__func__);
1899 return -EINVAL;
1900 }
1901
1902 pAdapter->sessionCtx.ap.beacon = new;
1903
1904 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
1905 }
1906
1907 EXIT();
1908 return status;
1909}
1910
1911#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
1912
Jeff Johnson295189b2012-06-20 16:38:30 -07001913
1914static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
1915 struct net_device *dev,
1916 struct bss_parameters *params)
1917{
1918 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1919
1920 ENTER();
1921
1922 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
1923 __func__,pAdapter->device_mode);
1924
1925 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
1926#ifdef WLAN_FEATURE_P2P
1927 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
1928#endif
1929 )
1930 {
1931 /* ap_isolate == -1 means that in change bss, upper layer doesn't
1932 * want to update this parameter */
1933 if (-1 != params->ap_isolate)
1934 {
1935 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
1936 }
1937 }
1938
1939 EXIT();
1940 return 0;
1941}
1942
1943/*
1944 * FUNCTION: wlan_hdd_cfg80211_change_iface
1945 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
1946 */
1947int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
1948 struct net_device *ndev,
1949 enum nl80211_iftype type,
1950 u32 *flags,
1951 struct vif_params *params
1952 )
1953{
1954 struct wireless_dev *wdev;
1955 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
1956 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07001957 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 tCsrRoamProfile *pRoamProfile = NULL;
1959 eCsrRoamBssType LastBSSType;
1960 hdd_config_t *pConfig = pHddCtx->cfg_ini;
1961 eMib_dot11DesiredBssType connectedBssType;
1962 VOS_STATUS status;
1963
1964 ENTER();
1965
1966 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
1967 {
1968 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
1969 return -EAGAIN;
1970 }
1971
1972 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
1973 __func__, pAdapter->device_mode);
1974
1975 wdev = ndev->ieee80211_ptr;
1976
1977#ifdef WLAN_BTAMP_FEATURE
1978 if((NL80211_IFTYPE_P2P_CLIENT == type)||
1979 (NL80211_IFTYPE_ADHOC == type)||
1980 (NL80211_IFTYPE_AP == type)||
1981 (NL80211_IFTYPE_P2P_GO == type))
1982 {
1983 pHddCtx->isAmpAllowed = VOS_FALSE;
1984 // stop AMP traffic
1985 status = WLANBAP_StopAmp();
1986 if(VOS_STATUS_SUCCESS != status )
1987 {
1988 pHddCtx->isAmpAllowed = VOS_TRUE;
1989 hddLog(VOS_TRACE_LEVEL_FATAL,
1990 "%s: Failed to stop AMP", __func__);
1991 return -EINVAL;
1992 }
1993 }
1994#endif //WLAN_BTAMP_FEATURE
1995 /* Reset the current device mode bit mask*/
1996 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
1997
1998 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
1999#ifdef WLAN_FEATURE_P2P
2000 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002001 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002002#endif
2003 )
2004 {
2005 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2006 pRoamProfile = &pWextState->roamProfile;
2007 LastBSSType = pRoamProfile->BSSType;
2008
2009 switch (type)
2010 {
2011 case NL80211_IFTYPE_STATION:
2012#ifdef WLAN_FEATURE_P2P
2013 case NL80211_IFTYPE_P2P_CLIENT:
2014#endif
2015 hddLog(VOS_TRACE_LEVEL_INFO,
2016 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2017 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002018#ifdef WLAN_FEATURE_11AC
2019 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2020 {
2021 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2022 }
2023#endif
2024 pRoamProfile->phyMode =
2025 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 wdev->iftype = type;
2027#ifdef WLAN_FEATURE_P2P
2028 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2029 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
2030#endif
2031 break;
2032 case NL80211_IFTYPE_ADHOC:
2033 hddLog(VOS_TRACE_LEVEL_INFO,
2034 "%s: setting interface Type to ADHOC", __func__);
2035 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2036 pRoamProfile->phyMode =
2037 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
2038 wdev->iftype = type;
2039 break;
2040
2041 case NL80211_IFTYPE_AP:
2042#ifdef WLAN_FEATURE_P2P
2043 case NL80211_IFTYPE_P2P_GO:
2044#endif
2045 {
2046 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2047 "%s: setting interface Type to %s", __func__,
2048 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2049
Mohit Khanna0f232092012-09-11 14:46:08 -07002050 if (NL80211_IFTYPE_AP == type)
2051 {
2052 /* As Loading WLAN Driver one interface being created for p2p device
2053 * address. This will take one HW STA and the max number of clients
2054 * that can connect to softAP will be reduced by one. so while changing
2055 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2056 * interface as it is not required in SoftAP mode.
2057 */
2058
2059 // Get P2P Adapter
2060 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2061
2062 if (pP2pAdapter)
2063 {
2064 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2065 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2066 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2067 }
2068 }
2069
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 //De-init the adapter.
2071 hdd_stop_adapter( pHddCtx, pAdapter );
2072 hdd_deinit_adapter( pHddCtx, pAdapter );
2073 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2074#ifdef WLAN_SOFTAP_FEATURE
2075#ifdef WLAN_FEATURE_P2P
2076 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2077 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
2078#else
2079 pAdapter->device_mode = WLAN_HDD_SOFTAP;
2080#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002081
2082 //Disable BMPS and IMPS if enabled
2083 //before starting Go
2084 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2085 {
2086 if(VOS_STATUS_E_FAILURE ==
2087 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2088 {
2089 //Fail to Exit BMPS
2090 VOS_ASSERT(0);
2091 }
2092 }
2093
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 hdd_set_ap_ops( pAdapter->dev );
2095
2096 status = hdd_init_ap_mode(pAdapter);
2097 if(status != VOS_STATUS_SUCCESS)
2098 {
2099 hddLog(VOS_TRACE_LEVEL_FATAL,
2100 "%s: Error initializing the ap mode", __func__);
2101 return -EINVAL;
2102 }
2103 hdd_set_conparam(1);
2104
2105#endif
2106 /*interface type changed update in wiphy structure*/
2107 if(wdev)
2108 {
2109 wdev->iftype = type;
2110 pHddCtx->change_iface = type;
2111 }
2112 else
2113 {
2114 hddLog(VOS_TRACE_LEVEL_ERROR,
2115 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2116 return -EINVAL;
2117 }
2118 goto done;
2119 }
2120
2121 default:
2122 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2123 __func__);
2124 return -EOPNOTSUPP;
2125 }
2126 }
2127 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
2128#ifdef WLAN_FEATURE_P2P
2129 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
2130#endif
2131 )
2132 {
2133 switch(type)
2134 {
2135 case NL80211_IFTYPE_STATION:
2136#ifdef WLAN_FEATURE_P2P
2137 case NL80211_IFTYPE_P2P_CLIENT:
2138#endif
2139 case NL80211_IFTYPE_ADHOC:
Jeff Johnson32d95a32012-09-10 13:15:23 -07002140 hdd_stop_adapter( pHddCtx, pAdapter );
2141 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 wdev->iftype = type;
2143#ifdef WLAN_FEATURE_P2P
2144 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2145 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
2146#endif
2147 hdd_set_conparam(0);
2148 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2150 hdd_set_station_ops( pAdapter->dev );
2151 status = hdd_init_station_mode( pAdapter );
2152 if( VOS_STATUS_SUCCESS != status )
2153 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002154 /* In case of JB, for P2P-GO, only change interface will be called,
2155 * This is the right place to enable back bmps_imps()
2156 */
2157 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 goto done;
2159 case NL80211_IFTYPE_AP:
2160#ifdef WLAN_FEATURE_P2P
2161 case NL80211_IFTYPE_P2P_GO:
2162#endif
2163 wdev->iftype = type;
2164#ifdef WLAN_FEATURE_P2P
2165 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2166 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
2167#endif
2168 goto done;
2169 default:
2170 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2171 __func__);
2172 return -EOPNOTSUPP;
2173
2174 }
2175
2176 }
2177 else
2178 {
2179 return -EOPNOTSUPP;
2180 }
2181
2182
2183 if(pRoamProfile)
2184 {
2185 if ( LastBSSType != pRoamProfile->BSSType )
2186 {
2187 /*interface type changed update in wiphy structure*/
2188 wdev->iftype = type;
2189
2190 /*the BSS mode changed, We need to issue disconnect
2191 if connected or in IBSS disconnect state*/
2192 if ( hdd_connGetConnectedBssType(
2193 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2194 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2195 {
2196 /*need to issue a disconnect to CSR.*/
2197 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2198 if( eHAL_STATUS_SUCCESS ==
2199 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2200 pAdapter->sessionId,
2201 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2202 {
2203 wait_for_completion_interruptible_timeout(
2204 &pAdapter->disconnect_comp_var,
2205 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2206 }
2207 }
2208 }
2209 }
2210
2211done:
2212 /*set bitmask based on updated value*/
2213 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
2214#ifdef WLAN_BTAMP_FEATURE
2215 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
2216 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2217 {
2218 //we are ok to do AMP
2219 pHddCtx->isAmpAllowed = VOS_TRUE;
2220 }
2221#endif //WLAN_BTAMP_FEATURE
2222 EXIT();
2223 return 0;
2224}
2225
2226static int wlan_hdd_change_station(struct wiphy *wiphy,
2227 struct net_device *dev,
2228 u8 *mac,
2229 struct station_parameters *params)
2230{
2231 VOS_STATUS status = VOS_STATUS_SUCCESS;
2232 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
2233 v_MACADDR_t STAMacAddress;
2234
Jeff Johnsone7245742012-09-05 17:12:55 -07002235 ENTER();
2236
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002237 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
2238 {
2239 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2240 "%s:LOGP in Progress. Ignore!!!", __func__);
2241 return -EAGAIN;
2242 }
2243
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
2245
2246 if ( ( pAdapter->device_mode == WLAN_HDD_SOFTAP )
2247#ifdef WLAN_FEATURE_P2P
2248 || ( pAdapter->device_mode == WLAN_HDD_P2P_GO )
2249#endif
2250 )
2251 {
2252 if(params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
2253 {
2254 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
2255 WLANTL_STA_AUTHENTICATED);
2256
2257 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ERROR,
2258 "%s: Station MAC address does not matching", __FUNCTION__);
2259 return -EINVAL;
2260 }
2261 }
2262
Jeff Johnsone7245742012-09-05 17:12:55 -07002263 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002264 return status;
2265}
2266
2267/*
2268 * FUNCTION: wlan_hdd_cfg80211_get_ibss_peer_staidx
2269 * This function is used to get peer station index in IBSS mode
2270 */
2271static u8 wlan_hdd_cfg80211_get_ibss_peer_staidx(hdd_adapter_t* pAdapter)
2272{
2273 u8 idx = 0;
2274 u8 temp[VOS_MAC_ADDR_SIZE] = {0};
2275 ENTER();
2276 memset(temp, 0, VOS_MAC_ADDR_SIZE);
2277 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2278 {
2279 if ( (0 !=
2280 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[idx])
2281 && memcmp((u8*)&(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.peerMacAddress[idx],
2282 temp, VOS_MAC_ADDR_SIZE)
2283 )
2284 {
2285 return idx;
2286 }
2287 }
2288 return idx;
2289}
2290
2291
2292/*
2293 * FUNCTION: wlan_hdd_cfg80211_add_key
2294 * This function is used to initialize the key information
2295 */
2296#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
2297static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
2298 struct net_device *ndev,
2299 u8 key_index, bool pairwise,
2300 const u8 *mac_addr,
2301 struct key_params *params
2302 )
2303#else
2304static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
2305 struct net_device *ndev,
2306 u8 key_index, const u8 *mac_addr,
2307 struct key_params *params
2308 )
2309#endif
2310{
2311 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2312 tCsrRoamSetKey setKey;
2313 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2314 int status = 0;
2315 v_U32_t roamId= 0xFF;
2316 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
2317 hdd_hostapd_state_t *pHostapdState;
2318 VOS_STATUS vos_status;
2319
2320 ENTER();
2321
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002322 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
2323 {
2324 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2325 "%s:LOGP in Progress. Ignore!!!", __func__);
2326 return -EAGAIN;
2327 }
2328
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2330 __func__,pAdapter->device_mode);
2331
2332 if (CSR_MAX_NUM_KEY <= key_index)
2333 {
2334 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
2335 key_index);
2336
2337 return -EINVAL;
2338 }
2339
2340 hddLog(VOS_TRACE_LEVEL_INFO,
2341 "%s: called with key index = %d & key length %d",
2342 __func__, key_index, params->key_len);
2343
2344 /*extract key idx, key len and key*/
2345 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
2346 setKey.keyId = key_index;
2347 setKey.keyLength = params->key_len;
2348 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
2349
2350 switch (params->cipher)
2351 {
2352 case WLAN_CIPHER_SUITE_WEP40:
2353 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
2354 break;
2355
2356 case WLAN_CIPHER_SUITE_WEP104:
2357 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2358 break;
2359
2360 case WLAN_CIPHER_SUITE_TKIP:
2361 {
2362 u8 *pKey = &setKey.Key[0];
2363 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
2364
2365 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
2366
2367 /*Supplicant sends the 32bytes key in this order
2368
2369 |--------------|----------|----------|
2370 | Tk1 |TX-MIC | RX Mic |
2371 |--------------|----------|----------|
2372 <---16bytes---><--8bytes--><--8bytes-->
2373
2374 */
2375 /*Sme expects the 32 bytes key to be in the below order
2376
2377 |--------------|----------|----------|
2378 | Tk1 |RX-MIC | TX Mic |
2379 |--------------|----------|----------|
2380 <---16bytes---><--8bytes--><--8bytes-->
2381 */
2382 /* Copy the Temporal Key 1 (TK1) */
2383 vos_mem_copy(pKey, params->key,16);
2384
2385 /*Copy the rx mic first*/
2386 vos_mem_copy(&pKey[16],&params->key[24],8);
2387
2388 /*Copy the tx mic */
2389 vos_mem_copy(&pKey[24],&params->key[16],8);
2390
2391
2392 break;
2393 }
2394
2395 case WLAN_CIPHER_SUITE_CCMP:
2396 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
2397 break;
2398
2399#ifdef FEATURE_WLAN_WAPI
2400 case WLAN_CIPHER_SUITE_SMS4:
2401 {
2402 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
2403 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
2404 params->key, params->key_len);
2405 return 0;
2406 }
2407#endif
2408#ifdef FEATURE_WLAN_CCX
2409 case WLAN_CIPHER_SUITE_KRK:
2410 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
2411 break;
2412#endif
2413 default:
2414 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu",
2415 __func__, params->cipher);
2416 return -EOPNOTSUPP;
2417 }
2418
2419 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
2420 __func__, setKey.encType);
2421
2422
2423
2424 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
2425#ifdef WLAN_FEATURE_P2P
2426 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
2427#endif
2428 )
2429 {
2430
2431
2432 if (
2433#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
2434 (!pairwise)
2435#else
2436 (!mac_addr || is_broadcast_ether_addr(mac_addr))
2437#endif
2438 )
2439 {
2440 /* set group key*/
2441 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2442 "%s- %d: setting Broacast key",
2443 __func__, __LINE__);
2444 setKey.keyDirection = eSIR_RX_ONLY;
2445 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2446 }
2447 else
2448 {
2449 /* set pairwise key*/
2450 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2451 "%s- %d: setting pairwise key",
2452 __func__, __LINE__);
2453 setKey.keyDirection = eSIR_TX_RX;
2454 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
2455 }
2456
2457 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2458 if( pHostapdState->bssState == BSS_START )
2459 {
2460 status = WLANSAP_SetKeySta( pVosContext, &setKey);
2461
2462 if ( status != eHAL_STATUS_SUCCESS )
2463 {
2464 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2465 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
2466 __LINE__, status );
2467 }
2468 }
2469
2470 /* Saving WEP keys */
2471 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
2472 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
2473 {
2474 //Save the wep key in ap context. Issue setkey after the BSS is started.
2475 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
2476 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
2477 }
2478 else
2479 {
2480 //Save the key in ap context. Issue setkey after the BSS is started.
2481 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
2482 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
2483 }
2484 }
2485 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
2486#ifdef WLAN_FEATURE_P2P
2487 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2488#endif
2489 )
2490 {
2491 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2492 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2493
2494 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
2495
2496 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
2497 params->key, params->key_len);
2498
2499 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
2500
2501 if (!( ( IW_AUTH_KEY_MGMT_802_1X
2502 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
2503 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
2504 )
2505 &&
2506 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
2507 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
2508 )
2509 )
2510 {
2511 /* in case of static WEP, macaddr/bssid is not coming from nl80211
2512 * interface, copy bssid for pairwise key and group macaddr for
2513 * group key initialization*/
2514
2515 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
2516
2517 pWextState->roamProfile.negotiatedUCEncryptionType =
2518 pHddStaCtx->conn_info.ucEncryptionType =
2519 ((WLAN_CIPHER_SUITE_WEP40 == params->cipher) ?
2520 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY :
2521 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY);
2522
2523
2524 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2525 "%s: Negotiated encryption type %d", __func__,
2526 pWextState->roamProfile.negotiatedUCEncryptionType);
2527
2528 sme_SetCfgPrivacy((tpAniSirGlobal)WLAN_HDD_GET_HAL_CTX(pAdapter),
2529 &pWextState->roamProfile, true);
2530 setKey.keyLength = 0;
2531 setKey.keyDirection = eSIR_TX_RX;
2532
2533#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
2534 if (pairwise)
2535 {
2536#endif
2537 if (mac_addr)
2538 {
2539 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
2540 }
2541 else
2542 {
2543 /* macaddr is NULL, set the peerMac to bssId in case of BSS,
2544 * and peerMacAddress in case of IBSS*/
2545 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType)
2546 {
2547 u8 staidx = wlan_hdd_cfg80211_get_ibss_peer_staidx(pAdapter);
2548 if (HDD_MAX_NUM_IBSS_STA != staidx)
2549 {
2550 vos_mem_copy(setKey.peerMac,
2551 &pHddStaCtx->conn_info.peerMacAddress[staidx],
2552 WNI_CFG_BSSID_LEN);
2553
2554 }
2555 else
2556 {
2557 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No peerMac found",
2558 __func__);
2559 return -EOPNOTSUPP;
2560 }
2561 }
2562 else
2563 {
2564 vos_mem_copy(setKey.peerMac,
2565 &pHddStaCtx->conn_info.bssId[0],
2566 WNI_CFG_BSSID_LEN);
2567 }
2568 }
2569#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
2570 }
2571 else
2572 {
2573 /* set group key*/
2574 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2575 "%s- %d: setting Group key",
2576 __func__, __LINE__);
2577 setKey.keyDirection = eSIR_RX_ONLY;
2578 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
2579 }
2580#endif
2581 }
2582 else if (
2583#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
2584 (!pairwise)
2585#else
2586 (!mac_addr || is_broadcast_ether_addr(mac_addr))
2587#endif
2588 )
2589 {
2590 /* set group key*/
2591 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2592 "%s- %d: setting Group key",
2593 __func__, __LINE__);
2594 setKey.keyDirection = eSIR_RX_ONLY;
2595 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2596 }
2597 else
2598 {
2599 /* set pairwise key*/
2600 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2601 "%s- %d: setting pairwise key",
2602 __func__, __LINE__);
2603 setKey.keyDirection = eSIR_TX_RX;
2604 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
2605 }
2606
2607 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2608 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
2609 __func__, setKey.peerMac[0], setKey.peerMac[1],
2610 setKey.peerMac[2], setKey.peerMac[3],
2611 setKey.peerMac[4], setKey.peerMac[5],
2612 setKey.keyDirection);
2613
2614 vos_status = wlan_hdd_check_ula_done(pAdapter);
2615
2616 if ( vos_status != VOS_STATUS_SUCCESS )
2617 {
2618 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2619 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
2620 __LINE__, vos_status );
2621
2622 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2623
2624 return -EINVAL;
2625
2626 }
2627
2628
2629 /* issue set key request to SME*/
2630 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2631 pAdapter->sessionId, &setKey, &roamId );
2632
2633 if ( 0 != status )
2634 {
2635 hddLog(VOS_TRACE_LEVEL_ERROR,
2636 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
2637 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2638 return -EINVAL;
2639 }
2640
2641
2642 /* in case of IBSS as there was no information available about WEP keys during
2643 * IBSS join, group key intialized with NULL key, so re-initialize group key
2644 * with correct value*/
2645 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
2646 !( ( IW_AUTH_KEY_MGMT_802_1X
2647 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
2648 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
2649 )
2650 &&
2651 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
2652 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
2653 )
2654 )
2655 {
2656 setKey.keyDirection = eSIR_RX_ONLY;
2657 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
2658
2659 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2660 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
2661 __func__, setKey.peerMac[0], setKey.peerMac[1],
2662 setKey.peerMac[2], setKey.peerMac[3],
2663 setKey.peerMac[4], setKey.peerMac[5],
2664 setKey.keyDirection);
2665
2666 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2667 pAdapter->sessionId, &setKey, &roamId );
2668
2669 if ( 0 != status )
2670 {
2671 hddLog(VOS_TRACE_LEVEL_ERROR,
2672 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
2673 __func__, status);
2674 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2675 return -EINVAL;
2676 }
2677 }
2678 }
2679
2680 return 0;
2681}
2682
2683/*
2684 * FUNCTION: wlan_hdd_cfg80211_get_key
2685 * This function is used to get the key information
2686 */
2687#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
2688static int wlan_hdd_cfg80211_get_key(
2689 struct wiphy *wiphy,
2690 struct net_device *ndev,
2691 u8 key_index, bool pairwise,
2692 const u8 *mac_addr, void *cookie,
2693 void (*callback)(void *cookie, struct key_params*)
2694 )
2695#else
2696static int wlan_hdd_cfg80211_get_key(
2697 struct wiphy *wiphy,
2698 struct net_device *ndev,
2699 u8 key_index, const u8 *mac_addr, void *cookie,
2700 void (*callback)(void *cookie, struct key_params*)
2701 )
2702#endif
2703{
2704 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2705 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2706 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
2707 struct key_params params;
2708
2709 ENTER();
2710
2711 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2712 __func__,pAdapter->device_mode);
2713
2714 memset(&params, 0, sizeof(params));
2715
2716 if (CSR_MAX_NUM_KEY <= key_index)
2717 {
2718 return -EINVAL;
2719 }
2720
2721 switch(pRoamProfile->EncryptionType.encryptionType[0])
2722 {
2723 case eCSR_ENCRYPT_TYPE_NONE:
2724 params.cipher = IW_AUTH_CIPHER_NONE;
2725 break;
2726
2727 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
2728 case eCSR_ENCRYPT_TYPE_WEP40:
2729 params.cipher = WLAN_CIPHER_SUITE_WEP40;
2730 break;
2731
2732 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
2733 case eCSR_ENCRYPT_TYPE_WEP104:
2734 params.cipher = WLAN_CIPHER_SUITE_WEP104;
2735 break;
2736
2737 case eCSR_ENCRYPT_TYPE_TKIP:
2738 params.cipher = WLAN_CIPHER_SUITE_TKIP;
2739 break;
2740
2741 case eCSR_ENCRYPT_TYPE_AES:
2742 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
2743 break;
2744
2745 default:
2746 params.cipher = IW_AUTH_CIPHER_NONE;
2747 break;
2748 }
2749
2750 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
2751 params.seq_len = 0;
2752 params.seq = NULL;
2753 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
2754 callback(cookie, &params);
2755 return 0;
2756}
2757
2758/*
2759 * FUNCTION: wlan_hdd_cfg80211_del_key
2760 * This function is used to delete the key information
2761 */
2762#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
2763static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
2764 struct net_device *ndev,
2765 u8 key_index,
2766 bool pairwise,
2767 const u8 *mac_addr
2768 )
2769#else
2770static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
2771 struct net_device *ndev,
2772 u8 key_index,
2773 const u8 *mac_addr
2774 )
2775#endif
2776{
2777 int status = 0;
2778
2779 //This code needs to be revisited. There is sme_removeKey API, we should
2780 //plan to use that. After the change to use correct index in setkey,
2781 //it is observed that this is invalidating peer
2782 //key index whenever re-key is done. This is affecting data link.
2783 //It should be ok to ignore del_key.
2784#if 0
2785 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2786 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
2787 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2788 tCsrRoamSetKey setKey;
2789 v_U32_t roamId= 0xFF;
2790
2791 ENTER();
2792
2793 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
2794 __func__,pAdapter->device_mode);
2795
2796 if (CSR_MAX_NUM_KEY <= key_index)
2797 {
2798 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
2799 key_index);
2800
2801 return -EINVAL;
2802 }
2803
2804 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
2805 setKey.keyId = key_index;
2806
2807 if (mac_addr)
2808 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
2809 else
2810 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
2811
2812 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
2813
2814 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
2815#ifdef WLAN_FEATURE_P2P
2816 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
2817#endif
2818 )
2819 {
2820
2821 hdd_hostapd_state_t *pHostapdState =
2822 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2823 if( pHostapdState->bssState == BSS_START)
2824 {
2825 status = WLANSAP_SetKeySta( pVosContext, &setKey);
2826
2827 if ( status != eHAL_STATUS_SUCCESS )
2828 {
2829 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2830 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
2831 __LINE__, status );
2832 }
2833 }
2834 }
2835 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
2836#ifdef WLAN_FEATURE_P2P
2837 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2838#endif
2839 )
2840 {
2841 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2842
2843 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
2844
2845 hddLog(VOS_TRACE_LEVEL_INFO_MED,
2846 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
2847 __func__, setKey.peerMac[0], setKey.peerMac[1],
2848 setKey.peerMac[2], setKey.peerMac[3],
2849 setKey.peerMac[4], setKey.peerMac[5]);
2850 if(pAdapter->sessionCtx.station.conn_info.connState ==
2851 eConnectionState_Associated)
2852 {
2853 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2854 pAdapter->sessionId, &setKey, &roamId );
2855
2856 if ( 0 != status )
2857 {
2858 hddLog(VOS_TRACE_LEVEL_ERROR,
2859 "%s: sme_RoamSetKey failure, returned %d",
2860 __func__, status);
2861 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2862 return -EINVAL;
2863 }
2864 }
2865 }
2866#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002867 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 return status;
2869}
2870
2871/*
2872 * FUNCTION: wlan_hdd_cfg80211_set_default_key
2873 * This function is used to set the default tx key index
2874 */
2875#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
2876static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
2877 struct net_device *ndev,
2878 u8 key_index,
2879 bool unicast, bool multicast)
2880#else
2881static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
2882 struct net_device *ndev,
2883 u8 key_index)
2884#endif
2885{
2886 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2887 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2888 int status = 0;
2889 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2890
2891 ENTER();
2892
2893 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
2894 __func__,pAdapter->device_mode, key_index);
2895
2896 if (CSR_MAX_NUM_KEY <= key_index)
2897 {
2898 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
2899 key_index);
2900
2901 return -EINVAL;
2902 }
2903
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002904 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
2905 {
2906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2907 "%s:LOGP in Progress. Ignore!!!", __func__);
2908 return -EAGAIN;
2909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002910
2911 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
2912#ifdef WLAN_FEATURE_P2P
2913 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2914#endif
2915 )
2916 {
2917 if ( (key_index != pWextState->roamProfile.Keys.defaultIndex) &&
2918 (eCSR_ENCRYPT_TYPE_TKIP !=
2919 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
2920 (eCSR_ENCRYPT_TYPE_AES !=
2921 pWextState->roamProfile.EncryptionType.encryptionType[0])
2922 )
2923 {
2924 /* if default key index is not same as previous one,
2925 * then update the default key index */
2926
2927 tCsrRoamSetKey setKey;
2928 v_U32_t roamId= 0xFF;
2929 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
2930
2931 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
2932 __func__, key_index);
2933
2934 Keys->defaultIndex = (u8)key_index;
2935 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
2936 setKey.keyId = key_index;
2937 setKey.keyLength = Keys->KeyLength[key_index];
2938
2939 vos_mem_copy(&setKey.Key[0],
2940 &Keys->KeyMaterial[key_index][0],
2941 Keys->KeyLength[key_index]);
2942
2943 setKey.keyDirection = eSIR_TX_ONLY;
2944
2945 vos_mem_copy(setKey.peerMac,
2946 &pHddStaCtx->conn_info.bssId[0],
2947 WNI_CFG_BSSID_LEN);
2948
2949 setKey.encType =
2950 pWextState->roamProfile.EncryptionType.encryptionType[0];
2951
2952 /* issue set key request */
2953 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2954 pAdapter->sessionId, &setKey, &roamId );
2955
2956 if ( 0 != status )
2957 {
2958 hddLog(VOS_TRACE_LEVEL_ERROR,
2959 "%s: sme_RoamSetKey failed, returned %d", __func__,
2960 status);
2961 return -EINVAL;
2962 }
2963 }
2964 }
2965
2966 /* In SoftAp mode setting key direction for default mode */
2967 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
2968 {
2969 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
2970 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
2971 (eCSR_ENCRYPT_TYPE_AES !=
2972 pWextState->roamProfile.EncryptionType.encryptionType[0])
2973 )
2974 {
2975 /* Saving key direction for default key index to TX default */
2976 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
2977 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
2978 }
2979 }
2980
2981 return status;
2982}
2983
2984/**
2985 * FUNCTION: wlan_hdd_cfg80211_set_channel
2986 * This function is used to set the channel number
2987 */
2988int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
2989 struct ieee80211_channel *chan,
2990 enum nl80211_channel_type channel_type
2991 )
2992{
2993 v_U32_t num_ch = 0;
2994 u32 channel = 0;
2995 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
2996 int freq = chan->center_freq; /* freq is in MHZ */
2997
2998 ENTER();
2999
3000 hddLog(VOS_TRACE_LEVEL_INFO,
3001 "%s: device_mode = %d freq = %d \n",__func__,
3002 pAdapter->device_mode, chan->center_freq);
3003
3004 /*
3005 * Do freq to chan conversion
3006 * TODO: for 11a
3007 */
3008
3009 channel = ieee80211_frequency_to_channel(freq);
3010
3011 /* Check freq range */
3012 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
3013 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
3014 {
3015 hddLog(VOS_TRACE_LEVEL_ERROR,
3016 "%s: Channel [%d] is outside valid range from %d to %d\n",
3017 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
3018 WNI_CFG_CURRENT_CHANNEL_STAMAX);
3019 return -EINVAL;
3020 }
3021
3022 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
3023
3024 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode)
3025#ifdef WLAN_FEATURE_P2P
3026 && (WLAN_HDD_P2P_GO != pAdapter->device_mode)
3027#endif
3028 )
3029 {
3030 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
3031 {
3032 hddLog(VOS_TRACE_LEVEL_ERROR,
3033 "%s: Invalid Channel [%d] \n", __func__, channel);
3034 return -EINVAL;
3035 }
3036 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3037 "%s: set channel to [%d] for device mode =%d",
3038 __func__, channel,pAdapter->device_mode);
3039 }
3040 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3041#ifdef WLAN_FEATURE_P2P
3042 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
3043#endif
3044 )
3045 {
3046 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3047 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
3048 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3049
3050 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
3051 {
3052 /* Link is up then return cant set channel*/
3053 hddLog( VOS_TRACE_LEVEL_ERROR,
3054 "%s: IBSS Associated, can't set the channel\n", __func__);
3055 return -EINVAL;
3056 }
3057
3058 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
3059 pHddStaCtx->conn_info.operationChannel = channel;
3060 pRoamProfile->ChannelInfo.ChannelList =
3061 &pHddStaCtx->conn_info.operationChannel;
3062 }
3063 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3064#ifdef WLAN_FEATURE_P2P
3065 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
3066#endif
3067 )
3068 {
3069 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
3070
3071 if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3072 {
3073 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
3074
3075 /* If auto channel selection is configured as enable/ 1 then ignore
3076 channel set by supplicant
3077 */
3078 if ( cfg_param->apAutoChannelSelection )
3079 {
3080 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = AUTO_CHANNEL_SELECT;
3081
3082 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3083 "%s: set channel to auto channel (0) for device mode =%d",
3084 __func__, pAdapter->device_mode);
3085 }
3086 }
3087 }
3088 else
3089 {
3090 hddLog(VOS_TRACE_LEVEL_FATAL,
3091 "%s: Invalid device mode failed to set valid channel", __func__);
3092 return -EINVAL;
3093 }
3094 EXIT();
3095 return 0;
3096}
3097
3098
3099
3100/*
3101 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3102 * This function is used to inform the BSS details to nl80211 interface.
3103 */
3104static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3105 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3106{
3107 struct net_device *dev = pAdapter->dev;
3108 struct wireless_dev *wdev = dev->ieee80211_ptr;
3109 struct wiphy *wiphy = wdev->wiphy;
3110 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3111 int chan_no;
3112 int ie_length;
3113 const char *ie;
3114 unsigned int freq;
3115 struct ieee80211_channel *chan;
3116 int rssi = 0;
3117 struct cfg80211_bss *bss = NULL;
3118
3119 ENTER();
3120
3121 if( NULL == pBssDesc )
3122 {
3123 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
3124 return bss;
3125 }
3126
3127 chan_no = pBssDesc->channelId;
3128 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
3129 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
3130
3131 if( NULL == ie )
3132 {
3133 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
3134 return bss;
3135 }
3136
3137#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
3138 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
3139 {
3140 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
3141 }
3142 else
3143 {
3144 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
3145 }
3146#else
3147 freq = ieee80211_channel_to_frequency(chan_no);
3148#endif
3149
3150 chan = __ieee80211_get_channel(wiphy, freq);
3151
3152 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
3153 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
3154 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
3155 if (bss == NULL)
3156 {
3157 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
3158
3159 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
3160 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
3161 pBssDesc->capabilityInfo,
3162 pBssDesc->beaconInterval, ie, ie_length,
3163 rssi, GFP_KERNEL ));
3164}
3165 else
3166 {
3167 return bss;
3168 }
3169}
3170
3171
3172
3173/*
3174 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
3175 * This function is used to inform the BSS details to nl80211 interface.
3176 */
3177struct cfg80211_bss*
3178wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
3179 tSirBssDescription *bss_desc
3180 )
3181{
3182 /*
3183 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
3184 already exists in bss data base of cfg80211 for that particular BSS ID.
3185 Using cfg80211_inform_bss_frame to update the bss entry instead of
3186 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
3187 now there is no possibility to get the mgmt(probe response) frame from PE,
3188 converting bss_desc to ieee80211_mgmt(probe response) and passing to
3189 cfg80211_inform_bss_frame.
3190 */
3191 struct net_device *dev = pAdapter->dev;
3192 struct wireless_dev *wdev = dev->ieee80211_ptr;
3193 struct wiphy *wiphy = wdev->wiphy;
3194 int chan_no = bss_desc->channelId;
3195 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
3196 const char *ie =
3197 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
3198 unsigned int freq;
3199 struct ieee80211_channel *chan;
3200 struct ieee80211_mgmt *mgmt =
3201 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
3202 struct cfg80211_bss *bss_status = NULL;
3203 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
3204 int rssi = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07003205#ifdef WLAN_OPEN_SOURCE
3206 struct timespec ts;
3207#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003208
3209 ENTER();
3210
3211 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07003212
3213#ifdef WLAN_OPEN_SOURCE
3214 /* Android does not want the timestamp from the frame.
3215 Instead it wants a monotonic increasing value */
3216 get_monotonic_boottime(&ts);
3217 mgmt->u.probe_resp.timestamp =
3218 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
3219#else
3220 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
3222 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07003223
3224#endif
3225
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
3227 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
3228 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
3229
3230 mgmt->frame_control |=
3231 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
3232
3233#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
3234 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
3235 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
3236 {
3237 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
3238 }
3239 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
3240 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
3241
3242 {
3243 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
3244 }
3245 else
3246 {
3247 kfree(mgmt);
3248 return NULL;
3249 }
3250#else
3251 freq = ieee80211_channel_to_frequency(chan_no);
3252#endif
3253 chan = __ieee80211_get_channel(wiphy, freq);
3254
3255 /*To keep the rssi icon of the connected AP in the scan window
3256 *and the rssi icon of the wireless networks in sync
3257 * */
3258 if (( eConnectionState_Associated ==
3259 pAdapter->sessionCtx.station.conn_info.connState ) &&
3260 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
3261 pAdapter->sessionCtx.station.conn_info.bssId,
3262 WNI_CFG_BSSID_LEN)))
3263 {
3264 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
3265 rssi = (pAdapter->rssi * 100);
3266 }
3267 else
3268 {
3269 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
3270 }
3271
3272 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
3273 frame_len, rssi, GFP_KERNEL);
3274 kfree(mgmt);
3275 return bss_status;
3276}
3277
3278/*
3279 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
3280 * This function is used to update the BSS data base of CFG8011
3281 */
3282struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
3283 tCsrRoamInfo *pRoamInfo
3284 )
3285{
3286 tCsrRoamConnectedProfile roamProfile;
3287 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3288 struct cfg80211_bss *bss = NULL;
3289
3290 ENTER();
3291
3292 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
3293 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
3294
3295 if (NULL != roamProfile.pBssDesc)
3296 {
3297 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
3298 &roamProfile);
3299
3300 if (NULL == bss)
3301 {
3302 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
3303 __func__);
3304 }
3305
3306 sme_RoamFreeConnectProfile(hHal, &roamProfile);
3307 }
3308 else
3309 {
3310 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
3311 __func__);
3312 }
3313 return bss;
3314}
3315
3316/*
3317 * FUNCTION: wlan_hdd_cfg80211_update_bss
3318 */
3319static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
3320 hdd_adapter_t *pAdapter
3321 )
3322{
3323 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3324 tCsrScanResultInfo *pScanResult;
3325 eHalStatus status = 0;
3326 tScanResultHandle pResult;
3327 struct cfg80211_bss *bss_status = NULL;
3328
3329 ENTER();
3330
3331 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3332 {
3333 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
3334 return -EAGAIN;
3335 }
3336
3337 /*
3338 * start getting scan results and populate cgf80211 BSS database
3339 */
3340 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
3341
3342 /* no scan results */
3343 if (NULL == pResult)
3344 {
3345 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
3346 return status;
3347 }
3348
3349 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
3350
3351 while (pScanResult)
3352 {
3353 /*
3354 * cfg80211_inform_bss() is not updating ie field of bss entry, if
3355 * entry already exists in bss data base of cfg80211 for that
3356 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
3357 * bss entry instead of cfg80211_inform_bss, But this call expects
3358 * mgmt packet as input. As of now there is no possibility to get
3359 * the mgmt(probe response) frame from PE, converting bss_desc to
3360 * ieee80211_mgmt(probe response) and passing to c
3361 * fg80211_inform_bss_frame.
3362 * */
3363
3364 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
3365 &pScanResult->BssDescriptor);
3366
3367
3368 if (NULL == bss_status)
3369 {
3370 hddLog(VOS_TRACE_LEVEL_INFO,
3371 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
3372 }
3373 else
3374 {
3375 cfg80211_put_bss(bss_status);
3376 }
3377
3378 pScanResult = sme_ScanResultGetNext(hHal, pResult);
3379 }
3380
3381 sme_ScanResultPurge(hHal, pResult);
3382
3383 return 0;
3384}
3385
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003386void
3387hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
3388{
3389 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
3390 "%X:%X:%X:%X:%X:%X\n",
3391 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
3392 macAddr[5]);
3393} /****** end hddPrintMacAddr() ******/
3394
3395void
3396hddPrintPmkId(tCsrBssid pmkId, tANI_U8 logLevel)
3397{
3398 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
3399 "%X:%X:%X:%X:%X:%X:%X:%X:%X:%X:%X:%X:%X:%X:%X:%X\n",
3400 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
3401 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9],
3402 pmkId[10], pmkId[11], pmkId[12], pmkId[13], pmkId[14],
3403 pmkId[15]);
3404} /****** end hddPrintPmkId() ******/
3405
3406//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
3407//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
3408
3409//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
3410//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
3411
3412#define dump_bssid(bssid) \
3413 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07003414 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
3415 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
3416 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003417 }
3418
3419#define dump_pmkid(pMac, pmkid) \
3420 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07003421 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
3422 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
3423 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003424 }
3425
3426#ifdef FEATURE_WLAN_LFR
3427/*
3428 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
3429 * This function is used to notify the supplicant of a new PMKSA candidate.
3430 */
3431int wlan_hdd_cfg80211_pmksa_candidate_notify(
3432 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3433 int index, bool preauth )
3434{
Jeff Johnsone7245742012-09-05 17:12:55 -07003435#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003436 struct net_device *dev = pAdapter->dev;
3437
3438 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07003439 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003440
3441 if( NULL == pRoamInfo )
3442 {
3443 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
3444 return -EINVAL;
3445 }
3446
3447 dump_bssid(pRoamInfo->bssid);
3448 cfg80211_pmksa_candidate_notify(dev, index,
3449 pRoamInfo->bssid, preauth, GFP_KERNEL);
Jeff Johnsone7245742012-09-05 17:12:55 -07003450#endif /* FEATURE_WLAN_OKC */
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003451 return 0;
3452}
3453#endif //FEATURE_WLAN_LFR
3454
Jeff Johnson295189b2012-06-20 16:38:30 -07003455/*
3456 * FUNCTION: hdd_cfg80211_scan_done_callback
3457 * scanning callback function, called after finishing scan
3458 *
3459 */
3460static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
3461 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
3462{
3463 struct net_device *dev = (struct net_device *) pContext;
3464 //struct wireless_dev *wdev = dev->ieee80211_ptr;
3465 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
3466 hdd_scaninfo_t *pScanInfo = &pAdapter->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 struct cfg80211_scan_request *req = NULL;
3468 int ret = 0;
3469
3470 ENTER();
3471
3472 hddLog(VOS_TRACE_LEVEL_INFO,
3473 "%s called with halHandle = %p, pContext = %p,"
3474 "scanID = %d, returned status = %d\n",
3475 __func__, halHandle, pContext, (int) scanId, (int) status);
3476
3477 //Block on scan req completion variable. Can't wait forever though.
3478 ret = wait_for_completion_interruptible_timeout(
3479 &pScanInfo->scan_req_completion_event,
3480 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
3481 if (!ret)
3482 {
3483 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07003484 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 }
3486
3487 if(pScanInfo->mScanPending != VOS_TRUE)
3488 {
3489 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07003490 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 }
3492
3493 /* Check the scanId */
3494 if (pScanInfo->scanId != scanId)
3495 {
3496 hddLog(VOS_TRACE_LEVEL_INFO,
3497 "%s called with mismatched scanId pScanInfo->scanId = %d "
3498 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
3499 (int) scanId);
3500 }
3501
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
3503 pAdapter);
3504
3505 if (0 > ret)
3506 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
3507
3508
3509 /* If any client wait scan result through WEXT
3510 * send scan done event to client */
3511 if (pAdapter->scan_info.waitScanResult)
3512 {
3513 /* The other scan request waiting for current scan finish
3514 * Send event to notify current scan finished */
3515 if(WEXT_SCAN_PENDING_DELAY == pAdapter->scan_info.scan_pending_option)
3516 {
3517 vos_event_set(&pAdapter->scan_info.scan_finished_event);
3518 }
3519 /* Send notify to WEXT client */
3520 else if(WEXT_SCAN_PENDING_PIGGYBACK == pAdapter->scan_info.scan_pending_option)
3521 {
3522 struct net_device *dev = pAdapter->dev;
3523 union iwreq_data wrqu;
3524 int we_event;
3525 char *msg;
3526
3527 memset(&wrqu, '\0', sizeof(wrqu));
3528 we_event = SIOCGIWSCAN;
3529 msg = NULL;
3530 wireless_send_event(dev, we_event, &wrqu, msg);
3531 }
3532 }
3533 pAdapter->scan_info.waitScanResult = FALSE;
3534
3535 /* Get the Scan Req */
3536 req = pAdapter->request;
3537
3538 if (!req)
3539 {
3540 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07003541 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003542 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 }
3544
3545 /*
3546 * setting up 0, just in case.
3547 */
3548 req->n_ssids = 0;
3549 req->n_channels = 0;
3550 req->ie = 0;
3551
3552 /*
3553 * cfg80211_scan_done informing NL80211 about completion
3554 * of scanning
3555 */
3556 cfg80211_scan_done(req, false);
3557 complete(&pAdapter->abortscan_event_var);
3558 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07003559 /* Scan is no longer pending */
3560 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003561
3562#ifdef WLAN_FEATURE_P2P
3563 /* Flush out scan result after p2p_serach is done */
Jeff Johnsone7245742012-09-05 17:12:55 -07003564 if(pScanInfo->flushP2pScanResults)
Jeff Johnson295189b2012-06-20 16:38:30 -07003565 {
3566 tANI_U8 sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 sme_ScanFlushResult(WLAN_HDD_GET_HAL_CTX(pAdapter), sessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07003568 pScanInfo->flushP2pScanResults = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 }
3570#endif
3571
Jeff Johnsone7245742012-09-05 17:12:55 -07003572allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07003573 /* release the wake lock at the end of the scan*/
3574 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07003575
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 EXIT();
3577 return 0;
3578}
3579
3580/*
3581 * FUNCTION: wlan_hdd_cfg80211_scan
3582 * this scan respond to scan trigger and update cfg80211 scan database
3583 * later, scan dump command can be used to recieve scan results
3584 */
3585int wlan_hdd_cfg80211_scan( struct wiphy *wiphy, struct net_device *dev,
3586 struct cfg80211_scan_request *request)
3587{
3588 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
3589 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
3590 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3591 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
3592 tCsrScanRequest scanRequest;
3593 tANI_U8 *channelList = NULL, i;
3594 v_U32_t scanId = 0;
3595 int status = 0;
3596 hdd_scaninfo_t *pScanInfo = &pAdapter->scan_info;
3597#ifdef WLAN_FEATURE_P2P
3598 v_U8_t* pP2pIe = NULL;
3599#endif
3600
3601 ENTER();
3602
3603 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3604 __func__,pAdapter->device_mode);
3605#ifdef WLAN_BTAMP_FEATURE
3606 //Scan not supported when AMP traffic is on.
3607 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
3608 {
3609 hddLog(VOS_TRACE_LEVEL_ERROR,
3610 "%s: No scanning when AMP is on", __func__);
3611 return -EOPNOTSUPP;
3612 }
3613#endif
3614 //Scan on any other interface is not supported.
3615 if( pAdapter->device_mode == WLAN_HDD_SOFTAP )
3616 {
3617 hddLog(VOS_TRACE_LEVEL_ERROR,
3618 "%s: Not scanning on device_mode = %d",
3619 __func__, pAdapter->device_mode);
3620 return -EOPNOTSUPP;
3621 }
3622
3623 if (TRUE == pScanInfo->mScanPending)
3624 {
3625 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__);
3626 return -EBUSY;
3627 }
3628
3629 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3630 {
3631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3632 "%s:LOGP in Progress. Ignore!!!", __func__);
3633 return -EAGAIN;
3634 }
3635
Mohit Khanna6c52bbf2012-09-11 15:10:12 -07003636 if ((WLAN_HDD_GET_CTX(pAdapter))->isLoadUnloadInProgress)
3637 {
3638 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3639 "%s:Unloading/Loading in Progress. Ignore!!!", __func__);
3640 return -EAGAIN;
3641 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07003642 //Don't Allow Scan and return busy if Remain On
3643 //Channel and action frame is pending
3644 //Otherwise Cancel Remain On Channel and allow Scan
3645 //If no action frame pending
3646 if(0 != wlan_hdd_check_remain_on_channel(pAdapter))
3647 {
3648 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__);
3649 return -EBUSY;
3650 }
3651
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
3653 {
3654 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
3655 "%s: Aquire lock fail", __func__);
3656 return -EAGAIN;
3657 }
3658 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
3659 {
3660 hddLog(VOS_TRACE_LEVEL_WARN,
3661 "%s: MAX TM Level Scan not allowed", __func__);
3662 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
3663 return -EBUSY;
3664 }
3665 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
3666
3667 vos_mem_zero( &scanRequest, sizeof(scanRequest));
3668
3669 if (NULL != request)
3670 {
3671 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
3672 (int)request->n_ssids);
3673
3674 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
3675 * Becasue of this, driver is assuming that this is not wildcard scan and so
3676 * is not aging out the scan results.
3677 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07003678 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 {
3680 request->n_ssids = 0;
3681 }
3682
3683 if (0 < request->n_ssids)
3684 {
3685 tCsrSSIDInfo *SsidInfo;
3686 int j;
3687 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
3688 /* Allocate num_ssid tCsrSSIDInfo structure */
3689 SsidInfo = scanRequest.SSIDs.SSIDList =
3690 ( tCsrSSIDInfo *)vos_mem_malloc(
3691 request->n_ssids*sizeof(tCsrSSIDInfo));
3692
3693 if(NULL == scanRequest.SSIDs.SSIDList)
3694 {
3695 hddLog(VOS_TRACE_LEVEL_ERROR,
3696 "memory alloc failed SSIDInfo buffer");
3697 return -ENOMEM;
3698 }
3699
3700 /* copy all the ssid's and their length */
3701 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
3702 {
3703 /* get the ssid length */
3704 SsidInfo->SSID.length = request->ssids[j].ssid_len;
3705 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
3706 SsidInfo->SSID.length);
3707 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
3708 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
3709 j, SsidInfo->SSID.ssId);
3710 }
3711 /* set the scan type to active */
3712 scanRequest.scanType = eSIR_ACTIVE_SCAN;
3713 }
3714 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
3715 {
3716 /* set the scan type to active */
3717 scanRequest.scanType = eSIR_ACTIVE_SCAN;
3718 }
3719 else
3720 {
3721 /*Set the scan type to default type, in this case it is ACTIVE*/
3722 scanRequest.scanType = pScanInfo->scan_mode;
3723 }
3724 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
3725 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
3726 }
3727 else
3728 {
3729 /* set the scan type to active */
3730 scanRequest.scanType = eSIR_ACTIVE_SCAN;
3731 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
3732
3733 /* set min and max channel time to zero */
3734 scanRequest.minChnTime = 0;
3735 scanRequest.maxChnTime = 0;
3736 }
3737
3738 /* set BSSType to default type */
3739 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
3740
3741 /*TODO: scan the requested channels only*/
3742
3743 /*Right now scanning all the channels */
3744 if( request )
3745 {
3746 if( request->n_channels )
3747 {
3748 channelList = vos_mem_malloc( request->n_channels );
3749 if( NULL == channelList )
3750 {
3751 status = -ENOMEM;
3752 goto free_mem;
3753 }
3754
3755 for( i = 0 ; i < request->n_channels ; i++ )
3756 channelList[i] = request->channels[i]->hw_value;
3757 }
3758
3759 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
3760 scanRequest.ChannelInfo.ChannelList = channelList;
3761
3762 /* set requestType to full scan */
3763 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
3764
3765 if( request->ie_len )
3766 {
3767 /* save this for future association (join requires this) */
3768 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
3769 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
3770 pScanInfo->scanAddIE.length = request->ie_len;
3771
3772 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07003773 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
3774 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 )
3776 {
3777 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
3778 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
3779 }
3780
3781 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
3782 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
3783
3784#ifdef WLAN_FEATURE_P2P
3785 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
3786 request->ie_len);
3787 if (pP2pIe != NULL)
3788 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003789 /* no_cck will be set during p2p find to disable 11b rates */
3790 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 {
3792 tANI_U8 sessionId = pAdapter->sessionId;
3793 hddLog(VOS_TRACE_LEVEL_INFO,
3794 "%s: This is a P2P Search", __func__);
3795 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07003796
3797 /* Flush the scan results only for P2P search.
3798 P2P search happens on 3 social channels (1, 6, 11) */
3799 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
3800 {
3801 pScanInfo->flushP2pScanResults = 1;
3802 sme_ScanFlushResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
3803 sessionId );
3804 }
3805
3806 /*
3807 Skip Dfs Channel in case of P2P Search
3808 if it is set in ini file
3809 */
3810 if(cfg_param->skipDfsChnlInP2pSearch)
3811 {
3812 scanRequest.skipDfsChnlInP2pSearch = 1;
3813 }
3814 else
3815 {
3816 scanRequest.skipDfsChnlInP2pSearch = 0;
3817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003818
3819 /* set requestType to P2P Discovery */
3820 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 }
3822 }
3823#endif
3824 }
3825 }
3826
3827 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
3828
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07003829 /* acquire the wakelock to avoid the apps suspend during the scan. To
3830 * address the following issues.
3831 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
3832 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
3833 * for long time, this result in apps running at full power for long time.
3834 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
3835 * be stuck in full power because of resume BMPS
3836 */
3837 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07003838
3839 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 pAdapter->sessionId, &scanRequest, &scanId,
3841 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07003842
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 if (eHAL_STATUS_SUCCESS != status)
3844 {
3845 hddLog(VOS_TRACE_LEVEL_ERROR,
3846 "%s: sme_ScanRequest returned error %d", __func__, status);
3847 complete(&pScanInfo->scan_req_completion_event);
3848 status = -EIO;
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07003849 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 goto free_mem;
3851 }
3852
3853 pScanInfo->mScanPending = TRUE;
3854 pAdapter->request = request;
3855 pScanInfo->scanId = scanId;
3856
3857 complete(&pScanInfo->scan_req_completion_event);
3858
3859free_mem:
3860 if( scanRequest.SSIDs.SSIDList )
3861 {
3862 vos_mem_free(scanRequest.SSIDs.SSIDList);
3863 }
3864
3865 if( channelList )
3866 vos_mem_free( channelList );
3867
3868 EXIT();
3869
3870 return status;
3871}
3872
3873/*
3874 * FUNCTION: wlan_hdd_cfg80211_connect_start
3875 * This function is used to start the association process
3876 */
3877int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07003878 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07003879{
3880 int status = 0;
3881 hdd_wext_state_t *pWextState;
3882 v_U32_t roamId;
3883 tCsrRoamProfile *pRoamProfile;
3884 eMib_dot11DesiredBssType connectedBssType;
3885 eCsrAuthType RSNAuthType;
3886
3887 ENTER();
3888
3889 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3890
3891 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
3892 {
3893 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
3894 return -EINVAL;
3895 }
3896
3897 pRoamProfile = &pWextState->roamProfile;
3898
3899 if (pRoamProfile)
3900 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003901 int ret = 0;
3902 hdd_station_ctx_t *pHddStaCtx;
3903 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3904 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
3905
3906 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
3907 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
3908 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 {
3910 /* Issue disconnect to CSR */
3911 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3912 if( eHAL_STATUS_SUCCESS ==
3913 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
3914 pAdapter->sessionId,
3915 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
3916 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003917 ret = wait_for_completion_interruptible_timeout(
3918 &pAdapter->disconnect_comp_var,
3919 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3920 if (0 == ret)
3921 {
3922 VOS_ASSERT(0);
3923 }
3924 }
3925 }
3926 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
3927 {
3928 ret = wait_for_completion_interruptible_timeout(
3929 &pAdapter->disconnect_comp_var,
3930 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3931 if (0 == ret)
3932 {
3933 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 }
3935 }
3936
3937 if (HDD_WMM_USER_MODE_NO_QOS ==
3938 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
3939 {
3940 /*QoS not enabled in cfg file*/
3941 pRoamProfile->uapsd_mask = 0;
3942 }
3943 else
3944 {
3945 /*QoS enabled, update uapsd mask from cfg file*/
3946 pRoamProfile->uapsd_mask =
3947 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
3948 }
3949
3950 pRoamProfile->SSIDs.numOfSSIDs = 1;
3951 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
3952 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
3953 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
3954 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
3955 ssid, ssid_len);
3956
3957 if (bssid)
3958 {
3959 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
3960 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
3961 WNI_CFG_BSSID_LEN);
3962 /* Save BSSID in seperate variable as well, as RoamProfile
3963 BSSID is getting zeroed out in the association process. And in
3964 case of join failure we should send valid BSSID to supplicant
3965 */
3966 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
3967 WNI_CFG_BSSID_LEN);
3968 }
3969
3970 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
3971 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
3972 {
3973 /*set gen ie*/
3974 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3975 /*set auth*/
3976 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3977 }
3978 else if ( (pWextState->roamProfile.AuthType.authType[0] ==
3979 eCSR_AUTH_TYPE_OPEN_SYSTEM)
3980 && ((pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3981 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY)
3982 || (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3983 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
3984 )
3985 {
3986 /*Android UI not having any option to configure the Authentication type to OPEN/SHARED;
3987 * The authentication type will be always eCSR_AUTH_TYPE_OPEN_SYSTEM when WEP is used
3988 * Use eCSR_AUTH_TYPE_AUTOSWITCH when WEP encryption used*/
3989 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType =
3990 eCSR_AUTH_TYPE_AUTOSWITCH;
3991 pWextState->roamProfile.AuthType.authType[0] =
3992 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
3993 }
3994#ifdef FEATURE_WLAN_WAPI
3995 if (pAdapter->wapi_info.nWapiMode)
3996 {
3997 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __FUNCTION__);
3998 switch (pAdapter->wapi_info.wapiAuthMode)
3999 {
4000 case WAPI_AUTH_MODE_PSK:
4001 {
4002 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __FUNCTION__,
4003 pAdapter->wapi_info.wapiAuthMode);
4004 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4005 break;
4006 }
4007 case WAPI_AUTH_MODE_CERT:
4008 {
4009 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __FUNCTION__,
4010 pAdapter->wapi_info.wapiAuthMode);
4011 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4012 break;
4013 }
4014 } // End of switch
4015 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4016 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4017 {
4018 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __FUNCTION__);
4019 pRoamProfile->AuthType.numEntries = 1;
4020 pRoamProfile->EncryptionType.numEntries = 1;
4021 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4022 pRoamProfile->mcEncryptionType.numEntries = 1;
4023 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4024 }
4025 }
4026#endif /* FEATURE_WLAN_WAPI */
4027 pRoamProfile->csrPersona = pAdapter->device_mode;
4028
Jeff Johnson32d95a32012-09-10 13:15:23 -07004029 if( operatingChannel )
4030 {
4031 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
4032 pRoamProfile->ChannelInfo.numOfChannels = 1;
4033 }
4034
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
4036 pAdapter->sessionId, pRoamProfile, &roamId);
4037
Jeff Johnson32d95a32012-09-10 13:15:23 -07004038 pRoamProfile->ChannelInfo.ChannelList = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 pRoamProfile->ChannelInfo.numOfChannels = 0;
4040 }
4041 else
4042 {
4043 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
4044 return -EINVAL;
4045 }
4046 EXIT();
4047 return status;
4048}
4049
4050/*
4051 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
4052 * This function is used to set the authentication type (OPEN/SHARED).
4053 *
4054 */
4055static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
4056 enum nl80211_auth_type auth_type)
4057{
4058 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4059 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4060
4061 ENTER();
4062
4063 /*set authentication type*/
4064 switch (auth_type)
4065 {
4066 case NL80211_AUTHTYPE_OPEN_SYSTEM:
4067 case NL80211_AUTHTYPE_AUTOMATIC:
4068 hddLog(VOS_TRACE_LEVEL_INFO,
4069 "%s: set authentication type to OPEN", __func__);
4070 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4071 break;
4072
4073 case NL80211_AUTHTYPE_SHARED_KEY:
4074 hddLog(VOS_TRACE_LEVEL_INFO,
4075 "%s: set authentication type to SHARED", __func__);
4076 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4077 break;
4078#ifdef FEATURE_WLAN_CCX
4079 case NL80211_AUTHTYPE_NETWORK_EAP:
4080 hddLog(VOS_TRACE_LEVEL_INFO,
4081 "%s: set authentication type to CCKM WPA", __func__);
4082 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
4083 break;
4084#endif
4085
4086
4087 default:
4088 hddLog(VOS_TRACE_LEVEL_ERROR,
4089 "%s: Unsupported authentication type %d", __func__,
4090 auth_type);
4091 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
4092 return -EINVAL;
4093 }
4094
4095 pWextState->roamProfile.AuthType.authType[0] =
4096 pHddStaCtx->conn_info.authType;
4097 return 0;
4098}
4099
4100/*
4101 * FUNCTION: wlan_hdd_set_akm_suite
4102 * This function is used to set the key mgmt type(PSK/8021x).
4103 *
4104 */
4105static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
4106 u32 key_mgmt
4107 )
4108{
4109 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4110 ENTER();
4111
4112 /*set key mgmt type*/
4113 switch(key_mgmt)
4114 {
4115 case WLAN_AKM_SUITE_PSK:
4116 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
4117 __func__);
4118 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4119 break;
4120
4121 case WLAN_AKM_SUITE_8021X:
4122 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
4123 __func__);
4124 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4125 break;
4126#ifdef FEATURE_WLAN_CCX
4127#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
4128#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4129 case WLAN_AKM_SUITE_CCKM:
4130 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
4131 __func__);
4132 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4133 break;
4134#endif
4135
4136 default:
4137 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
4138 __func__, key_mgmt);
4139 return -EINVAL;
4140
4141 }
4142 return 0;
4143}
4144
4145/*
4146 * FUNCTION: wlan_hdd_cfg80211_set_cipher
4147 * This function is used to set the encryption type
4148 * (NONE/WEP40/WEP104/TKIP/CCMP).
4149 */
4150static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
4151 u32 cipher,
4152 bool ucast
4153 )
4154{
4155 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4156 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4157 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4158
4159 ENTER();
4160
4161 if (!cipher)
4162 {
4163 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
4164 __func__, cipher);
4165 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4166 }
4167 else
4168 {
4169
4170 /*set encryption method*/
4171 switch (cipher)
4172 {
4173 case IW_AUTH_CIPHER_NONE:
4174 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4175 break;
4176
4177 case WLAN_CIPHER_SUITE_WEP40:
4178 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) &&
4179 (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4180 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
4181 else
4182 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4183 break;
4184
4185 case WLAN_CIPHER_SUITE_WEP104:
4186 if ((IW_AUTH_KEY_MGMT_802_1X == pWextState->authKeyMgmt) &&
4187 (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4188 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4189 else
4190 encryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4191 break;
4192
4193 case WLAN_CIPHER_SUITE_TKIP:
4194 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4195 break;
4196
4197 case WLAN_CIPHER_SUITE_CCMP:
4198 encryptionType = eCSR_ENCRYPT_TYPE_AES;
4199 break;
4200#ifdef FEATURE_WLAN_WAPI
4201 case WLAN_CIPHER_SUITE_SMS4:
4202 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
4203 break;
4204#endif
4205
4206#ifdef FEATURE_WLAN_CCX
4207 case WLAN_CIPHER_SUITE_KRK:
4208 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
4209 break;
4210#endif
4211 default:
4212 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
4213 __func__, cipher);
4214 return -EOPNOTSUPP;
4215 }
4216 }
4217
4218 if (ucast)
4219 {
4220 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
4221 __func__, encryptionType);
4222 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4223 pWextState->roamProfile.EncryptionType.numEntries = 1;
4224 pWextState->roamProfile.EncryptionType.encryptionType[0] =
4225 encryptionType;
4226 }
4227 else
4228 {
4229 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
4230 __func__, encryptionType);
4231 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
4232 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4233 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
4234 }
4235
4236 return 0;
4237}
4238
4239
4240/*
4241 * FUNCTION: wlan_hdd_cfg80211_set_ie
4242 * This function is used to parse WPA/RSN IE's.
4243 */
4244int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
4245 u8 *ie,
4246 size_t ie_len
4247 )
4248{
4249 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4250 u8 *genie = ie;
4251 v_U16_t remLen = ie_len;
4252#ifdef FEATURE_WLAN_WAPI
4253 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
4254 u16 *tmp;
4255 v_U16_t akmsuiteCount;
4256 int *akmlist;
4257#endif
4258 ENTER();
4259
4260 /* clear previous assocAddIE */
4261 pWextState->assocAddIE.length = 0;
4262 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
4263
4264 while (remLen >= 2)
4265 {
4266 v_U16_t eLen = 0;
4267 v_U8_t elementId;
4268 elementId = *genie++;
4269 eLen = *genie++;
4270 remLen -= 2;
4271
4272 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
4273 __func__, elementId, eLen);
4274
4275 switch ( elementId )
4276 {
4277 case DOT11F_EID_WPA:
4278 if ((2+4) > eLen) /* should have at least OUI */
4279 {
4280 hddLog(VOS_TRACE_LEVEL_ERROR,
4281 "%s: Invalid WPA IE", __func__);
4282 return -EINVAL;
4283 }
4284 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
4285 {
4286 v_U16_t curAddIELen = pWextState->assocAddIE.length;
4287 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
4288 __func__, eLen + 2);
4289
4290 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
4291 {
4292 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accomadate assocAddIE. "
4293 "Need bigger buffer space\n");
4294 VOS_ASSERT(0);
4295 return -ENOMEM;
4296 }
4297 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
4298 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
4299 pWextState->assocAddIE.length += eLen + 2;
4300
4301 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
4302 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4303 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4304 }
4305 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
4306 {
4307 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
4308 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
4309 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
4310 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
4311 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
4312 }
4313#ifdef WLAN_FEATURE_P2P
4314 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
4315 P2P_OUI_TYPE_SIZE))
4316 /*Consider P2P IE, only for P2P Client */
4317 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
4318 {
4319 v_U16_t curAddIELen = pWextState->assocAddIE.length;
4320 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
4321 __func__, eLen + 2);
4322
4323 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
4324 {
4325 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accomadate assocAddIE "
4326 "Need bigger buffer space\n");
4327 VOS_ASSERT(0);
4328 return -ENOMEM;
4329 }
4330 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
4331 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
4332 pWextState->assocAddIE.length += eLen + 2;
4333
4334 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4335 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4336 }
4337#endif
4338#ifdef WLAN_FEATURE_WFD
4339 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
4340 WFD_OUI_TYPE_SIZE))
4341 /*Consider WFD IE, only for P2P Client */
4342 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
4343 {
4344 v_U16_t curAddIELen = pWextState->assocAddIE.length;
4345 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
4346 __func__, eLen + 2);
4347
4348 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
4349 {
4350 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accomadate assocAddIE "
4351 "Need bigger buffer space\n");
4352 VOS_ASSERT(0);
4353 return -ENOMEM;
4354 }
4355 // WFD IE is saved to Additional IE ; it should be accumulated to handle
4356 // WPS IE + P2P IE + WFD IE
4357 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
4358 pWextState->assocAddIE.length += eLen + 2;
4359
4360 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4361 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4362 }
4363#endif
4364 break;
4365 case DOT11F_EID_RSN:
4366 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
4367 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
4368 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
4369 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
4370 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
4371 break;
4372#ifdef FEATURE_WLAN_WAPI
4373 case WLAN_EID_WAPI:
4374 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
4375 hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n",
4376 pAdapter->wapi_info.nWapiMode);
4377 tmp = (u16 *)ie;
4378 tmp = tmp + 2; // Skip element Id and Len, Version
4379 akmsuiteCount = WPA_GET_LE16(tmp);
4380 tmp = tmp + 1;
4381 akmlist = (int *)(tmp);
4382 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
4383 {
4384 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
4385 }
4386 else
4387 {
4388 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
4389 VOS_ASSERT(0);
4390 return -EINVAL;
4391 }
4392
4393 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
4394 {
4395 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
4396 __FUNCTION__);
4397 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
4398 }
4399 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
4400 {
4401 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
4402 __FUNCTION__);
4403 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
4404 }
4405 break;
4406#endif
4407 default:
4408 hddLog (VOS_TRACE_LEVEL_ERROR,
4409 "%s Set UNKNOWN IE %X", __func__, elementId);
4410 return 0;
4411 }
4412 genie += eLen;
4413 remLen -= eLen;
4414 }
4415 EXIT();
4416 return 0;
4417}
4418
4419/*
4420 * FUNCTION: wlan_hdd_cfg80211_set_privacy
4421 * This function is used to initialize the security
4422 * parameters during connect operation.
4423 */
4424int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
4425 struct cfg80211_connect_params *req
4426 )
4427{
4428 int status = 0;
4429 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4430 ENTER();
4431
4432 /*set wpa version*/
4433 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4434
4435 if (req->crypto.wpa_versions)
4436 {
4437 if ( (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
4438 && ( (req->ie_len)
4439 && (0 == memcmp( &req->ie[2], "\x00\x50\xf2",3) ) ) )
4440 // Make sure that it is including a WPA IE.
4441 /* Currently NL is putting WPA version 1 even for open,
4442 * since p2p ie is also put in same buffer.
4443 * */
4444 {
4445 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
4446 }
4447 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
4448 {
4449 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
4450 }
4451 }
4452
4453 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
4454 pWextState->wpaVersion);
4455
4456 /*set authentication type*/
4457 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
4458
4459 if (0 > status)
4460 {
4461 hddLog(VOS_TRACE_LEVEL_ERROR,
4462 "%s: failed to set authentication type ", __func__);
4463 return status;
4464 }
4465
4466 /*set key mgmt type*/
4467 if (req->crypto.n_akm_suites)
4468 {
4469 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
4470 if (0 > status)
4471 {
4472 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
4473 __func__);
4474 return status;
4475 }
4476 }
4477
4478 /*set pairwise cipher type*/
4479 if (req->crypto.n_ciphers_pairwise)
4480 {
4481 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
4482 req->crypto.ciphers_pairwise[0], true);
4483 if (0 > status)
4484 {
4485 hddLog(VOS_TRACE_LEVEL_ERROR,
4486 "%s: failed to set unicast cipher type", __func__);
4487 return status;
4488 }
4489 }
4490 else
4491 {
4492 /*Reset previous cipher suite to none*/
4493 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
4494 if (0 > status)
4495 {
4496 hddLog(VOS_TRACE_LEVEL_ERROR,
4497 "%s: failed to set unicast cipher type", __func__);
4498 return status;
4499 }
4500 }
4501
4502 /*set group cipher type*/
4503 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
4504 false);
4505
4506 if (0 > status)
4507 {
4508 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
4509 __func__);
4510 return status;
4511 }
4512
4513 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
4514 if (req->ie_len)
4515 {
4516 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
4517 if ( 0 > status)
4518 {
4519 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
4520 __func__);
4521 return status;
4522 }
4523 }
4524
4525 /*incase of WEP set default key information*/
4526 if (req->key && req->key_len)
4527 {
4528 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
4529 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
4530 )
4531 {
4532 if ( IW_AUTH_KEY_MGMT_802_1X
4533 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4534 {
4535 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
4536 __func__);
4537 return -EOPNOTSUPP;
4538 }
4539 else
4540 {
4541 u8 key_len = req->key_len;
4542 u8 key_idx = req->key_idx;
4543
4544 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
4545 && (CSR_MAX_NUM_KEY > key_idx)
4546 )
4547 {
4548 hddLog(VOS_TRACE_LEVEL_INFO,
4549 "%s: setting default wep key, key_idx = %hu key_len %hu",
4550 __func__, key_idx, key_len);
4551 vos_mem_copy(
4552 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
4553 req->key, key_len);
4554 pWextState->roamProfile.Keys.KeyLength[key_idx] =
4555 (u8)key_len;
4556 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
4557 }
4558 }
4559 }
4560 }
4561
4562 return status;
4563}
4564
4565/*
4566 * FUNCTION: wlan_hdd_cfg80211_set_privacy
4567 * This function is used to initialize the security
4568 * parameters during connect operation.
4569 */
4570static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
4571 struct net_device *ndev,
4572 struct cfg80211_connect_params *req
4573 )
4574{
4575 int status = 0;
4576 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
4577 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
4578 hdd_context_t *pHddCtx = NULL;
4579
4580 ENTER();
4581
4582 hddLog(VOS_TRACE_LEVEL_INFO,
4583 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
4584
4585 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
4586 {
4587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4588 "%s:LOGP in Progress. Ignore!!!", __func__);
4589 return -EAGAIN;
4590 }
4591
4592#ifdef WLAN_BTAMP_FEATURE
4593 //Infra connect not supported when AMP traffic is on.
4594 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
4595 {
4596 hddLog(VOS_TRACE_LEVEL_ERROR,
4597 "%s: No connection when AMP is on", __func__);
4598 return -1;
4599 }
4600#endif
4601 /*initialise security parameters*/
4602 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
4603
4604 if ( 0 > status)
4605 {
4606 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
4607 __func__);
4608 return status;
4609 }
4610
4611 //If Device Mode is Station Concurrent Sessions Exit BMps
4612 //P2P Mode will be taken care in Open/close adaptor
4613 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
4614 (vos_concurrent_sessions_running()))
4615 {
4616 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
4617
4618 if (NULL != pVosContext)
4619 {
4620 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
4621 if(NULL != pHddCtx)
4622 {
4623 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
4624 }
4625 }
4626 }
4627
Mohit Khanna765234a2012-09-11 15:08:35 -07004628 if ( req->channel )
4629 {
4630 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
4631 req->ssid_len, req->bssid,
4632 req->channel->hw_value);
4633 }
4634 else
4635 {
4636 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
4637 req->ssid_len, req->bssid,
4638 0);
4639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004640
4641 if (0 > status)
4642 {
4643 //ReEnable BMPS if disabled
4644 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
4645 (NULL != pHddCtx))
4646 {
4647 //ReEnable Bmps and Imps back
4648 hdd_enable_bmps_imps(pHddCtx);
4649 }
4650
4651 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
4652 return status;
4653 }
4654 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
4655 EXIT();
4656 return status;
4657}
4658
4659
4660/*
4661 * FUNCTION: wlan_hdd_cfg80211_disconnect
4662 * This function is used to issue a disconnect request to SME
4663 */
4664static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
4665 struct net_device *dev,
4666 u16 reason
4667 )
4668{
4669 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
4670 tCsrRoamProfile *pRoamProfile =
4671 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
4672 int status = 0;
4673 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4674
4675 ENTER();
4676
4677 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4678 __func__,pAdapter->device_mode);
4679
4680 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
4681 __func__, reason);
4682
4683 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4684 {
4685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4686 "%s:LOGP in Progress. Ignore!!!",__func__);
4687 return -EAGAIN;
4688 }
4689 if (NULL != pRoamProfile)
4690 {
4691 /*issue disconnect request to SME, if station is in connected state*/
4692 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
4693 {
4694 eCsrRoamDisconnectReason reasonCode =
4695 eCSR_DISCONNECT_REASON_UNSPECIFIED;
4696 switch(reason)
4697 {
4698 case WLAN_REASON_MIC_FAILURE:
4699 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
4700 break;
4701
4702 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
4703 case WLAN_REASON_DISASSOC_AP_BUSY:
4704 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
4705 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
4706 break;
4707
4708 case WLAN_REASON_PREV_AUTH_NOT_VALID:
4709 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
4710 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
4711 break;
4712
4713 case WLAN_REASON_DEAUTH_LEAVING:
4714 default:
4715 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
4716 break;
4717 }
4718 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
4719 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_TRUE;
4720 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4721
4722 /*issue disconnect*/
4723 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
4724 pAdapter->sessionId, reasonCode);
4725
4726 if ( 0 != status)
4727 {
4728 hddLog(VOS_TRACE_LEVEL_ERROR,
4729 "%s csrRoamDisconnect failure, returned %d \n",
4730 __func__, (int)status );
4731 return -EINVAL;
4732 }
4733
4734 wait_for_completion_interruptible_timeout(
4735 &pAdapter->disconnect_comp_var,
4736 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4737
4738
4739 /*stop tx queues*/
4740 netif_tx_disable(dev);
4741 netif_carrier_off(dev);
4742 }
4743 }
4744 else
4745 {
4746 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
4747 }
4748
4749 return status;
4750}
4751
4752/*
4753 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
4754 * This function is used to initialize the security
4755 * settings in IBSS mode.
4756 */
4757static int wlan_hdd_cfg80211_set_privacy_ibss(
4758 hdd_adapter_t *pAdapter,
4759 struct cfg80211_ibss_params *params
4760 )
4761{
4762 int status = 0;
4763 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4764 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
4765 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4766
4767 ENTER();
4768
4769 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
4770
4771 if (params->ie_len && ( NULL != params->ie) )
4772 {
4773 if (WLAN_EID_RSN == params->ie[0])
4774 {
4775 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
4776 encryptionType = eCSR_ENCRYPT_TYPE_AES;
4777 }
4778 else
4779 {
4780 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
4781 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4782 }
4783 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
4784
4785 if (0 > status)
4786 {
4787 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
4788 __func__);
4789 return status;
4790 }
4791 }
4792
4793 pWextState->roamProfile.AuthType.authType[0] =
4794 pHddStaCtx->conn_info.authType =
4795 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4796
4797 if (params->privacy)
4798 {
4799 /* Security enabled IBSS, At this time there is no information available
4800 * about the security paramters, so initialise the encryption type to
4801 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
4802 * The correct security parameters will be updated later in
4803 * wlan_hdd_cfg80211_add_key */
4804 /* Hal expects encryption type to be set inorder
4805 *enable privacy bit in beacons */
4806
4807 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4808 }
4809
4810 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
4811 pWextState->roamProfile.EncryptionType.numEntries = 1;
4812 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
4813
4814 return status;
4815}
4816
4817/*
4818 * FUNCTION: wlan_hdd_cfg80211_join_ibss
4819 * This function is used to create/join an IBSS
4820 */
4821static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
4822 struct net_device *dev,
4823 struct cfg80211_ibss_params *params
4824 )
4825{
4826 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
4827 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4828 tCsrRoamProfile *pRoamProfile;
4829 int status;
4830 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4831
4832 ENTER();
4833
4834 hddLog(VOS_TRACE_LEVEL_INFO,
4835 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
4836
4837 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
4838 {
4839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4840 "%s:LOGP in Progress. Ignore!!!", __func__);
4841 return -EAGAIN;
4842 }
4843
4844 if (NULL == pWextState)
4845 {
4846 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
4847 __func__);
4848 return -EIO;
4849 }
4850
4851 pRoamProfile = &pWextState->roamProfile;
4852
4853 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
4854 {
4855 hddLog (VOS_TRACE_LEVEL_ERROR,
4856 "%s Interface type is not set to IBSS \n", __func__);
4857 return -EINVAL;
4858 }
4859
4860 /* Set Channel */
4861 if (NULL != params->channel)
4862 {
4863 u8 channelNum;
4864 if (IEEE80211_BAND_5GHZ == params->channel->band)
4865 {
4866 hddLog(VOS_TRACE_LEVEL_ERROR,
4867 "%s: IBSS join is called with unsupported band %d",
4868 __func__, params->channel->band);
4869 return -EOPNOTSUPP;
4870 }
4871
4872 /* Get channel number */
4873 channelNum =
4874 ieee80211_frequency_to_channel(params->channel->center_freq);
4875
4876 /*TODO: use macro*/
4877 if (14 >= channelNum)
4878 {
4879 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4880 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
4881 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4882 int indx;
4883
4884 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
4885 validChan, &numChans))
4886 {
4887 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
4888 __func__);
4889 return -EOPNOTSUPP;
4890 }
4891
4892 for (indx = 0; indx < numChans; indx++)
4893 {
4894 if (channelNum == validChan[indx])
4895 {
4896 break;
4897 }
4898 }
4899 if (indx >= numChans)
4900 {
4901 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
4902 __func__, channelNum);
4903 return -EINVAL;
4904 }
4905 /* Set the Operational Channel */
4906 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
4907 channelNum);
4908 pRoamProfile->ChannelInfo.numOfChannels = 1;
4909 pHddStaCtx->conn_info.operationChannel = channelNum;
4910 pRoamProfile->ChannelInfo.ChannelList =
4911 &pHddStaCtx->conn_info.operationChannel;
4912 }
4913 else
4914 {
4915 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %hu",
4916 __func__, channelNum);
4917 return -EINVAL;
4918 }
4919 }
4920
4921 /* Initialize security parameters */
4922 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
4923 if (status < 0)
4924 {
4925 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
4926 __func__);
4927 return status;
4928 }
4929
4930 /* Issue connect start */
4931 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004932 params->ssid_len, params->bssid, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004933
4934 if (0 > status)
4935 {
4936 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
4937 return status;
4938 }
4939
4940 return 0;
4941}
4942
4943/*
4944 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
4945 * This function is used to leave an IBSS
4946 */
4947static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
4948 struct net_device *dev
4949 )
4950{
4951 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
4952 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4953 tCsrRoamProfile *pRoamProfile;
4954
4955 ENTER();
4956
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004957 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
4958 {
4959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4960 "%s:LOGP in Progress. Ignore!!!", __func__);
4961 return -EAGAIN;
4962 }
4963
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
4965 if (NULL == pWextState)
4966 {
4967 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
4968 __func__);
4969 return -EIO;
4970 }
4971
4972 pRoamProfile = &pWextState->roamProfile;
4973
4974 /* Issue disconnect only if interface type is set to IBSS */
4975 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
4976 {
4977 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
4978 __func__);
4979 return -EINVAL;
4980 }
4981
4982 /* Issue Disconnect request */
4983 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4984 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
4985 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
4986
4987 return 0;
4988}
4989
4990/*
4991 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
4992 * This function is used to set the phy parameters
4993 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
4994 */
4995static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
4996 u32 changed)
4997{
4998 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4999 tHalHandle hHal = pHddCtx->hHal;
5000
5001 ENTER();
5002
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005003 if ( pHddCtx->isLogpInProgress )
5004 {
5005 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5006 "%s:LOGP in Progress. Ignore!!!", __func__);
5007 return -EAGAIN;
5008 }
5009
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
5011 {
5012 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
5013 WNI_CFG_RTS_THRESHOLD_STAMAX :
5014 wiphy->rts_threshold;
5015
5016 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
5017 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
5018 {
5019 hddLog(VOS_TRACE_LEVEL_ERROR,
5020 "%s: Invalid RTS Threshold value %hu",
5021 __func__, rts_threshold);
5022 return -EINVAL;
5023 }
5024
5025 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
5026 rts_threshold, ccmCfgSetCallback,
5027 eANI_BOOLEAN_TRUE))
5028 {
5029 hddLog(VOS_TRACE_LEVEL_ERROR,
5030 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
5031 __func__, rts_threshold);
5032 return -EIO;
5033 }
5034
5035 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
5036 rts_threshold);
5037 }
5038
5039 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
5040 {
5041 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
5042 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
5043 wiphy->frag_threshold;
5044
5045 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
5046 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
5047 {
5048 hddLog(VOS_TRACE_LEVEL_ERROR,
5049 "%s: Invalid frag_threshold value %hu", __func__,
5050 frag_threshold);
5051 return -EINVAL;
5052 }
5053
5054 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
5055 frag_threshold, ccmCfgSetCallback,
5056 eANI_BOOLEAN_TRUE))
5057 {
5058 hddLog(VOS_TRACE_LEVEL_ERROR,
5059 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
5060 __func__, frag_threshold);
5061 return -EIO;
5062 }
5063
5064 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
5065 frag_threshold);
5066 }
5067
5068 if ((changed & WIPHY_PARAM_RETRY_SHORT)
5069 || (changed & WIPHY_PARAM_RETRY_LONG))
5070 {
5071 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
5072 wiphy->retry_short :
5073 wiphy->retry_long;
5074
5075 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
5076 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
5077 {
5078 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
5079 __func__, retry_value);
5080 return -EINVAL;
5081 }
5082
5083 if (changed & WIPHY_PARAM_RETRY_SHORT)
5084 {
5085 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
5086 retry_value, ccmCfgSetCallback,
5087 eANI_BOOLEAN_TRUE))
5088 {
5089 hddLog(VOS_TRACE_LEVEL_ERROR,
5090 "%s: ccmCfgSetInt failed for long retry count %hu",
5091 __func__, retry_value);
5092 return -EIO;
5093 }
5094 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
5095 __func__, retry_value);
5096 }
5097 else if (changed & WIPHY_PARAM_RETRY_SHORT)
5098 {
5099 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
5100 retry_value, ccmCfgSetCallback,
5101 eANI_BOOLEAN_TRUE))
5102 {
5103 hddLog(VOS_TRACE_LEVEL_ERROR,
5104 "%s: ccmCfgSetInt failed for short retry count %hu",
5105 __func__, retry_value);
5106 return -EIO;
5107 }
5108 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
5109 __func__, retry_value);
5110 }
5111 }
5112
5113 return 0;
5114}
5115
5116/*
5117 * FUNCTION: wlan_hdd_cfg80211_set_txpower
5118 * This function is used to set the txpower
5119 */
5120static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
5121#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
5122 enum tx_power_setting type,
5123#else
5124 enum nl80211_tx_power_setting type,
5125#endif
5126 int dbm)
5127{
5128 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
5129 tHalHandle hHal = pHddCtx->hHal;
5130 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5131 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
5132
5133 ENTER();
5134
5135 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
5136 dbm, ccmCfgSetCallback,
5137 eANI_BOOLEAN_TRUE))
5138 {
5139 hddLog(VOS_TRACE_LEVEL_ERROR,
5140 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
5141 return -EIO;
5142 }
5143
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005144 if ( pHddCtx->isLogpInProgress )
5145 {
5146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5147 "%s:LOGP in Progress. Ignore!!!", __func__);
5148 return -EAGAIN;
5149 }
5150
Jeff Johnson295189b2012-06-20 16:38:30 -07005151 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
5152 dbm);
5153
5154 switch(type)
5155 {
5156 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
5157 /* Fall through */
5158 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
5159 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
5160 {
5161 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
5162 __func__);
5163 return -EIO;
5164 }
5165 break;
5166 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
5167 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
5168 __func__);
5169 return -EOPNOTSUPP;
5170 break;
5171 default:
5172 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
5173 __func__, type);
5174 return -EIO;
5175 }
5176
5177 return 0;
5178}
5179
5180/*
5181 * FUNCTION: wlan_hdd_cfg80211_get_txpower
5182 * This function is used to read the txpower
5183 */
5184static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm)
5185{
5186
5187 hdd_adapter_t *pAdapter;
5188 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
5189
Jeff Johnsone7245742012-09-05 17:12:55 -07005190 ENTER();
5191
Jeff Johnson295189b2012-06-20 16:38:30 -07005192 if (NULL == pHddCtx)
5193 {
5194 hddLog(VOS_TRACE_LEVEL_FATAL,"%s: HDD context is Null",__func__);
5195 *dbm = 0;
5196 return -ENOENT;
5197 }
5198
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005199 if ( pHddCtx->isLogpInProgress )
5200 {
5201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5202 "%s:LOGP in Progress. Ignore!!!", __func__);
5203 return -EAGAIN;
5204 }
5205
Jeff Johnson295189b2012-06-20 16:38:30 -07005206 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
5207 if (NULL == pAdapter)
5208 {
5209 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
5210 return -ENOENT;
5211 }
5212
5213 wlan_hdd_get_classAstats(pAdapter);
5214 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
5215
Jeff Johnsone7245742012-09-05 17:12:55 -07005216 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005217 return 0;
5218}
5219
5220static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
5221 u8* mac, struct station_info *sinfo)
5222{
5223 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
5224 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5225 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
5226 tANI_U8 rate_flags;
5227
5228 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
5229 hdd_config_t *pCfg = pHddCtx->cfg_ini;
5230 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5231
5232 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
5233 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
5234 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
5235 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
5236 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
5237 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
5238 tANI_U16 maxRate = 0;
5239 tANI_U16 myRate;
5240 tANI_U16 currentRate = 0;
5241 tANI_U8 maxSpeedMCS = 0;
5242 tANI_U8 maxMCSIdx = 0;
5243 tANI_U8 rateFlag = 1;
5244 tANI_U8 i, j, rssidx;
5245
Jeff Johnsone7245742012-09-05 17:12:55 -07005246 ENTER();
5247
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
5249 (0 == ssidlen))
5250 {
5251 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
5252 " Invalid ssidlen, %d", __func__, ssidlen);
5253 /*To keep GUI happy*/
5254 return 0;
5255 }
5256
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005257 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
5258 {
5259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5260 "%s:LOGP in Progress. Ignore!!!", __func__);
5261 return -EAGAIN;
5262 }
5263
Jeff Johnson295189b2012-06-20 16:38:30 -07005264 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
5265 sinfo->filled |= STATION_INFO_SIGNAL;
5266
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07005267 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
5269
5270 //convert to the UI units of 100kbps
5271 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
5272
5273#ifdef LINKSPEED_DEBUG_ENABLED
5274 pr_info("RSSI %d, RLMS %u, rate %d, rssi high %d, rssi low %d\n",
5275 sinfo->signal,
5276 pCfg->reportMaxLinkSpeed,
5277 myRate,
5278 (int) pCfg->linkSpeedRssiHigh,
5279 (int) pCfg->linkSpeedRssiLow);
5280#endif //LINKSPEED_DEBUG_ENABLED
5281
5282 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
5283 {
5284 // we do not want to necessarily report the current speed
5285 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
5286 {
5287 // report the max possible speed
5288 rssidx = 0;
5289 }
5290 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
5291 {
5292 // report the max possible speed with RSSI scaling
5293 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
5294 {
5295 // report the max possible speed
5296 rssidx = 0;
5297 }
5298 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
5299 {
5300 // report middle speed
5301 rssidx = 1;
5302 }
5303 else
5304 {
5305 // report actual speed
5306 rssidx = 2;
5307 }
5308 }
5309 else
5310 {
5311 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
5312 hddLog(VOS_TRACE_LEVEL_ERROR,
5313 "%s: Invalid value for reportMaxLinkSpeed: %u",
5314 __func__, pCfg->reportMaxLinkSpeed);
5315 rssidx = 0;
5316 }
5317
5318 maxRate = 0;
5319
5320 /* Get Basic Rate Set */
5321 ccmCfgGetStr(hHal, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates, &ORLeng);
5322 for (i = 0; i < ORLeng; i++)
5323 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005324 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 {
5326 /* Validate Rate Set */
5327 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
5328 {
5329 currentRate = supported_data_rate[j].supported_rate[rssidx];
5330 break;
5331 }
5332 }
5333 /* Update MAX rate */
5334 maxRate = (currentRate > maxRate)?currentRate:maxRate;
5335 }
5336
5337 /* Get Extended Rate Set */
5338 ccmCfgGetStr(hHal, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedRates, &ERLeng);
5339 for (i = 0; i < ERLeng; i++)
5340 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005341 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005342 {
5343 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
5344 {
5345 currentRate = supported_data_rate[j].supported_rate[rssidx];
5346 break;
5347 }
5348 }
5349 /* Update MAX rate */
5350 maxRate = (currentRate > maxRate)?currentRate:maxRate;
5351 }
5352
5353 /* Get MCS Rate Set -- but only if we are connected at MCS
5354 rates or if we are always reporting max speed or if we have
5355 good rssi */
5356 if ((0 == rssidx) || !(rate_flags & eHAL_TX_RATE_LEGACY))
5357 {
5358 ccmCfgGetStr(hHal, WNI_CFG_CURRENT_MCS_SET, MCSRates, &MCSLeng);
5359 rateFlag = 0;
5360 if (rate_flags & eHAL_TX_RATE_HT40)
5361 {
5362 rateFlag |= 1;
5363 }
5364 if (rate_flags & eHAL_TX_RATE_SGI)
5365 {
5366 rateFlag |= 2;
5367 }
5368
5369 for (i = 0; i < MCSLeng; i++)
5370 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005371 for (j = 0; j < (sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0])); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 {
5373 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
5374 {
5375 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
5376 break;
5377 }
5378 }
5379 if (currentRate > maxRate)
5380 {
5381 maxRate = currentRate;
5382 maxSpeedMCS = 1;
5383 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
5384 }
5385 }
5386 }
5387
5388 // make sure we report a value at least as big as our current rate
5389 if (maxRate < myRate)
5390 {
5391 maxRate = myRate;
5392 if (rate_flags & eHAL_TX_RATE_LEGACY)
5393 {
5394 maxSpeedMCS = 0;
5395 }
5396 else
5397 {
5398 maxSpeedMCS = 1;
5399 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
5400 }
5401 }
5402
5403 if (!maxSpeedMCS)
5404 {
5405 sinfo->txrate.legacy = maxRate;
5406#ifdef LINKSPEED_DEBUG_ENABLED
5407 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
5408#endif //LINKSPEED_DEBUG_ENABLED
5409 }
5410 else
5411 {
5412 sinfo->txrate.mcs = maxMCSIdx;
5413 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
5414 if (rate_flags & eHAL_TX_RATE_SGI)
5415 {
5416 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
5417 }
5418 if (rate_flags & eHAL_TX_RATE_HT40)
5419 {
5420 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
5421 }
5422#ifdef LINKSPEED_DEBUG_ENABLED
5423 pr_info("Reporting MCS rate %d flags %x\n",
5424 sinfo->txrate.mcs,
5425 sinfo->txrate.flags );
5426#endif //LINKSPEED_DEBUG_ENABLED
5427 }
5428 }
5429 else
5430 {
5431 // report current rate instead of max rate
5432
5433 if (rate_flags & eHAL_TX_RATE_LEGACY)
5434 {
5435 //provide to the UI in units of 100kbps
5436 sinfo->txrate.legacy = myRate;
5437#ifdef LINKSPEED_DEBUG_ENABLED
5438 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
5439#endif //LINKSPEED_DEBUG_ENABLED
5440 }
5441 else
5442 {
5443 //must be MCS
5444 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
5445 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
5446 if (rate_flags & eHAL_TX_RATE_SGI)
5447 {
5448 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
5449 }
5450 if (rate_flags & eHAL_TX_RATE_HT40)
5451 {
5452 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
5453 }
5454#ifdef LINKSPEED_DEBUG_ENABLED
5455 pr_info("Reporting actual MCS rate %d flags %x\n",
5456 sinfo->txrate.mcs,
5457 sinfo->txrate.flags );
5458#endif //LINKSPEED_DEBUG_ENABLED
5459 }
5460 }
5461 sinfo->filled |= STATION_INFO_TX_BITRATE;
5462
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07005463 sinfo->tx_packets =
5464 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
5465 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
5466 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
5467 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
5468
5469 sinfo->tx_retries =
5470 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
5471 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
5472 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
5473 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
5474
5475 sinfo->tx_failed =
5476 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
5477 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
5478 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
5479 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
5480
5481 sinfo->filled |=
5482 STATION_INFO_TX_PACKETS |
5483 STATION_INFO_TX_RETRIES |
5484 STATION_INFO_TX_FAILED;
5485
5486 EXIT();
5487 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005488}
5489
5490static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
5491 struct net_device *dev, bool mode, v_SINT_t timeout)
5492{
5493 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5494 VOS_STATUS vos_status;
5495
Jeff Johnsone7245742012-09-05 17:12:55 -07005496 ENTER();
5497
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 if (NULL == pAdapter)
5499 {
5500 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
5501 return -ENODEV;
5502 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005503 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
5504 {
5505 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5506 "%s:LOGP in Progress. Ignore!!!", __func__);
5507 return -EAGAIN;
5508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005509
5510 /**The get power cmd from the supplicant gets updated by the nl only
5511 *on successful execution of the function call
5512 *we are oppositely mapped w.r.t mode in the driver
5513 **/
5514 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
5515
Jeff Johnsone7245742012-09-05 17:12:55 -07005516 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005517 if (VOS_STATUS_E_FAILURE == vos_status)
5518 {
5519 return -EINVAL;
5520 }
5521 return 0;
5522}
5523
5524
5525#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5526static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
5527 struct net_device *netdev,
5528 u8 key_index)
5529{
Jeff Johnsone7245742012-09-05 17:12:55 -07005530 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 return 0;
5532}
5533#endif //LINUX_VERSION_CODE
5534
5535#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5536static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
5537 struct net_device *dev,
5538 struct ieee80211_txq_params *params)
5539{
Jeff Johnsone7245742012-09-05 17:12:55 -07005540 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07005541 return 0;
5542}
5543#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5544static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
5545 struct ieee80211_txq_params *params)
5546{
Jeff Johnsone7245742012-09-05 17:12:55 -07005547 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 return 0;
5549}
5550#endif //LINUX_VERSION_CODE
5551
5552static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
5553 struct net_device *dev, u8 *mac)
5554{
5555 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5556
Jeff Johnsone7245742012-09-05 17:12:55 -07005557 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 if ( NULL == pAdapter || NULL == pAdapter->pHddCtx)
5559 {
5560 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid Adapter or HDD Context " ,__func__);
5561 return -EINVAL;
5562 }
5563
5564 if (((hdd_context_t*)pAdapter->pHddCtx)->isLoadUnloadInProgress)
5565 {
5566 hddLog( LOGE,
5567 "%s: Wlan Load/Unload is in progress", __func__);
5568 return -EBUSY;
5569 }
5570
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005571 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
5572 {
5573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5574 "%s:LOGP in Progress. Ignore!!!", __func__);
5575 return -EAGAIN;
5576 }
5577
Jeff Johnson295189b2012-06-20 16:38:30 -07005578 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
5579#ifdef WLAN_FEATURE_P2P
5580 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
5581#endif
5582 )
5583 {
5584 if( NULL == mac )
5585 {
5586 v_U16_t i;
5587 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
5588 {
5589 if(pAdapter->aStaInfo[i].isUsed)
5590 {
5591 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
5592 hddLog(VOS_TRACE_LEVEL_INFO,
5593 "%s: Delete STA with MAC::"
5594 "%02x:%02x:%02x:%02x:%02x:%02x",
5595 __func__,
5596 macAddr[0], macAddr[1], macAddr[2],
5597 macAddr[3], macAddr[4], macAddr[5]);
5598 hdd_softap_sta_deauth(pAdapter, macAddr);
5599 }
5600 }
5601 }
5602 else
5603 {
5604 hddLog(VOS_TRACE_LEVEL_INFO,
5605 "%s: Delete STA with MAC::"
5606 "%02x:%02x:%02x:%02x:%02x:%02x",
5607 __func__,
5608 mac[0], mac[1], mac[2],
5609 mac[3], mac[4], mac[5]);
5610 hdd_softap_sta_deauth(pAdapter, mac);
5611 }
5612 }
5613
5614 EXIT();
5615
5616 return 0;
5617}
5618
5619static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
5620 struct net_device *dev, u8 *mac, struct station_parameters *params)
5621{
5622 // TODO: Implement this later.
Jeff Johnsone7245742012-09-05 17:12:55 -07005623 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07005624 return 0;
5625}
5626
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005627
5628#ifdef FEATURE_WLAN_LFR
5629static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07005630 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005631{
5632#define MAX_PMKSAIDS_IN_CACHE 8
5633 static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache
5634 static tANI_U32 i = 0; // HDD Local Cache index
5635 tANI_U32 j=0;
5636 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5637 tHalHandle halHandle;
5638 eHalStatus result;
5639 tANI_U8 BSSIDMatched = 0;
5640
Jeff Johnsone7245742012-09-05 17:12:55 -07005641 ENTER();
5642
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005643 // Validate pAdapter
5644 if ( NULL == pAdapter || NULL == pAdapter->pHddCtx)
5645 {
5646 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid Adapter or HDD Context " ,__func__);
5647 return -EINVAL;
5648 }
5649
5650 if (((hdd_context_t*)pAdapter->pHddCtx)->isLoadUnloadInProgress)
5651 {
5652 hddLog( LOGE,
5653 "%s: Wlan Load/Unload is in progress", __func__);
5654 return -EBUSY;
5655 }
5656
5657 if ( (WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress )
5658 {
5659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5660 "%s:LOGP in Progress. Ignore!!!", __func__);
5661 return -EAGAIN;
5662 }
5663
5664 // Retrieve halHandle
5665 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
5666
5667 for (j = 0; j < i; j++)
5668 {
5669 if(vos_mem_compare(PMKIDCache[j].BSSID,
5670 pmksa->bssid, WNI_CFG_BSSID_LEN))
5671 {
5672 /* BSSID matched previous entry. Overwrite it. */
5673 BSSIDMatched = 1;
5674 vos_mem_copy(PMKIDCache[j].BSSID,
5675 pmksa->bssid, WNI_CFG_BSSID_LEN);
5676 vos_mem_copy(PMKIDCache[j].PMKID,
5677 pmksa->pmkid,
5678 CSR_RSN_PMKID_SIZE);
5679 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
5680 __FUNCTION__, j );
5681 dump_bssid(pmksa->bssid);
5682 dump_pmkid(halHandle, pmksa->pmkid);
5683 break;
5684 }
5685 }
5686
5687 if (!BSSIDMatched)
5688 {
5689 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
5690 vos_mem_copy(PMKIDCache[i].BSSID,
5691 pmksa->bssid, ETHER_ADDR_LEN);
5692 vos_mem_copy(PMKIDCache[i].PMKID,
5693 pmksa->pmkid,
5694 CSR_RSN_PMKID_SIZE);
5695 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
5696 __FUNCTION__, i );
5697 dump_bssid(pmksa->bssid);
5698 dump_pmkid(halHandle, pmksa->pmkid);
5699 // Increment the HDD Local Cache index
5700 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
5701 if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0;
5702 }
5703
5704
5705 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
5706 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
5707 // __FUNCTION__, i );
5708 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
5709 __FUNCTION__, i );
5710 // Finally set the PMKSA ID Cache in CSR
5711 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
5712 PMKIDCache,
5713 i );
5714 return 0;
5715}
5716
5717
5718static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07005719 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005720{
Jeff Johnsone7245742012-09-05 17:12:55 -07005721 ENTER();
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005722 // TODO: Implement this later.
5723 return 0;
5724}
5725
5726static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
5727{
Jeff Johnsone7245742012-09-05 17:12:55 -07005728 ENTER();
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005729 // TODO: Implement this later.
5730 return 0;
5731}
5732#endif
5733
5734
Jeff Johnson295189b2012-06-20 16:38:30 -07005735/* cfg80211_ops */
5736static struct cfg80211_ops wlan_hdd_cfg80211_ops =
5737{
5738 .add_virtual_intf = wlan_hdd_add_virtual_intf,
5739 .del_virtual_intf = wlan_hdd_del_virtual_intf,
5740 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
5741 .change_station = wlan_hdd_change_station,
5742#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
5743 .add_beacon = wlan_hdd_cfg80211_add_beacon,
5744 .del_beacon = wlan_hdd_cfg80211_del_beacon,
5745 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005746#else
5747 .start_ap = wlan_hdd_cfg80211_start_ap,
5748 .change_beacon = wlan_hdd_cfg80211_change_beacon,
5749 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07005750#endif
5751 .change_bss = wlan_hdd_cfg80211_change_bss,
5752 .add_key = wlan_hdd_cfg80211_add_key,
5753 .get_key = wlan_hdd_cfg80211_get_key,
5754 .del_key = wlan_hdd_cfg80211_del_key,
5755 .set_default_key = wlan_hdd_cfg80211_set_default_key,
5756 .set_channel = wlan_hdd_cfg80211_set_channel,
5757 .scan = wlan_hdd_cfg80211_scan,
5758 .connect = wlan_hdd_cfg80211_connect,
5759 .disconnect = wlan_hdd_cfg80211_disconnect,
5760 .join_ibss = wlan_hdd_cfg80211_join_ibss,
5761 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
5762 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
5763 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
5764 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
5765#ifdef WLAN_FEATURE_P2P
5766 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
5767 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
5768 .mgmt_tx = wlan_hdd_action,
5769#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
5770 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
5771 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
5772 .set_txq_params = wlan_hdd_set_txq_params,
5773#endif
5774#endif
5775 .get_station = wlan_hdd_cfg80211_get_station,
5776 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
5777 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005778 .add_station = wlan_hdd_cfg80211_add_station,
5779#ifdef FEATURE_WLAN_LFR
5780 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
5781 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
5782 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
5783#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005784};
5785
5786#endif // CONFIG_CFG80211