blob: d436e4170d744a3cfc9b398c81bb26c6dd91a7df [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +053026 *
Kiet Lamaa8e15a2014-02-11 23:30:06 -080027 */
Kiet Lam842dad02014-02-18 18:44:02 -080028
29
Kiet Lama7f454d2014-07-24 12:04:06 -070030
31
Jeff Johnson295189b2012-06-20 16:38:30 -070032/**========================================================================
33
34 \file wlan_hdd_cfg80211.c
35
36 \brief WLAN Host Device Driver implementation
37
Jeff Johnson295189b2012-06-20 16:38:30 -070038 ========================================================================*/
39
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070040/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070041
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070042 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070043
44
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070047
48
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070049 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070052 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070053 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070054 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070055
56 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070057 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070058 ==========================================================================*/
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060
61#include <linux/version.h>
62#include <linux/module.h>
63#include <linux/kernel.h>
64#include <linux/init.h>
65#include <linux/wireless.h>
66#include <wlan_hdd_includes.h>
67#include <net/arp.h>
68#include <net/cfg80211.h>
69#include <linux/wireless.h>
70#include <wlan_hdd_wowl.h>
71#include <aniGlobal.h>
72#include "ccmApi.h"
73#include "sirParams.h"
74#include "dot11f.h"
75#include "wlan_hdd_assoc.h"
76#include "wlan_hdd_wext.h"
77#include "sme_Api.h"
78#include "wlan_hdd_p2p.h"
79#include "wlan_hdd_cfg80211.h"
80#include "wlan_hdd_hostapd.h"
81#include "sapInternal.h"
82#include "wlan_hdd_softap_tx_rx.h"
83#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053084#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053085#include "wlan_hdd_power.h"
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053086#include "wlan_hdd_trace.h"
87#include "vos_types.h"
88#include "vos_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070089#ifdef WLAN_BTAMP_FEATURE
90#include "bap_hdd_misc.h"
91#endif
92#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080093#ifdef FEATURE_WLAN_TDLS
94#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053095#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053096#include "wlan_qct_wda.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080097#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053098#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070099#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -0700100
101#define g_mode_rates_size (12)
102#define a_mode_rates_size (8)
103#define FREQ_BASE_80211G (2407)
104#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700105#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530106#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700107#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800108 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700109
110#define HDD2GHZCHAN(freq, chan, flag) { \
111 .band = IEEE80211_BAND_2GHZ, \
112 .center_freq = (freq), \
113 .hw_value = (chan),\
114 .flags = (flag), \
115 .max_antenna_gain = 0 ,\
116 .max_power = 30, \
117}
118
119#define HDD5GHZCHAN(freq, chan, flag) { \
120 .band = IEEE80211_BAND_5GHZ, \
121 .center_freq = (freq), \
122 .hw_value = (chan),\
123 .flags = (flag), \
124 .max_antenna_gain = 0 ,\
125 .max_power = 30, \
126}
127
128#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
129{\
130 .bitrate = rate, \
131 .hw_value = rate_id, \
132 .flags = flag, \
133}
134
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530135#ifdef WLAN_FEATURE_VOWIFI_11R
136#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
137#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
138#endif
139
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530141#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530142
Sunil Duttc69bccb2014-05-26 21:30:20 +0530143#ifdef WLAN_FEATURE_LINK_LAYER_STATS
144/*
145 * Used to allocate the size of 4096 for the link layer stats.
146 * The size of 4096 is considered assuming that all data per
147 * respective event fit with in the limit.Please take a call
148 * on the limit based on the data requirements on link layer
149 * statistics.
150 */
151#define LL_STATS_EVENT_BUF_SIZE 4096
152#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530153#ifdef WLAN_FEATURE_EXTSCAN
154/*
155 * Used to allocate the size of 4096 for the EXTScan NL data.
156 * The size of 4096 is considered assuming that all data per
157 * respective event fit with in the limit.Please take a call
158 * on the limit based on the data requirements.
159 */
160
161#define EXTSCAN_EVENT_BUF_SIZE 4096
162#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
163#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530164
Atul Mittal115287b2014-07-08 13:26:33 +0530165/*EXT TDLS*/
166/*
167 * Used to allocate the size of 4096 for the TDLS.
168 * The size of 4096 is considered assuming that all data per
169 * respective event fit with in the limit.Please take a call
170 * on the limit based on the data requirements on link layer
171 * statistics.
172 */
173#define EXTTDLS_EVENT_BUF_SIZE 4096
174
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530175static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700176{
177 WLAN_CIPHER_SUITE_WEP40,
178 WLAN_CIPHER_SUITE_WEP104,
179 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800180#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700181#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
182 WLAN_CIPHER_SUITE_KRK,
183 WLAN_CIPHER_SUITE_CCMP,
184#else
185 WLAN_CIPHER_SUITE_CCMP,
186#endif
187#ifdef FEATURE_WLAN_WAPI
188 WLAN_CIPHER_SUITE_SMS4,
189#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700190#ifdef WLAN_FEATURE_11W
191 WLAN_CIPHER_SUITE_AES_CMAC,
192#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700193};
194
195static inline int is_broadcast_ether_addr(const u8 *addr)
196{
197 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
198 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
199}
200
201static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530202{
Jeff Johnson295189b2012-06-20 16:38:30 -0700203 HDD2GHZCHAN(2412, 1, 0) ,
204 HDD2GHZCHAN(2417, 2, 0) ,
205 HDD2GHZCHAN(2422, 3, 0) ,
206 HDD2GHZCHAN(2427, 4, 0) ,
207 HDD2GHZCHAN(2432, 5, 0) ,
208 HDD2GHZCHAN(2437, 6, 0) ,
209 HDD2GHZCHAN(2442, 7, 0) ,
210 HDD2GHZCHAN(2447, 8, 0) ,
211 HDD2GHZCHAN(2452, 9, 0) ,
212 HDD2GHZCHAN(2457, 10, 0) ,
213 HDD2GHZCHAN(2462, 11, 0) ,
214 HDD2GHZCHAN(2467, 12, 0) ,
215 HDD2GHZCHAN(2472, 13, 0) ,
216 HDD2GHZCHAN(2484, 14, 0) ,
217};
218
Jeff Johnson295189b2012-06-20 16:38:30 -0700219static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
220{
221 HDD2GHZCHAN(2412, 1, 0) ,
222 HDD2GHZCHAN(2437, 6, 0) ,
223 HDD2GHZCHAN(2462, 11, 0) ,
224};
Jeff Johnson295189b2012-06-20 16:38:30 -0700225
226static struct ieee80211_channel hdd_channels_5_GHZ[] =
227{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700228 HDD5GHZCHAN(4920, 240, 0) ,
229 HDD5GHZCHAN(4940, 244, 0) ,
230 HDD5GHZCHAN(4960, 248, 0) ,
231 HDD5GHZCHAN(4980, 252, 0) ,
232 HDD5GHZCHAN(5040, 208, 0) ,
233 HDD5GHZCHAN(5060, 212, 0) ,
234 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 HDD5GHZCHAN(5180, 36, 0) ,
236 HDD5GHZCHAN(5200, 40, 0) ,
237 HDD5GHZCHAN(5220, 44, 0) ,
238 HDD5GHZCHAN(5240, 48, 0) ,
239 HDD5GHZCHAN(5260, 52, 0) ,
240 HDD5GHZCHAN(5280, 56, 0) ,
241 HDD5GHZCHAN(5300, 60, 0) ,
242 HDD5GHZCHAN(5320, 64, 0) ,
243 HDD5GHZCHAN(5500,100, 0) ,
244 HDD5GHZCHAN(5520,104, 0) ,
245 HDD5GHZCHAN(5540,108, 0) ,
246 HDD5GHZCHAN(5560,112, 0) ,
247 HDD5GHZCHAN(5580,116, 0) ,
248 HDD5GHZCHAN(5600,120, 0) ,
249 HDD5GHZCHAN(5620,124, 0) ,
250 HDD5GHZCHAN(5640,128, 0) ,
251 HDD5GHZCHAN(5660,132, 0) ,
252 HDD5GHZCHAN(5680,136, 0) ,
253 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800254#ifdef FEATURE_WLAN_CH144
255 HDD5GHZCHAN(5720,144, 0) ,
256#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 HDD5GHZCHAN(5745,149, 0) ,
258 HDD5GHZCHAN(5765,153, 0) ,
259 HDD5GHZCHAN(5785,157, 0) ,
260 HDD5GHZCHAN(5805,161, 0) ,
261 HDD5GHZCHAN(5825,165, 0) ,
262};
263
264static struct ieee80211_rate g_mode_rates[] =
265{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530266 HDD_G_MODE_RATETAB(10, 0x1, 0),
267 HDD_G_MODE_RATETAB(20, 0x2, 0),
268 HDD_G_MODE_RATETAB(55, 0x4, 0),
269 HDD_G_MODE_RATETAB(110, 0x8, 0),
270 HDD_G_MODE_RATETAB(60, 0x10, 0),
271 HDD_G_MODE_RATETAB(90, 0x20, 0),
272 HDD_G_MODE_RATETAB(120, 0x40, 0),
273 HDD_G_MODE_RATETAB(180, 0x80, 0),
274 HDD_G_MODE_RATETAB(240, 0x100, 0),
275 HDD_G_MODE_RATETAB(360, 0x200, 0),
276 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700277 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530278};
Jeff Johnson295189b2012-06-20 16:38:30 -0700279
280static struct ieee80211_rate a_mode_rates[] =
281{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530282 HDD_G_MODE_RATETAB(60, 0x10, 0),
283 HDD_G_MODE_RATETAB(90, 0x20, 0),
284 HDD_G_MODE_RATETAB(120, 0x40, 0),
285 HDD_G_MODE_RATETAB(180, 0x80, 0),
286 HDD_G_MODE_RATETAB(240, 0x100, 0),
287 HDD_G_MODE_RATETAB(360, 0x200, 0),
288 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 HDD_G_MODE_RATETAB(540, 0x800, 0),
290};
291
292static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
293{
294 .channels = hdd_channels_2_4_GHZ,
295 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
296 .band = IEEE80211_BAND_2GHZ,
297 .bitrates = g_mode_rates,
298 .n_bitrates = g_mode_rates_size,
299 .ht_cap.ht_supported = 1,
300 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
301 | IEEE80211_HT_CAP_GRN_FLD
302 | IEEE80211_HT_CAP_DSSSCCK40
303 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
304 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
305 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
306 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
307 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
308 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
309};
310
Jeff Johnson295189b2012-06-20 16:38:30 -0700311static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
312{
313 .channels = hdd_social_channels_2_4_GHZ,
314 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
315 .band = IEEE80211_BAND_2GHZ,
316 .bitrates = g_mode_rates,
317 .n_bitrates = g_mode_rates_size,
318 .ht_cap.ht_supported = 1,
319 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
320 | IEEE80211_HT_CAP_GRN_FLD
321 | IEEE80211_HT_CAP_DSSSCCK40
322 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
323 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
324 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
325 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
326 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
327 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
328};
Jeff Johnson295189b2012-06-20 16:38:30 -0700329
330static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
331{
332 .channels = hdd_channels_5_GHZ,
333 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
334 .band = IEEE80211_BAND_5GHZ,
335 .bitrates = a_mode_rates,
336 .n_bitrates = a_mode_rates_size,
337 .ht_cap.ht_supported = 1,
338 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
339 | IEEE80211_HT_CAP_GRN_FLD
340 | IEEE80211_HT_CAP_DSSSCCK40
341 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
342 | IEEE80211_HT_CAP_SGI_40
343 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
344 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
345 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
346 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
347 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
348 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
349};
350
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530351/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 TX/RX direction for each kind of interface */
353static const struct ieee80211_txrx_stypes
354wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
355 [NL80211_IFTYPE_STATION] = {
356 .tx = 0xffff,
357 .rx = BIT(SIR_MAC_MGMT_ACTION) |
358 BIT(SIR_MAC_MGMT_PROBE_REQ),
359 },
360 [NL80211_IFTYPE_AP] = {
361 .tx = 0xffff,
362 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
363 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
364 BIT(SIR_MAC_MGMT_PROBE_REQ) |
365 BIT(SIR_MAC_MGMT_DISASSOC) |
366 BIT(SIR_MAC_MGMT_AUTH) |
367 BIT(SIR_MAC_MGMT_DEAUTH) |
368 BIT(SIR_MAC_MGMT_ACTION),
369 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700370 [NL80211_IFTYPE_ADHOC] = {
371 .tx = 0xffff,
372 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
373 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
374 BIT(SIR_MAC_MGMT_PROBE_REQ) |
375 BIT(SIR_MAC_MGMT_DISASSOC) |
376 BIT(SIR_MAC_MGMT_AUTH) |
377 BIT(SIR_MAC_MGMT_DEAUTH) |
378 BIT(SIR_MAC_MGMT_ACTION),
379 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 [NL80211_IFTYPE_P2P_CLIENT] = {
381 .tx = 0xffff,
382 .rx = BIT(SIR_MAC_MGMT_ACTION) |
383 BIT(SIR_MAC_MGMT_PROBE_REQ),
384 },
385 [NL80211_IFTYPE_P2P_GO] = {
386 /* This is also same as for SoftAP */
387 .tx = 0xffff,
388 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
389 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
390 BIT(SIR_MAC_MGMT_PROBE_REQ) |
391 BIT(SIR_MAC_MGMT_DISASSOC) |
392 BIT(SIR_MAC_MGMT_AUTH) |
393 BIT(SIR_MAC_MGMT_DEAUTH) |
394 BIT(SIR_MAC_MGMT_ACTION),
395 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700396};
397
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800398#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800399static const struct ieee80211_iface_limit
400wlan_hdd_iface_limit[] = {
401 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800402 /* max = 3 ; Our driver create two interfaces during driver init
403 * wlan0 and p2p0 interfaces. p2p0 is considered as station
404 * interface until a group is formed. In JB architecture, once the
405 * group is formed, interface type of p2p0 is changed to P2P GO or
406 * Client.
407 * When supplicant remove the group, it first issue a set interface
408 * cmd to change the mode back to Station. In JB this works fine as
409 * we advertize two station type interface during driver init.
410 * Some vendors create separate interface for P2P GO/Client,
411 * after group formation(Third one). But while group remove
412 * supplicant first tries to change the mode(3rd interface) to STATION
413 * But as we advertized only two sta type interfaces nl80211 was
414 * returning error for the third one which was leading to failure in
415 * delete interface. Ideally while removing the group, supplicant
416 * should not try to change the 3rd interface mode to Station type.
417 * Till we get a fix in wpa_supplicant, we advertize max STA
418 * interface type to 3
419 */
420 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800421 .types = BIT(NL80211_IFTYPE_STATION),
422 },
423 {
424 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700425 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800426 },
427 {
428 .max = 1,
429 .types = BIT(NL80211_IFTYPE_P2P_GO) |
430 BIT(NL80211_IFTYPE_P2P_CLIENT),
431 },
432};
433
434/* By default, only single channel concurrency is allowed */
435static struct ieee80211_iface_combination
436wlan_hdd_iface_combination = {
437 .limits = wlan_hdd_iface_limit,
438 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800439 /*
440 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
441 * and p2p0 interfaces during driver init
442 * Some vendors create separate interface for P2P operations.
443 * wlan0: STA interface
444 * p2p0: P2P Device interface, action frames goes
445 * through this interface.
446 * p2p-xx: P2P interface, After GO negotiation this interface is
447 * created for p2p operations(GO/CLIENT interface).
448 */
449 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800450 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
451 .beacon_int_infra_match = false,
452};
453#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800454
Jeff Johnson295189b2012-06-20 16:38:30 -0700455static struct cfg80211_ops wlan_hdd_cfg80211_ops;
456
457/* Data rate 100KBPS based on IE Index */
458struct index_data_rate_type
459{
460 v_U8_t beacon_rate_index;
461 v_U16_t supported_rate[4];
462};
463
464/* 11B, 11G Rate table include Basic rate and Extended rate
465 The IDX field is the rate index
466 The HI field is the rate when RSSI is strong or being ignored
467 (in this case we report actual rate)
468 The MID field is the rate when RSSI is moderate
469 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
470 The LO field is the rate when RSSI is low
471 (in this case we don't report rates, actual current rate used)
472 */
473static const struct
474{
475 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700476 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700477} supported_data_rate[] =
478{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700479/* IDX HI HM LM LO (RSSI-based index */
480 {2, { 10, 10, 10, 0}},
481 {4, { 20, 20, 10, 0}},
482 {11, { 55, 20, 10, 0}},
483 {12, { 60, 55, 20, 0}},
484 {18, { 90, 55, 20, 0}},
485 {22, {110, 55, 20, 0}},
486 {24, {120, 90, 60, 0}},
487 {36, {180, 120, 60, 0}},
488 {44, {220, 180, 60, 0}},
489 {48, {240, 180, 90, 0}},
490 {66, {330, 180, 90, 0}},
491 {72, {360, 240, 90, 0}},
492 {96, {480, 240, 120, 0}},
493 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700494};
495
496/* MCS Based rate table */
497static struct index_data_rate_type supported_mcs_rate[] =
498{
499/* MCS L20 L40 S20 S40 */
500 {0, {65, 135, 72, 150}},
501 {1, {130, 270, 144, 300}},
502 {2, {195, 405, 217, 450}},
503 {3, {260, 540, 289, 600}},
504 {4, {390, 810, 433, 900}},
505 {5, {520, 1080, 578, 1200}},
506 {6, {585, 1215, 650, 1350}},
507 {7, {650, 1350, 722, 1500}}
508};
509
Leo Chang6f8870f2013-03-26 18:11:36 -0700510#ifdef WLAN_FEATURE_11AC
511
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530512#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700513
514struct index_vht_data_rate_type
515{
516 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530517 v_U16_t supported_VHT80_rate[2];
518 v_U16_t supported_VHT40_rate[2];
519 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700520};
521
522typedef enum
523{
524 DATA_RATE_11AC_MAX_MCS_7,
525 DATA_RATE_11AC_MAX_MCS_8,
526 DATA_RATE_11AC_MAX_MCS_9,
527 DATA_RATE_11AC_MAX_MCS_NA
528} eDataRate11ACMaxMcs;
529
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530530/* SSID broadcast type */
531typedef enum eSSIDBcastType
532{
533 eBCAST_UNKNOWN = 0,
534 eBCAST_NORMAL = 1,
535 eBCAST_HIDDEN = 2,
536} tSSIDBcastType;
537
Leo Chang6f8870f2013-03-26 18:11:36 -0700538/* MCS Based VHT rate table */
539static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
540{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530541/* MCS L80 S80 L40 S40 L20 S40*/
542 {0, {293, 325}, {135, 150}, {65, 72}},
543 {1, {585, 650}, {270, 300}, {130, 144}},
544 {2, {878, 975}, {405, 450}, {195, 217}},
545 {3, {1170, 1300}, {540, 600}, {260, 289}},
546 {4, {1755, 1950}, {810, 900}, {390, 433}},
547 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
548 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
549 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
550 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
551 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700552};
553#endif /* WLAN_FEATURE_11AC */
554
c_hpothu79aab322014-07-14 21:11:01 +0530555/*array index points to MCS and array value points respective rssi*/
556static int rssiMcsTbl[][10] =
557{
558/*MCS 0 1 2 3 4 5 6 7 8 9*/
559 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
560 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
561 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
562};
563
Jeff Johnson295189b2012-06-20 16:38:30 -0700564extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530565#ifdef FEATURE_WLAN_SCAN_PNO
566static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
567#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700568
Leo Chang9056f462013-08-01 19:21:11 -0700569#ifdef WLAN_NL80211_TESTMODE
570enum wlan_hdd_tm_attr
571{
572 WLAN_HDD_TM_ATTR_INVALID = 0,
573 WLAN_HDD_TM_ATTR_CMD = 1,
574 WLAN_HDD_TM_ATTR_DATA = 2,
575 WLAN_HDD_TM_ATTR_TYPE = 3,
576 /* keep last */
577 WLAN_HDD_TM_ATTR_AFTER_LAST,
578 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
579};
580
581enum wlan_hdd_tm_cmd
582{
583 WLAN_HDD_TM_CMD_WLAN_HB = 1,
584};
585
586#define WLAN_HDD_TM_DATA_MAX_LEN 5000
587
588static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
589{
590 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
591 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
592 .len = WLAN_HDD_TM_DATA_MAX_LEN },
593};
594#endif /* WLAN_NL80211_TESTMODE */
595
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800596#ifdef FEATURE_WLAN_CH_AVOID
597/*
598 * FUNCTION: wlan_hdd_send_avoid_freq_event
599 * This is called when wlan driver needs to send vendor specific
600 * avoid frequency range event to userspace
601 */
602int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
603 tHddAvoidFreqList *pAvoidFreqList)
604{
605 struct sk_buff *vendor_event;
606
607 ENTER();
608
609 if (!pHddCtx)
610 {
611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
612 "%s: HDD context is null", __func__);
613 return -1;
614 }
615
616 if (!pAvoidFreqList)
617 {
618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
619 "%s: pAvoidFreqList is null", __func__);
620 return -1;
621 }
622
623 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
624 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530625 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800626 GFP_KERNEL);
627 if (!vendor_event)
628 {
629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
630 "%s: cfg80211_vendor_event_alloc failed", __func__);
631 return -1;
632 }
633
634 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
635 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
636
637 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
638
639 EXIT();
640 return 0;
641}
642#endif /* FEATURE_WLAN_CH_AVOID */
643
Srinivas Dasari030bad32015-02-18 23:23:54 +0530644/*
645 * FUNCTION: __wlan_hdd_cfg80211_nan_request
646 * This is called when wlan driver needs to send vendor specific
647 * nan request event.
648 */
649static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
650 struct wireless_dev *wdev,
651 const void *data, int data_len)
652{
653 tNanRequestReq nan_req;
654 VOS_STATUS status;
655 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530656 struct net_device *dev = wdev->netdev;
657 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
658 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530659 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
660
661 if (0 == data_len)
662 {
663 hddLog(VOS_TRACE_LEVEL_ERROR,
664 FL("NAN - Invalid Request, length = 0"));
665 return ret_val;
666 }
667
668 if (NULL == data)
669 {
670 hddLog(VOS_TRACE_LEVEL_ERROR,
671 FL("NAN - Invalid Request, data is NULL"));
672 return ret_val;
673 }
674
675 status = wlan_hdd_validate_context(pHddCtx);
676 if (0 != status)
677 {
678 hddLog(VOS_TRACE_LEVEL_ERROR,
679 FL("HDD context is not valid"));
680 return -EINVAL;
681 }
682
683 hddLog(LOG1, FL("Received NAN command"));
684 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
685 (tANI_U8 *)data, data_len);
686
687 /* check the NAN Capability */
688 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
689 {
690 hddLog(VOS_TRACE_LEVEL_ERROR,
691 FL("NAN is not supported by Firmware"));
692 return -EINVAL;
693 }
694
695 nan_req.request_data_len = data_len;
696 nan_req.request_data = data;
697
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530698 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530699 if (VOS_STATUS_SUCCESS == status)
700 {
701 ret_val = 0;
702 }
703 return ret_val;
704}
705
706/*
707 * FUNCTION: wlan_hdd_cfg80211_nan_request
708 * Wrapper to protect the nan vendor command from ssr
709 */
710static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
711 struct wireless_dev *wdev,
712 const void *data, int data_len)
713{
714 int ret;
715
716 vos_ssr_protect(__func__);
717 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
718 vos_ssr_unprotect(__func__);
719
720 return ret;
721}
722
723/*
724 * FUNCTION: wlan_hdd_cfg80211_nan_callback
725 * This is a callback function and it gets called
726 * when we need to report nan response event to
727 * upper layers.
728 */
729static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
730{
731 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
732 struct sk_buff *vendor_event;
733 int status;
734 tSirNanEvent *data;
735
736 ENTER();
737 if (NULL == msg)
738 {
739 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
740 FL(" msg received here is null"));
741 return;
742 }
743 data = msg;
744
745 status = wlan_hdd_validate_context(pHddCtx);
746
747 if (0 != status)
748 {
749 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
750 FL("HDD context is not valid"));
751 return;
752 }
753
754 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
755 data->event_data_len +
756 NLMSG_HDRLEN,
757 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
758 GFP_KERNEL);
759
760 if (!vendor_event)
761 {
762 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
763 FL("cfg80211_vendor_event_alloc failed"));
764 return;
765 }
766 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
767 data->event_data_len, data->event_data))
768 {
769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
770 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
771 kfree_skb(vendor_event);
772 return;
773 }
774 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
775 EXIT();
776}
777
778/*
779 * FUNCTION: wlan_hdd_cfg80211_nan_init
780 * This function is called to register the callback to sme layer
781 */
782inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
783{
784 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
785}
786
787
Sunil Duttc69bccb2014-05-26 21:30:20 +0530788#ifdef WLAN_FEATURE_LINK_LAYER_STATS
789
790static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
791 struct sk_buff *vendor_event)
792{
793 if (nla_put_u8(vendor_event,
794 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
795 stats->rate.preamble) ||
796 nla_put_u8(vendor_event,
797 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
798 stats->rate.nss) ||
799 nla_put_u8(vendor_event,
800 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
801 stats->rate.bw) ||
802 nla_put_u8(vendor_event,
803 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
804 stats->rate.rateMcsIdx) ||
805 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
806 stats->rate.bitrate ) ||
807 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
808 stats->txMpdu ) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
810 stats->rxMpdu ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
812 stats->mpduLost ) ||
813 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
814 stats->retries) ||
815 nla_put_u32(vendor_event,
816 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
817 stats->retriesShort ) ||
818 nla_put_u32(vendor_event,
819 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
820 stats->retriesLong))
821 {
822 hddLog(VOS_TRACE_LEVEL_ERROR,
823 FL("QCA_WLAN_VENDOR_ATTR put fail"));
824 return FALSE;
825 }
826 return TRUE;
827}
828
829static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
830 struct sk_buff *vendor_event)
831{
832 u32 i = 0;
833 struct nlattr *rateInfo;
834 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
835 stats->type) ||
836 nla_put(vendor_event,
837 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
838 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
839 nla_put_u32(vendor_event,
840 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
841 stats->capabilities) ||
842 nla_put_u32(vendor_event,
843 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
844 stats->numRate))
845 {
846 hddLog(VOS_TRACE_LEVEL_ERROR,
847 FL("QCA_WLAN_VENDOR_ATTR put fail"));
848 goto error;
849 }
850
851 rateInfo = nla_nest_start(vendor_event,
852 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530853 if(!rateInfo)
854 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530855 for (i = 0; i < stats->numRate; i++)
856 {
857 struct nlattr *rates;
858 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
859 stats->rateStats +
860 (i * sizeof(tSirWifiRateStat)));
861 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530862 if(!rates)
863 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530864
865 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
866 {
867 hddLog(VOS_TRACE_LEVEL_ERROR,
868 FL("QCA_WLAN_VENDOR_ATTR put fail"));
869 return FALSE;
870 }
871 nla_nest_end(vendor_event, rates);
872 }
873 nla_nest_end(vendor_event, rateInfo);
874
875 return TRUE;
876error:
877 return FALSE;
878}
879
880static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
881 struct sk_buff *vendor_event)
882{
883 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
884 stats->ac ) ||
885 nla_put_u32(vendor_event,
886 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
887 stats->txMpdu ) ||
888 nla_put_u32(vendor_event,
889 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
890 stats->rxMpdu ) ||
891 nla_put_u32(vendor_event,
892 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
893 stats->txMcast ) ||
894 nla_put_u32(vendor_event,
895 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
896 stats->rxMcast ) ||
897 nla_put_u32(vendor_event,
898 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
899 stats->rxAmpdu ) ||
900 nla_put_u32(vendor_event,
901 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
902 stats->txAmpdu ) ||
903 nla_put_u32(vendor_event,
904 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
905 stats->mpduLost )||
906 nla_put_u32(vendor_event,
907 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
908 stats->retries ) ||
909 nla_put_u32(vendor_event,
910 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
911 stats->retriesShort ) ||
912 nla_put_u32(vendor_event,
913 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
914 stats->retriesLong ) ||
915 nla_put_u32(vendor_event,
916 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
917 stats->contentionTimeMin ) ||
918 nla_put_u32(vendor_event,
919 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
920 stats->contentionTimeMax ) ||
921 nla_put_u32(vendor_event,
922 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
923 stats->contentionTimeAvg ) ||
924 nla_put_u32(vendor_event,
925 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
926 stats->contentionNumSamples ))
927 {
928 hddLog(VOS_TRACE_LEVEL_ERROR,
929 FL("QCA_WLAN_VENDOR_ATTR put fail") );
930 return FALSE;
931 }
932 return TRUE;
933}
934
935static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
936 struct sk_buff *vendor_event)
937{
Dino Myclec8f3f332014-07-21 16:48:27 +0530938 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530939 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
940 nla_put(vendor_event,
941 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
942 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
943 nla_put_u32(vendor_event,
944 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
945 stats->state ) ||
946 nla_put_u32(vendor_event,
947 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
948 stats->roaming ) ||
949 nla_put_u32(vendor_event,
950 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
951 stats->capabilities ) ||
952 nla_put(vendor_event,
953 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
954 strlen(stats->ssid), stats->ssid) ||
955 nla_put(vendor_event,
956 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
957 WNI_CFG_BSSID_LEN, stats->bssid) ||
958 nla_put(vendor_event,
959 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
960 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
961 nla_put(vendor_event,
962 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
963 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
964 )
965 {
966 hddLog(VOS_TRACE_LEVEL_ERROR,
967 FL("QCA_WLAN_VENDOR_ATTR put fail") );
968 return FALSE;
969 }
970 return TRUE;
971}
972
Dino Mycle3b9536d2014-07-09 22:05:24 +0530973static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
974 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530975 struct sk_buff *vendor_event)
976{
977 int i = 0;
978 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530979 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
980 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530981 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530982
Sunil Duttc69bccb2014-05-26 21:30:20 +0530983 if (FALSE == put_wifi_interface_info(
984 &pWifiIfaceStat->info,
985 vendor_event))
986 {
987 hddLog(VOS_TRACE_LEVEL_ERROR,
988 FL("QCA_WLAN_VENDOR_ATTR put fail") );
989 return FALSE;
990
991 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530992 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
993 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
994 if (NULL == pWifiIfaceStatTL)
995 {
996 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
997 return FALSE;
998 }
999
Srinivas Dasaria8a304f2014-11-15 16:13:37 +05301000 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
1001 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1002 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1003 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1004
1005 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1007 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1008 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301009
1010 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1011 {
1012 if (VOS_STATUS_SUCCESS ==
1013 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1014 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1015 {
1016 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1017 * obtained from TL structure
1018 */
1019
1020 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1021 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301022 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1023
Srinivas Dasari98947432014-11-07 19:41:24 +05301024 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1025 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1026 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1027 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1028 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1030 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1031 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301032
Srinivas Dasari98947432014-11-07 19:41:24 +05301033 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1034 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1035 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1036 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1037 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1039 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1040 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301041
Srinivas Dasari98947432014-11-07 19:41:24 +05301042 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1043 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1044 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1045 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1046 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1048 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1049 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301050 }
1051 else
1052 {
1053 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1054 }
1055
Dino Mycle3b9536d2014-07-09 22:05:24 +05301056 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1057 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1058 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1059 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1060 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1062 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1063 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1064 }
1065 else
1066 {
1067 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1068 }
1069
1070
Sunil Duttc69bccb2014-05-26 21:30:20 +05301071
1072 if (nla_put_u32(vendor_event,
1073 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1074 pWifiIfaceStat->beaconRx) ||
1075 nla_put_u32(vendor_event,
1076 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1077 pWifiIfaceStat->mgmtRx) ||
1078 nla_put_u32(vendor_event,
1079 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1080 pWifiIfaceStat->mgmtActionRx) ||
1081 nla_put_u32(vendor_event,
1082 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1083 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301084 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301085 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1086 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301087 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301088 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1089 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301090 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301091 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1092 pWifiIfaceStat->rssiAck))
1093 {
1094 hddLog(VOS_TRACE_LEVEL_ERROR,
1095 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301096 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301097 return FALSE;
1098 }
1099
1100 wmmInfo = nla_nest_start(vendor_event,
1101 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301102 if(!wmmInfo)
1103 {
1104 vos_mem_free(pWifiIfaceStatTL);
1105 return FALSE;
1106 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301107 for (i = 0; i < WIFI_AC_MAX; i++)
1108 {
1109 struct nlattr *wmmStats;
1110 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301111 if(!wmmStats)
1112 {
1113 vos_mem_free(pWifiIfaceStatTL);
1114 return FALSE;
1115 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301116 if (FALSE == put_wifi_wmm_ac_stat(
1117 &pWifiIfaceStat->AccessclassStats[i],
1118 vendor_event))
1119 {
1120 hddLog(VOS_TRACE_LEVEL_ERROR,
1121 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301122 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301123 return FALSE;
1124 }
1125
1126 nla_nest_end(vendor_event, wmmStats);
1127 }
1128 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301129 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301130 return TRUE;
1131}
1132
1133static tSirWifiInterfaceMode
1134 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1135{
1136 switch (deviceMode)
1137 {
1138 case WLAN_HDD_INFRA_STATION:
1139 return WIFI_INTERFACE_STA;
1140 case WLAN_HDD_SOFTAP:
1141 return WIFI_INTERFACE_SOFTAP;
1142 case WLAN_HDD_P2P_CLIENT:
1143 return WIFI_INTERFACE_P2P_CLIENT;
1144 case WLAN_HDD_P2P_GO:
1145 return WIFI_INTERFACE_P2P_GO;
1146 case WLAN_HDD_IBSS:
1147 return WIFI_INTERFACE_IBSS;
1148 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301149 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301150 }
1151}
1152
1153static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1154 tpSirWifiInterfaceInfo pInfo)
1155{
1156 v_U8_t *staMac = NULL;
1157 hdd_station_ctx_t *pHddStaCtx;
1158 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1159 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1160
1161 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1162
1163 vos_mem_copy(pInfo->macAddr,
1164 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1165
1166 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1167 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1168 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1169 {
1170 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1171 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1172 {
1173 pInfo->state = WIFI_DISCONNECTED;
1174 }
1175 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1176 {
1177 hddLog(VOS_TRACE_LEVEL_ERROR,
1178 "%s: Session ID %d, Connection is in progress", __func__,
1179 pAdapter->sessionId);
1180 pInfo->state = WIFI_ASSOCIATING;
1181 }
1182 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1183 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1184 {
1185 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1186 hddLog(VOS_TRACE_LEVEL_ERROR,
1187 "%s: client " MAC_ADDRESS_STR
1188 " is in the middle of WPS/EAPOL exchange.", __func__,
1189 MAC_ADDR_ARRAY(staMac));
1190 pInfo->state = WIFI_AUTHENTICATING;
1191 }
1192 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1193 {
1194 pInfo->state = WIFI_ASSOCIATED;
1195 vos_mem_copy(pInfo->bssid,
1196 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1197 vos_mem_copy(pInfo->ssid,
1198 pHddStaCtx->conn_info.SSID.SSID.ssId,
1199 pHddStaCtx->conn_info.SSID.SSID.length);
1200 //NULL Terminate the string.
1201 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1202 }
1203 }
1204 vos_mem_copy(pInfo->countryStr,
1205 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1206
1207 vos_mem_copy(pInfo->apCountryStr,
1208 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1209
1210 return TRUE;
1211}
1212
1213/*
1214 * hdd_link_layer_process_peer_stats () - This function is called after
1215 * receiving Link Layer Peer statistics from FW.This function converts
1216 * the firmware data to the NL data and sends the same to the kernel/upper
1217 * layers.
1218 */
1219static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1220 v_VOID_t *pData)
1221{
1222 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1223 tpSirWifiRateStat pWifiRateStat;
1224 tpSirWifiPeerStat pWifiPeerStat;
1225 tpSirWifiPeerInfo pWifiPeerInfo;
1226 struct nlattr *peerInfo;
1227 struct sk_buff *vendor_event;
1228 int status, i;
1229
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301230 ENTER();
1231
Sunil Duttc69bccb2014-05-26 21:30:20 +05301232 status = wlan_hdd_validate_context(pHddCtx);
1233 if (0 != status)
1234 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301235 return;
1236 }
1237
1238 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1239
1240 hddLog(VOS_TRACE_LEVEL_INFO,
1241 "LL_STATS_PEER_ALL : numPeers %u",
1242 pWifiPeerStat->numPeers);
1243 {
1244 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1245 {
1246 pWifiPeerInfo = (tpSirWifiPeerInfo)
1247 ((uint8 *)pWifiPeerStat->peerInfo +
1248 ( i * sizeof(tSirWifiPeerInfo)));
1249
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301250 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1251 pWifiPeerInfo->type = WIFI_PEER_AP;
1252 }
1253 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1254 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1255 }
1256
Sunil Duttc69bccb2014-05-26 21:30:20 +05301257 hddLog(VOS_TRACE_LEVEL_INFO,
1258 " %d) LL_STATS Channel Stats "
1259 " Peer Type %u "
1260 " peerMacAddress %pM "
1261 " capabilities 0x%x "
1262 " numRate %u ",
1263 i,
1264 pWifiPeerInfo->type,
1265 pWifiPeerInfo->peerMacAddress,
1266 pWifiPeerInfo->capabilities,
1267 pWifiPeerInfo->numRate);
1268 {
1269 int j;
1270 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1271 {
1272 pWifiRateStat = (tpSirWifiRateStat)
1273 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1274 ( j * sizeof(tSirWifiRateStat)));
1275
1276 hddLog(VOS_TRACE_LEVEL_INFO,
1277 " peer Rate Stats "
1278 " preamble %u "
1279 " nss %u "
1280 " bw %u "
1281 " rateMcsIdx %u "
1282 " reserved %u "
1283 " bitrate %u "
1284 " txMpdu %u "
1285 " rxMpdu %u "
1286 " mpduLost %u "
1287 " retries %u "
1288 " retriesShort %u "
1289 " retriesLong %u",
1290 pWifiRateStat->rate.preamble,
1291 pWifiRateStat->rate.nss,
1292 pWifiRateStat->rate.bw,
1293 pWifiRateStat->rate.rateMcsIdx,
1294 pWifiRateStat->rate.reserved,
1295 pWifiRateStat->rate.bitrate,
1296 pWifiRateStat->txMpdu,
1297 pWifiRateStat->rxMpdu,
1298 pWifiRateStat->mpduLost,
1299 pWifiRateStat->retries,
1300 pWifiRateStat->retriesShort,
1301 pWifiRateStat->retriesLong);
1302 }
1303 }
1304 }
1305 }
1306
1307 /*
1308 * Allocate a size of 4096 for the peer stats comprising
1309 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1310 * sizeof (tSirWifiRateStat).Each field is put with an
1311 * NL attribute.The size of 4096 is considered assuming
1312 * that number of rates shall not exceed beyond 50 with
1313 * the sizeof (tSirWifiRateStat) being 32.
1314 */
1315 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1316 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1317 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1318 GFP_KERNEL);
1319 if (!vendor_event)
1320 {
1321 hddLog(VOS_TRACE_LEVEL_ERROR,
1322 "%s: cfg80211_vendor_event_alloc failed",
1323 __func__);
1324 return;
1325 }
1326 if (nla_put_u32(vendor_event,
1327 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1328 pWifiPeerStat->numPeers))
1329 {
1330 hddLog(VOS_TRACE_LEVEL_ERROR,
1331 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1332 kfree_skb(vendor_event);
1333 return;
1334 }
1335
1336 peerInfo = nla_nest_start(vendor_event,
1337 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301338 if(!peerInfo)
1339 {
1340 hddLog(VOS_TRACE_LEVEL_ERROR,
1341 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1342 __func__);
1343 kfree_skb(vendor_event);
1344 return;
1345 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301346
1347 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1348 pWifiPeerStat->peerInfo);
1349
1350 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1351 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301352 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301353 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301354
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301355 if(!peers)
1356 {
1357 hddLog(VOS_TRACE_LEVEL_ERROR,
1358 "%s: peer stats put fail",
1359 __func__);
1360 kfree_skb(vendor_event);
1361 return;
1362 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301363 if (FALSE == put_wifi_peer_info(
1364 pWifiPeerInfo, vendor_event))
1365 {
1366 hddLog(VOS_TRACE_LEVEL_ERROR,
1367 "%s: put_wifi_peer_info put fail", __func__);
1368 kfree_skb(vendor_event);
1369 return;
1370 }
1371
1372 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1373 pWifiPeerStat->peerInfo +
1374 (i * sizeof(tSirWifiPeerInfo)) +
1375 (numRate * sizeof (tSirWifiRateStat)));
1376 nla_nest_end(vendor_event, peers);
1377 }
1378 nla_nest_end(vendor_event, peerInfo);
1379 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301380
1381 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301382}
1383
1384/*
1385 * hdd_link_layer_process_iface_stats () - This function is called after
1386 * receiving Link Layer Interface statistics from FW.This function converts
1387 * the firmware data to the NL data and sends the same to the kernel/upper
1388 * layers.
1389 */
1390static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1391 v_VOID_t *pData)
1392{
1393 tpSirWifiIfaceStat pWifiIfaceStat;
1394 struct sk_buff *vendor_event;
1395 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1396 int status;
1397
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301398 ENTER();
1399
Sunil Duttc69bccb2014-05-26 21:30:20 +05301400 status = wlan_hdd_validate_context(pHddCtx);
1401 if (0 != status)
1402 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301403 return;
1404 }
1405 /*
1406 * Allocate a size of 4096 for the interface stats comprising
1407 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1408 * assuming that all these fit with in the limit.Please take
1409 * a call on the limit based on the data requirements on
1410 * interface statistics.
1411 */
1412 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1413 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1414 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1415 GFP_KERNEL);
1416 if (!vendor_event)
1417 {
1418 hddLog(VOS_TRACE_LEVEL_ERROR,
1419 FL("cfg80211_vendor_event_alloc failed") );
1420 return;
1421 }
1422
1423 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1424
Dino Mycle3b9536d2014-07-09 22:05:24 +05301425
1426 if (FALSE == hdd_get_interface_info( pAdapter,
1427 &pWifiIfaceStat->info))
1428 {
1429 hddLog(VOS_TRACE_LEVEL_ERROR,
1430 FL("hdd_get_interface_info get fail") );
1431 kfree_skb(vendor_event);
1432 return;
1433 }
1434
1435 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1436 vendor_event))
1437 {
1438 hddLog(VOS_TRACE_LEVEL_ERROR,
1439 FL("put_wifi_iface_stats fail") );
1440 kfree_skb(vendor_event);
1441 return;
1442 }
1443
Sunil Duttc69bccb2014-05-26 21:30:20 +05301444 hddLog(VOS_TRACE_LEVEL_INFO,
1445 "WMI_LINK_STATS_IFACE Data");
1446
1447 hddLog(VOS_TRACE_LEVEL_INFO,
1448 "LL_STATS_IFACE: "
1449 " Mode %u "
1450 " MAC %pM "
1451 " State %u "
1452 " Roaming %u "
1453 " capabilities 0x%x "
1454 " SSID %s "
1455 " BSSID %pM",
1456 pWifiIfaceStat->info.mode,
1457 pWifiIfaceStat->info.macAddr,
1458 pWifiIfaceStat->info.state,
1459 pWifiIfaceStat->info.roaming,
1460 pWifiIfaceStat->info.capabilities,
1461 pWifiIfaceStat->info.ssid,
1462 pWifiIfaceStat->info.bssid);
1463
1464 hddLog(VOS_TRACE_LEVEL_INFO,
1465 " AP country str: %c%c%c",
1466 pWifiIfaceStat->info.apCountryStr[0],
1467 pWifiIfaceStat->info.apCountryStr[1],
1468 pWifiIfaceStat->info.apCountryStr[2]);
1469
1470
1471 hddLog(VOS_TRACE_LEVEL_INFO,
1472 " Country Str Association: %c%c%c",
1473 pWifiIfaceStat->info.countryStr[0],
1474 pWifiIfaceStat->info.countryStr[1],
1475 pWifiIfaceStat->info.countryStr[2]);
1476
1477 hddLog(VOS_TRACE_LEVEL_INFO,
1478 " beaconRx %u "
1479 " mgmtRx %u "
1480 " mgmtActionRx %u "
1481 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301482 " rssiMgmt %d "
1483 " rssiData %d "
1484 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301485 pWifiIfaceStat->beaconRx,
1486 pWifiIfaceStat->mgmtRx,
1487 pWifiIfaceStat->mgmtActionRx,
1488 pWifiIfaceStat->mgmtActionTx,
1489 pWifiIfaceStat->rssiMgmt,
1490 pWifiIfaceStat->rssiData,
1491 pWifiIfaceStat->rssiAck );
1492
1493
1494 {
1495 int i;
1496 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1497 {
1498 hddLog(VOS_TRACE_LEVEL_INFO,
1499
1500 " %d) LL_STATS IFACE: "
1501 " ac: %u txMpdu: %u "
1502 " rxMpdu: %u txMcast: %u "
1503 " rxMcast: %u rxAmpdu: %u "
1504 " txAmpdu: %u mpduLost: %u "
1505 " retries: %u retriesShort: %u "
1506 " retriesLong: %u contentionTimeMin: %u "
1507 " contentionTimeMax: %u contentionTimeAvg: %u "
1508 " contentionNumSamples: %u",
1509 i,
1510 pWifiIfaceStat->AccessclassStats[i].ac,
1511 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1512 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1513 pWifiIfaceStat->AccessclassStats[i].txMcast,
1514 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1515 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1516 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1517 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1518 pWifiIfaceStat->AccessclassStats[i].retries,
1519 pWifiIfaceStat->
1520 AccessclassStats[i].retriesShort,
1521 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1522 pWifiIfaceStat->
1523 AccessclassStats[i].contentionTimeMin,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].contentionTimeMax,
1526 pWifiIfaceStat->
1527 AccessclassStats[i].contentionTimeAvg,
1528 pWifiIfaceStat->
1529 AccessclassStats[i].contentionNumSamples);
1530
1531 }
1532 }
1533
Sunil Duttc69bccb2014-05-26 21:30:20 +05301534 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301535
1536 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301537}
1538
1539/*
1540 * hdd_link_layer_process_radio_stats () - This function is called after
1541 * receiving Link Layer Radio statistics from FW.This function converts
1542 * the firmware data to the NL data and sends the same to the kernel/upper
1543 * layers.
1544 */
1545static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1546 v_VOID_t *pData)
1547{
1548 int status, i;
1549 tpSirWifiRadioStat pWifiRadioStat;
1550 tpSirWifiChannelStats pWifiChannelStats;
1551 struct sk_buff *vendor_event;
1552 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1553 struct nlattr *chList;
1554
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301555 ENTER();
1556
Sunil Duttc69bccb2014-05-26 21:30:20 +05301557 status = wlan_hdd_validate_context(pHddCtx);
1558 if (0 != status)
1559 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301560 return;
1561 }
1562 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1563
1564 hddLog(VOS_TRACE_LEVEL_INFO,
1565 "LL_STATS_RADIO"
1566 " radio is %d onTime is %u "
1567 " txTime is %u rxTime is %u "
1568 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301569 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301570 " onTimePnoScan is %u onTimeHs20 is %u "
1571 " numChannels is %u",
1572 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1573 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1574 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301575 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301576 pWifiRadioStat->onTimeRoamScan,
1577 pWifiRadioStat->onTimePnoScan,
1578 pWifiRadioStat->onTimeHs20,
1579 pWifiRadioStat->numChannels);
1580 /*
1581 * Allocate a size of 4096 for the Radio stats comprising
1582 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1583 * (tSirWifiChannelStats).Each channel data is put with an
1584 * NL attribute.The size of 4096 is considered assuming that
1585 * number of channels shall not exceed beyond 60 with the
1586 * sizeof (tSirWifiChannelStats) being 24 bytes.
1587 */
1588
1589 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1590 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1591 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1592 GFP_KERNEL);
1593
1594 if (!vendor_event)
1595 {
1596 hddLog(VOS_TRACE_LEVEL_ERROR,
1597 FL("cfg80211_vendor_event_alloc failed") );
1598 return;
1599 }
1600
1601 if (nla_put_u32(vendor_event,
1602 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1603 pWifiRadioStat->radio) ||
1604 nla_put_u32(vendor_event,
1605 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1606 pWifiRadioStat->onTime) ||
1607 nla_put_u32(vendor_event,
1608 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1609 pWifiRadioStat->txTime) ||
1610 nla_put_u32(vendor_event,
1611 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1612 pWifiRadioStat->rxTime) ||
1613 nla_put_u32(vendor_event,
1614 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1615 pWifiRadioStat->onTimeScan) ||
1616 nla_put_u32(vendor_event,
1617 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1618 pWifiRadioStat->onTimeNbd) ||
1619 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301620 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1621 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301622 nla_put_u32(vendor_event,
1623 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1624 pWifiRadioStat->onTimeRoamScan) ||
1625 nla_put_u32(vendor_event,
1626 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1627 pWifiRadioStat->onTimePnoScan) ||
1628 nla_put_u32(vendor_event,
1629 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1630 pWifiRadioStat->onTimeHs20) ||
1631 nla_put_u32(vendor_event,
1632 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1633 pWifiRadioStat->numChannels))
1634 {
1635 hddLog(VOS_TRACE_LEVEL_ERROR,
1636 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1637 kfree_skb(vendor_event);
1638 return ;
1639 }
1640
1641 chList = nla_nest_start(vendor_event,
1642 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301643 if(!chList)
1644 {
1645 hddLog(VOS_TRACE_LEVEL_ERROR,
1646 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1647 __func__);
1648 kfree_skb(vendor_event);
1649 return;
1650 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301651 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1652 {
1653 struct nlattr *chInfo;
1654
1655 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1656 pWifiRadioStat->channels +
1657 (i * sizeof(tSirWifiChannelStats)));
1658
1659 hddLog(VOS_TRACE_LEVEL_INFO,
1660 " %d) Channel Info"
1661 " width is %u "
1662 " CenterFreq %u "
1663 " CenterFreq0 %u "
1664 " CenterFreq1 %u "
1665 " onTime %u "
1666 " ccaBusyTime %u",
1667 i,
1668 pWifiChannelStats->channel.width,
1669 pWifiChannelStats->channel.centerFreq,
1670 pWifiChannelStats->channel.centerFreq0,
1671 pWifiChannelStats->channel.centerFreq1,
1672 pWifiChannelStats->onTime,
1673 pWifiChannelStats->ccaBusyTime);
1674
1675
1676 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301677 if(!chInfo)
1678 {
1679 hddLog(VOS_TRACE_LEVEL_ERROR,
1680 "%s: failed to put chInfo",
1681 __func__);
1682 kfree_skb(vendor_event);
1683 return;
1684 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301685
1686 if (nla_put_u32(vendor_event,
1687 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1688 pWifiChannelStats->channel.width) ||
1689 nla_put_u32(vendor_event,
1690 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1691 pWifiChannelStats->channel.centerFreq) ||
1692 nla_put_u32(vendor_event,
1693 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1694 pWifiChannelStats->channel.centerFreq0) ||
1695 nla_put_u32(vendor_event,
1696 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1697 pWifiChannelStats->channel.centerFreq1) ||
1698 nla_put_u32(vendor_event,
1699 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1700 pWifiChannelStats->onTime) ||
1701 nla_put_u32(vendor_event,
1702 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1703 pWifiChannelStats->ccaBusyTime))
1704 {
1705 hddLog(VOS_TRACE_LEVEL_ERROR,
1706 FL("cfg80211_vendor_event_alloc failed") );
1707 kfree_skb(vendor_event);
1708 return ;
1709 }
1710 nla_nest_end(vendor_event, chInfo);
1711 }
1712 nla_nest_end(vendor_event, chList);
1713
1714 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301715
1716 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301717 return;
1718}
1719
1720/*
1721 * hdd_link_layer_stats_ind_callback () - This function is called after
1722 * receiving Link Layer indications from FW.This callback converts the firmware
1723 * data to the NL data and send the same to the kernel/upper layers.
1724 */
1725static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1726 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301727 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301728{
Dino Mycled3d50022014-07-07 12:58:25 +05301729 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1730 hdd_adapter_t *pAdapter = NULL;
1731 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301732 int status;
1733
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301734 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301735
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301736 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301737 if (0 != status)
1738 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301739 return;
1740 }
1741
Dino Mycled3d50022014-07-07 12:58:25 +05301742 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1743 if (NULL == pAdapter)
1744 {
1745 hddLog(VOS_TRACE_LEVEL_ERROR,
1746 FL(" MAC address %pM does not exist with host"),
1747 macAddr);
1748 return;
1749 }
1750
Sunil Duttc69bccb2014-05-26 21:30:20 +05301751 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301752 "%s: Interface: %s LLStats indType: %d", __func__,
1753 pAdapter->dev->name, indType);
1754
Sunil Duttc69bccb2014-05-26 21:30:20 +05301755 switch (indType)
1756 {
1757 case SIR_HAL_LL_STATS_RESULTS_RSP:
1758 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301759 hddLog(VOS_TRACE_LEVEL_INFO,
1760 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1761 hddLog(VOS_TRACE_LEVEL_INFO,
1762 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1763 linkLayerStatsResults->paramId);
1764 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301765 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1766 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301767 hddLog(VOS_TRACE_LEVEL_INFO,
1768 "LL_STATS RESULTS RESPONSE respId = %u",
1769 linkLayerStatsResults->respId);
1770 hddLog(VOS_TRACE_LEVEL_INFO,
1771 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1772 linkLayerStatsResults->moreResultToFollow);
1773 hddLog(VOS_TRACE_LEVEL_INFO,
1774 "LL_STATS RESULTS RESPONSE result = %p",
1775 linkLayerStatsResults->result);
1776 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1777 {
1778 hdd_link_layer_process_radio_stats(pAdapter,
1779 (v_VOID_t *)linkLayerStatsResults->result);
1780 }
1781 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1782 {
1783 hdd_link_layer_process_iface_stats(pAdapter,
1784 (v_VOID_t *)linkLayerStatsResults->result);
1785 }
1786 else if ( linkLayerStatsResults->paramId &
1787 WMI_LINK_STATS_ALL_PEER )
1788 {
1789 hdd_link_layer_process_peer_stats(pAdapter,
1790 (v_VOID_t *)linkLayerStatsResults->result);
1791 } /* WMI_LINK_STATS_ALL_PEER */
1792 else
1793 {
1794 hddLog(VOS_TRACE_LEVEL_ERROR,
1795 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1796 }
1797
1798 break;
1799 }
1800 default:
1801 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1802 break;
1803 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301804
1805 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301806 return;
1807}
1808
1809const struct
1810nla_policy
1811qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1812{
1813 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1814 { .type = NLA_U32 },
1815 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1816 { .type = NLA_U32 },
1817};
1818
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301819static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1820 struct wireless_dev *wdev,
1821 const void *data,
1822 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301823{
1824 int status;
1825 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301826 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301827 struct net_device *dev = wdev->netdev;
1828 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1829 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Srinivas Dasari98947432014-11-07 19:41:24 +05301830 hdd_station_ctx_t *pHddStaCtx;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301831
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301832 ENTER();
1833
Sunil Duttc69bccb2014-05-26 21:30:20 +05301834 status = wlan_hdd_validate_context(pHddCtx);
1835 if (0 != status)
1836 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301837 return -EINVAL;
1838 }
1839
1840 if (NULL == pAdapter)
1841 {
1842 hddLog(VOS_TRACE_LEVEL_ERROR,
1843 FL("HDD adapter is Null"));
1844 return -ENODEV;
1845 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301846 /* check the LLStats Capability */
1847 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1848 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1849 {
1850 hddLog(VOS_TRACE_LEVEL_ERROR,
1851 FL("Link Layer Statistics not supported by Firmware"));
1852 return -EINVAL;
1853 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301854
1855 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1856 (struct nlattr *)data,
1857 data_len, qca_wlan_vendor_ll_set_policy))
1858 {
1859 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1860 return -EINVAL;
1861 }
1862 if (!tb_vendor
1863 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1864 {
1865 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1866 return -EINVAL;
1867 }
1868 if (!tb_vendor[
1869 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1870 {
1871 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1872 return -EINVAL;
1873 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301874 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301875 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301876
Dino Mycledf0a5d92014-07-04 09:41:55 +05301877 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301878 nla_get_u32(
1879 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1880
Dino Mycledf0a5d92014-07-04 09:41:55 +05301881 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301882 nla_get_u32(
1883 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1884
Dino Mycled3d50022014-07-07 12:58:25 +05301885 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1886 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301887
1888
1889 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301890 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301891 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301892 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301893 hddLog(VOS_TRACE_LEVEL_INFO,
1894 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301895 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301896 hddLog(VOS_TRACE_LEVEL_INFO,
1897 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301898 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301899
1900 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1901 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301902 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301903 {
1904 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1905 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301906 return -EINVAL;
1907
1908 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301909
1910 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1911 if (VOS_STATUS_SUCCESS !=
1912 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1913 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE))
1914 {
1915 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1916 "WLANTL_ClearInterfaceStats Failed", __func__);
1917 return -EINVAL;
1918 }
1919
1920 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1921 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1922 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1923 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1924
Sunil Duttc69bccb2014-05-26 21:30:20 +05301925 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301926 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301927 {
1928 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1929 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301930 return -EINVAL;
1931 }
1932
1933 pAdapter->isLinkLayerStatsSet = 1;
1934
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301935 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301936 return 0;
1937}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301938static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1939 struct wireless_dev *wdev,
1940 const void *data,
1941 int data_len)
1942{
1943 int ret = 0;
1944
1945 vos_ssr_protect(__func__);
1946 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1947 vos_ssr_unprotect(__func__);
1948
1949 return ret;
1950}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301951
1952const struct
1953nla_policy
1954qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1955{
1956 /* Unsigned 32bit value provided by the caller issuing the GET stats
1957 * command. When reporting
1958 * the stats results, the driver uses the same value to indicate
1959 * which GET request the results
1960 * correspond to.
1961 */
1962 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1963
1964 /* Unsigned 32bit value . bit mask to identify what statistics are
1965 requested for retrieval */
1966 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1967};
1968
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301969static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1970 struct wireless_dev *wdev,
1971 const void *data,
1972 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301973{
1974 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1975 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301976 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301977 struct net_device *dev = wdev->netdev;
1978 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1979 int status;
1980
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301981 ENTER();
1982
Sunil Duttc69bccb2014-05-26 21:30:20 +05301983 status = wlan_hdd_validate_context(pHddCtx);
1984 if (0 != status)
1985 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301986 return -EINVAL ;
1987 }
1988
1989 if (NULL == pAdapter)
1990 {
1991 hddLog(VOS_TRACE_LEVEL_FATAL,
1992 "%s: HDD adapter is Null", __func__);
1993 return -ENODEV;
1994 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301995 /* check the LLStats Capability */
1996 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1997 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1998 {
1999 hddLog(VOS_TRACE_LEVEL_ERROR,
2000 FL("Link Layer Statistics not supported by Firmware"));
2001 return -EINVAL;
2002 }
2003
Sunil Duttc69bccb2014-05-26 21:30:20 +05302004
2005 if (!pAdapter->isLinkLayerStatsSet)
2006 {
2007 hddLog(VOS_TRACE_LEVEL_FATAL,
2008 "%s: isLinkLayerStatsSet : %d",
2009 __func__, pAdapter->isLinkLayerStatsSet);
2010 return -EINVAL;
2011 }
2012
2013 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2014 (struct nlattr *)data,
2015 data_len, qca_wlan_vendor_ll_get_policy))
2016 {
2017 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2018 return -EINVAL;
2019 }
2020
2021 if (!tb_vendor
2022 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2023 {
2024 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2025 return -EINVAL;
2026 }
2027
2028 if (!tb_vendor
2029 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2030 {
2031 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2032 return -EINVAL;
2033 }
2034
Sunil Duttc69bccb2014-05-26 21:30:20 +05302035
Dino Mycledf0a5d92014-07-04 09:41:55 +05302036 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302037 nla_get_u32( tb_vendor[
2038 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302039 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302040 nla_get_u32( tb_vendor[
2041 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2042
Dino Mycled3d50022014-07-07 12:58:25 +05302043 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2044 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302045
2046 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302047 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302048 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302049 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302050 hddLog(VOS_TRACE_LEVEL_INFO,
2051 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302052 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302053
2054 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302055 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302056 {
2057 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2058 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302059 return -EINVAL;
2060 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302061
2062 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302063 return 0;
2064}
2065
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302066static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2067 struct wireless_dev *wdev,
2068 const void *data,
2069 int data_len)
2070{
2071 int ret = 0;
2072
2073 vos_ssr_protect(__func__);
2074 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2075 vos_ssr_unprotect(__func__);
2076
2077 return ret;
2078}
2079
Sunil Duttc69bccb2014-05-26 21:30:20 +05302080const struct
2081nla_policy
2082qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2083{
2084 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2085 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2086 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2087 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2088};
2089
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302090static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2091 struct wireless_dev *wdev,
2092 const void *data,
2093 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302094{
2095 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2096 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302097 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302098 struct net_device *dev = wdev->netdev;
2099 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2100 u32 statsClearReqMask;
2101 u8 stopReq;
2102 int status;
2103
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302104 ENTER();
2105
Sunil Duttc69bccb2014-05-26 21:30:20 +05302106 status = wlan_hdd_validate_context(pHddCtx);
2107 if (0 != status)
2108 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302109 return -EINVAL;
2110 }
2111
2112 if (NULL == pAdapter)
2113 {
2114 hddLog(VOS_TRACE_LEVEL_FATAL,
2115 "%s: HDD adapter is Null", __func__);
2116 return -ENODEV;
2117 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302118 /* check the LLStats Capability */
2119 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2120 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2121 {
2122 hddLog(VOS_TRACE_LEVEL_ERROR,
2123 FL("Enable LLStats Capability"));
2124 return -EINVAL;
2125 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302126
2127 if (!pAdapter->isLinkLayerStatsSet)
2128 {
2129 hddLog(VOS_TRACE_LEVEL_FATAL,
2130 "%s: isLinkLayerStatsSet : %d",
2131 __func__, pAdapter->isLinkLayerStatsSet);
2132 return -EINVAL;
2133 }
2134
2135 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2136 (struct nlattr *)data,
2137 data_len, qca_wlan_vendor_ll_clr_policy))
2138 {
2139 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2140 return -EINVAL;
2141 }
2142
2143 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2144
2145 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2146 {
2147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2148 return -EINVAL;
2149
2150 }
2151
Sunil Duttc69bccb2014-05-26 21:30:20 +05302152
Dino Mycledf0a5d92014-07-04 09:41:55 +05302153 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302154 nla_get_u32(
2155 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2156
Dino Mycledf0a5d92014-07-04 09:41:55 +05302157 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302158 nla_get_u8(
2159 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2160
2161 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302162 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302163
Dino Mycled3d50022014-07-07 12:58:25 +05302164 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2165 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302166
2167 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302168 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302169 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302170 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302171 hddLog(VOS_TRACE_LEVEL_INFO,
2172 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302173 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302174 hddLog(VOS_TRACE_LEVEL_INFO,
2175 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302176 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302177
2178 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302179 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302180 {
2181 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302182 hdd_station_ctx_t *pHddStaCtx;
2183
2184 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2185 if (VOS_STATUS_SUCCESS !=
2186 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2187 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2188 {
2189 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2190 "WLANTL_ClearInterfaceStats Failed", __func__);
2191 return -EINVAL;
2192 }
2193 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2194 (statsClearReqMask & WIFI_STATS_IFACE)) {
2195 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2196 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2197 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2198 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2199 }
2200
Sunil Duttc69bccb2014-05-26 21:30:20 +05302201 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2202 2 * sizeof(u32) +
2203 NLMSG_HDRLEN);
2204
2205 if (temp_skbuff != NULL)
2206 {
2207
2208 if (nla_put_u32(temp_skbuff,
2209 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2210 statsClearReqMask) ||
2211 nla_put_u32(temp_skbuff,
2212 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2213 stopReq))
2214 {
2215 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2216 kfree_skb(temp_skbuff);
2217 return -EINVAL;
2218 }
2219 /* If the ask is to stop the stats collection as part of clear
2220 * (stopReq = 1) , ensure that no further requests of get
2221 * go to the firmware by having isLinkLayerStatsSet set to 0.
2222 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302223 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302224 * case the firmware is just asked to clear the statistics.
2225 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302226 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302227 pAdapter->isLinkLayerStatsSet = 0;
2228 return cfg80211_vendor_cmd_reply(temp_skbuff);
2229 }
2230 return -ENOMEM;
2231 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302232
2233 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302234 return -EINVAL;
2235}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302236static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2237 struct wireless_dev *wdev,
2238 const void *data,
2239 int data_len)
2240{
2241 int ret = 0;
2242
2243 vos_ssr_protect(__func__);
2244 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2245 vos_ssr_unprotect(__func__);
2246
2247 return ret;
2248
2249
2250}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302251#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2252
Dino Mycle6fb96c12014-06-10 11:52:40 +05302253#ifdef WLAN_FEATURE_EXTSCAN
2254static const struct nla_policy
2255wlan_hdd_extscan_config_policy
2256 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2257{
2258 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2259 { .type = NLA_U32 },
2260 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2261 { .type = NLA_U32 },
2262 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2263 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2264 { .type = NLA_U32 },
2265 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2266 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2267
2268 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2269 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2270 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2271 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2272 { .type = NLA_U8 },
2273 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2274 { .type = NLA_U32 },
2275 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2276 { .type = NLA_U32 },
2277 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2278 { .type = NLA_U32 },
2279 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2280 { .type = NLA_U8 },
2281 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2282 { .type = NLA_U8 },
2283 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2284 { .type = NLA_U8 },
2285
2286 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2287 { .type = NLA_U32 },
2288 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2289 { .type = NLA_UNSPEC },
2290 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2291 { .type = NLA_S32 },
2292 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2293 { .type = NLA_S32 },
2294 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2295 { .type = NLA_U32 },
2296 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2297 { .type = NLA_U32 },
2298 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2299 { .type = NLA_U32 },
2300 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2301 = { .type = NLA_U32 },
2302 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2303 { .type = NLA_U32 },
2304 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2305 NLA_U32 },
2306};
2307
2308static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2309{
2310 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2311 struct sk_buff *skb = NULL;
2312 tpSirEXTScanCapabilitiesEvent pData =
2313 (tpSirEXTScanCapabilitiesEvent) pMsg;
2314
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302315 ENTER();
2316
2317 if (wlan_hdd_validate_context(pHddCtx))
2318 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302319 return;
2320 }
2321
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302322 if (!pMsg)
2323 {
2324 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2325 return;
2326 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302327 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2328 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2329 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2330 GFP_KERNEL);
2331
2332 if (!skb) {
2333 hddLog(VOS_TRACE_LEVEL_ERROR,
2334 FL("cfg80211_vendor_event_alloc failed"));
2335 return;
2336 }
2337
2338 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2339 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2340 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2341 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2342 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2343 pData->maxRssiSampleSize);
2344 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2345 pData->maxScanReportingThreshold);
2346 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2347 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2348 pData->maxSignificantWifiChangeAPs);
2349 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2350 pData->maxBsidHistoryEntries);
2351
2352 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2353 pData->requestId) ||
2354 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2355 nla_put_u32(skb,
2356 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2357 pData->scanCacheSize) ||
2358 nla_put_u32(skb,
2359 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2360 pData->scanBuckets) ||
2361 nla_put_u32(skb,
2362 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2363 pData->maxApPerScan) ||
2364 nla_put_u32(skb,
2365 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2366 pData->maxRssiSampleSize) ||
2367 nla_put_u32(skb,
2368 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2369 pData->maxScanReportingThreshold) ||
2370 nla_put_u32(skb,
2371 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2372 pData->maxHotlistAPs) ||
2373 nla_put_u32(skb,
2374 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2375 pData->maxSignificantWifiChangeAPs) ||
2376 nla_put_u32(skb,
2377 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2378 pData->maxBsidHistoryEntries)) {
2379 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2380 goto nla_put_failure;
2381 }
2382
2383 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302384 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302385 return;
2386
2387nla_put_failure:
2388 kfree_skb(skb);
2389 return;
2390}
2391
2392
2393static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2394{
2395 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2396 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2397 struct sk_buff *skb = NULL;
2398 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2399
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302400 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302401
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302402 if (wlan_hdd_validate_context(pHddCtx)){
2403 return;
2404 }
2405 if (!pMsg)
2406 {
2407 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302408 return;
2409 }
2410
2411 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2412 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2413 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2414 GFP_KERNEL);
2415
2416 if (!skb) {
2417 hddLog(VOS_TRACE_LEVEL_ERROR,
2418 FL("cfg80211_vendor_event_alloc failed"));
2419 return;
2420 }
2421 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2422 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2423 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2424
2425 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2426 pData->requestId) ||
2427 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2428 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2429 goto nla_put_failure;
2430 }
2431
2432 /*
2433 * Store the Request ID for comparing with the requestID obtained
2434 * in other requests.HDD shall return a failure is the extscan_stop
2435 * request is issued with a different requestId as that of the
2436 * extscan_start request. Also, This requestId shall be used while
2437 * indicating the full scan results to the upper layers.
2438 * The requestId is stored with the assumption that the firmware
2439 * shall return the ext scan start request's requestId in ext scan
2440 * start response.
2441 */
2442 if (pData->status == 0)
2443 pMac->sme.extScanStartReqId = pData->requestId;
2444
2445
2446 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302447 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302448 return;
2449
2450nla_put_failure:
2451 kfree_skb(skb);
2452 return;
2453}
2454
2455
2456static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2457{
2458 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2459 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2460 struct sk_buff *skb = NULL;
2461
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302462 ENTER();
2463
2464 if (wlan_hdd_validate_context(pHddCtx)){
2465 return;
2466 }
2467 if (!pMsg)
2468 {
2469 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302470 return;
2471 }
2472
2473 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2474 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2475 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2476 GFP_KERNEL);
2477
2478 if (!skb) {
2479 hddLog(VOS_TRACE_LEVEL_ERROR,
2480 FL("cfg80211_vendor_event_alloc failed"));
2481 return;
2482 }
2483 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2484 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2485
2486 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2487 pData->requestId) ||
2488 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2489 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2490 goto nla_put_failure;
2491 }
2492
2493 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302494 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302495 return;
2496
2497nla_put_failure:
2498 kfree_skb(skb);
2499 return;
2500}
2501
2502
2503static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2504 void *pMsg)
2505{
2506 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2507 struct sk_buff *skb = NULL;
2508 tpSirEXTScanSetBssidHotListRspParams pData =
2509 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2510
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302511 ENTER();
2512
2513 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302514 return;
2515 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302516 if (!pMsg)
2517 {
2518 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2519 return;
2520 }
2521
Dino Mycle6fb96c12014-06-10 11:52:40 +05302522 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2523 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2524 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2525 GFP_KERNEL);
2526
2527 if (!skb) {
2528 hddLog(VOS_TRACE_LEVEL_ERROR,
2529 FL("cfg80211_vendor_event_alloc failed"));
2530 return;
2531 }
2532 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2533 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2534 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2535
2536 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2537 pData->requestId) ||
2538 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2539 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2540 goto nla_put_failure;
2541 }
2542
2543 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302544 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302545 return;
2546
2547nla_put_failure:
2548 kfree_skb(skb);
2549 return;
2550}
2551
2552static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2553 void *pMsg)
2554{
2555 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2556 struct sk_buff *skb = NULL;
2557 tpSirEXTScanResetBssidHotlistRspParams pData =
2558 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2559
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302560 ENTER();
2561
2562 if (wlan_hdd_validate_context(pHddCtx)) {
2563 return;
2564 }
2565 if (!pMsg)
2566 {
2567 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302568 return;
2569 }
2570
2571 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2572 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2573 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2574 GFP_KERNEL);
2575
2576 if (!skb) {
2577 hddLog(VOS_TRACE_LEVEL_ERROR,
2578 FL("cfg80211_vendor_event_alloc failed"));
2579 return;
2580 }
2581 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2582 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2583
2584 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2585 pData->requestId) ||
2586 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2587 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2588 goto nla_put_failure;
2589 }
2590
2591 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302592 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302593 return;
2594
2595nla_put_failure:
2596 kfree_skb(skb);
2597 return;
2598}
2599
2600
2601static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2602 void *pMsg)
2603{
2604 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2605 struct sk_buff *skb = NULL;
2606 tpSirEXTScanSetSignificantChangeRspParams pData =
2607 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2608
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302609 ENTER();
2610
2611 if (wlan_hdd_validate_context(pHddCtx)) {
2612 return;
2613 }
2614 if (!pMsg)
2615 {
2616 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302617 return;
2618 }
2619
2620 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2621 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2622 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2623 GFP_KERNEL);
2624
2625 if (!skb) {
2626 hddLog(VOS_TRACE_LEVEL_ERROR,
2627 FL("cfg80211_vendor_event_alloc failed"));
2628 return;
2629 }
2630 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2631 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2632 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2633
2634 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2635 pData->requestId) ||
2636 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2637 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2638 goto nla_put_failure;
2639 }
2640
2641 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302642 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302643 return;
2644
2645nla_put_failure:
2646 kfree_skb(skb);
2647 return;
2648}
2649
2650
2651static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2652 void *pMsg)
2653{
2654 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2655 struct sk_buff *skb = NULL;
2656 tpSirEXTScanResetSignificantChangeRspParams pData =
2657 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2658
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302659 ENTER();
2660
2661 if (wlan_hdd_validate_context(pHddCtx)) {
2662 return;
2663 }
2664 if (!pMsg)
2665 {
2666 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302667 return;
2668 }
2669
2670 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2671 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2672 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2673 GFP_KERNEL);
2674
2675 if (!skb) {
2676 hddLog(VOS_TRACE_LEVEL_ERROR,
2677 FL("cfg80211_vendor_event_alloc failed"));
2678 return;
2679 }
2680 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2681 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2682 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2683
2684 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2685 pData->requestId) ||
2686 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2687 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2688 goto nla_put_failure;
2689 }
2690
2691 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302692 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302693 return;
2694
2695nla_put_failure:
2696 kfree_skb(skb);
2697 return;
2698}
2699
2700static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2701 void *pMsg)
2702{
2703 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2704 struct sk_buff *skb = NULL;
2705 tANI_U32 i = 0, j, resultsPerEvent;
2706 tANI_S32 totalResults;
2707 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2708 tpSirWifiScanResult pSirWifiScanResult;
2709
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302710 ENTER();
2711
2712 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302713 return;
2714 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302715 if (!pMsg)
2716 {
2717 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2718 return;
2719 }
2720
Dino Mycle6fb96c12014-06-10 11:52:40 +05302721 totalResults = pData->numOfAps;
2722 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2723 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2724 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2725
2726 do{
2727 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2728 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2729 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2730
2731 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2732 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2733 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2734 GFP_KERNEL);
2735
2736 if (!skb) {
2737 hddLog(VOS_TRACE_LEVEL_ERROR,
2738 FL("cfg80211_vendor_event_alloc failed"));
2739 return;
2740 }
2741
2742 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2743
2744 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2745 pData->requestId) ||
2746 nla_put_u32(skb,
2747 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2748 resultsPerEvent)) {
2749 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2750 goto fail;
2751 }
2752 if (nla_put_u8(skb,
2753 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2754 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2755 {
2756 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2757 goto fail;
2758 }
2759
2760 if (resultsPerEvent) {
2761 struct nlattr *aps;
2762
2763 aps = nla_nest_start(skb,
2764 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2765 if (!aps)
2766 {
2767 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2768 goto fail;
2769 }
2770
2771 for (j = 0; j < resultsPerEvent; j++, i++) {
2772 struct nlattr *ap;
2773 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2774 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2775
2776 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2777 "Ssid (%s)"
2778 "Bssid: %pM "
2779 "Channel (%u)"
2780 "Rssi (%d)"
2781 "RTT (%u)"
2782 "RTT_SD (%u)",
2783 i,
2784 pSirWifiScanResult->ts,
2785 pSirWifiScanResult->ssid,
2786 pSirWifiScanResult->bssid,
2787 pSirWifiScanResult->channel,
2788 pSirWifiScanResult->rssi,
2789 pSirWifiScanResult->rtt,
2790 pSirWifiScanResult->rtt_sd);
2791
2792 ap = nla_nest_start(skb, j + 1);
2793 if (!ap)
2794 {
2795 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2796 goto fail;
2797 }
2798
2799 if (nla_put_u64(skb,
2800 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2801 pSirWifiScanResult->ts) )
2802 {
2803 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2804 goto fail;
2805 }
2806 if (nla_put(skb,
2807 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2808 sizeof(pSirWifiScanResult->ssid),
2809 pSirWifiScanResult->ssid) )
2810 {
2811 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2812 goto fail;
2813 }
2814 if (nla_put(skb,
2815 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2816 sizeof(pSirWifiScanResult->bssid),
2817 pSirWifiScanResult->bssid) )
2818 {
2819 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2820 goto fail;
2821 }
2822 if (nla_put_u32(skb,
2823 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2824 pSirWifiScanResult->channel) )
2825 {
2826 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2827 goto fail;
2828 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302829 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302830 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2831 pSirWifiScanResult->rssi) )
2832 {
2833 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2834 goto fail;
2835 }
2836 if (nla_put_u32(skb,
2837 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2838 pSirWifiScanResult->rtt) )
2839 {
2840 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2841 goto fail;
2842 }
2843 if (nla_put_u32(skb,
2844 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2845 pSirWifiScanResult->rtt_sd))
2846 {
2847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2848 goto fail;
2849 }
2850
2851 nla_nest_end(skb, ap);
2852 }
2853 nla_nest_end(skb, aps);
2854
2855 }
2856 cfg80211_vendor_event(skb, GFP_KERNEL);
2857 } while (totalResults > 0);
2858
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302859 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302860 return;
2861fail:
2862 kfree_skb(skb);
2863 return;
2864}
2865
2866static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2867 void *pMsg)
2868{
2869 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2870 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2871 struct sk_buff *skb = NULL;
2872 tANI_U32 i;
2873
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302874 ENTER();
2875
2876 if (wlan_hdd_validate_context(pHddCtx)) {
2877 return;
2878 }
2879 if (!pMsg)
2880 {
2881 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302882 return;
2883 }
2884
2885 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2886 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2887 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2888 GFP_KERNEL);
2889
2890 if (!skb) {
2891 hddLog(VOS_TRACE_LEVEL_ERROR,
2892 FL("cfg80211_vendor_event_alloc failed"));
2893 return;
2894 }
2895 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2896 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2897 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2898 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2899
2900 for (i = 0; i < pData->numOfAps; i++) {
2901 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2902 "Ssid (%s) "
2903 "Bssid (" MAC_ADDRESS_STR ") "
2904 "Channel (%u) "
2905 "Rssi (%d) "
2906 "RTT (%u) "
2907 "RTT_SD (%u) ",
2908 i,
2909 pData->ap[i].ts,
2910 pData->ap[i].ssid,
2911 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2912 pData->ap[i].channel,
2913 pData->ap[i].rssi,
2914 pData->ap[i].rtt,
2915 pData->ap[i].rtt_sd);
2916 }
2917
2918 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2919 pData->requestId) ||
2920 nla_put_u32(skb,
2921 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2922 pData->numOfAps)) {
2923 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2924 goto fail;
2925 }
2926 if (pData->numOfAps) {
2927 struct nlattr *aps;
2928
2929 aps = nla_nest_start(skb,
2930 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2931 if (!aps)
2932 goto fail;
2933
2934 for (i = 0; i < pData->numOfAps; i++) {
2935 struct nlattr *ap;
2936
2937 ap = nla_nest_start(skb, i + 1);
2938 if (!ap)
2939 goto fail;
2940
2941 if (nla_put_u64(skb,
2942 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2943 pData->ap[i].ts) ||
2944 nla_put(skb,
2945 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2946 sizeof(pData->ap[i].ssid),
2947 pData->ap[i].ssid) ||
2948 nla_put(skb,
2949 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2950 sizeof(pData->ap[i].bssid),
2951 pData->ap[i].bssid) ||
2952 nla_put_u32(skb,
2953 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2954 pData->ap[i].channel) ||
2955 nla_put_s32(skb,
2956 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2957 pData->ap[i].rssi) ||
2958 nla_put_u32(skb,
2959 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2960 pData->ap[i].rtt) ||
2961 nla_put_u32(skb,
2962 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2963 pData->ap[i].rtt_sd))
2964 goto fail;
2965
2966 nla_nest_end(skb, ap);
2967 }
2968 nla_nest_end(skb, aps);
2969
2970 if (nla_put_u8(skb,
2971 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2972 pData->moreData))
2973 goto fail;
2974 }
2975
2976 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302977 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302978 return;
2979
2980fail:
2981 kfree_skb(skb);
2982 return;
2983
2984}
2985static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
2986 void *pMsg)
2987{
2988 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2989 struct sk_buff *skb = NULL;
2990 tANI_U32 i, j;
2991 tpSirWifiSignificantChangeEvent pData =
2992 (tpSirWifiSignificantChangeEvent) pMsg;
2993
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302994 ENTER();
2995
2996 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302997 return;
2998 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302999 if (!pMsg)
3000 {
3001 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3002 return;
3003 }
3004
Dino Mycle6fb96c12014-06-10 11:52:40 +05303005 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3006 EXTSCAN_EVENT_BUF_SIZE,
3007 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3008 GFP_KERNEL);
3009
3010 if (!skb) {
3011 hddLog(VOS_TRACE_LEVEL_ERROR,
3012 FL("cfg80211_vendor_event_alloc failed"));
3013 return;
3014 }
3015 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3016 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3017 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3018 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3019 pData->numSigRssiBss);
3020 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3021
3022 for (i = 0; i < pData->numSigRssiBss; i++) {
3023 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3024 " num RSSI %u ",
3025 i, pData->sigRssiResult[i].bssid,
3026 pData->sigRssiResult[i].channel,
3027 pData->sigRssiResult[i].numRssi);
3028
3029 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3030
3031 hddLog(VOS_TRACE_LEVEL_INFO,
3032 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303033 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303034
3035 }
3036 }
3037
3038
3039 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3040 pData->requestId) ||
3041 nla_put_u32(skb,
3042 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3043 pData->numSigRssiBss)) {
3044 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3045 goto fail;
3046 }
3047
3048 if (pData->numSigRssiBss) {
3049 struct nlattr *aps;
3050 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3051 if (!aps)
3052 goto fail;
3053 for (i = 0; i < pData->numSigRssiBss; i++) {
3054 struct nlattr *ap;
3055
3056 ap = nla_nest_start(skb, i);
3057 if (!ap)
3058 goto fail;
3059 if (nla_put(skb,
3060 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3061 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3062 nla_put_u32(skb,
3063 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3064 pData->sigRssiResult[i].channel) ||
3065 nla_put_u32(skb,
3066 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3067 pData->sigRssiResult[i].numRssi) ||
3068 nla_put(skb,
3069 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3070 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3071 pData->sigRssiResult[i].rssi))
3072 goto fail;
3073 nla_nest_end(skb, ap);
3074 }
3075 nla_nest_end(skb, aps);
3076 if (nla_put_u8(skb,
3077 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3078 pData->moreData))
3079 goto fail;
3080 }
3081 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303082 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303083 return;
3084fail:
3085 kfree_skb(skb);
3086 return;
3087}
3088
3089static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3090 void *pMsg)
3091{
3092 struct sk_buff *skb;
3093 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3094 tpSirWifiFullScanResultEvent pData =
3095 (tpSirWifiFullScanResultEvent) (pMsg);
3096
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303097 ENTER();
3098
3099 if (wlan_hdd_validate_context(pHddCtx)) {
3100 return;
3101 }
3102 if (!pMsg)
3103 {
3104 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303105 return;
3106 }
3107
3108 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3109 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3110 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3111 GFP_KERNEL);
3112
3113 if (!skb) {
3114 hddLog(VOS_TRACE_LEVEL_ERROR,
3115 FL("cfg80211_vendor_event_alloc failed"));
3116 return;
3117 }
3118
3119 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3120 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3121 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3122 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3123 "Ssid (%s)"
3124 "Bssid (" MAC_ADDRESS_STR ")"
3125 "Channel (%u)"
3126 "Rssi (%d)"
3127 "RTT (%u)"
3128 "RTT_SD (%u)"),
3129 pData->ap.ts,
3130 pData->ap.ssid,
3131 MAC_ADDR_ARRAY(pData->ap.bssid),
3132 pData->ap.channel,
3133 pData->ap.rssi,
3134 pData->ap.rtt,
3135 pData->ap.rtt_sd);
3136 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3137 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3138 pData->requestId) ||
3139 nla_put_u64(skb,
3140 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3141 pData->ap.ts) ||
3142 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3143 sizeof(pData->ap.ssid),
3144 pData->ap.ssid) ||
3145 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3146 WNI_CFG_BSSID_LEN,
3147 pData->ap.bssid) ||
3148 nla_put_u32(skb,
3149 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3150 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303151 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303152 pData->ap.rssi) ||
3153 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3154 pData->ap.rtt) ||
3155 nla_put_u32(skb,
3156 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3157 pData->ap.rtt_sd) ||
3158 nla_put_u16(skb,
3159 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3160 pData->ap.beaconPeriod) ||
3161 nla_put_u16(skb,
3162 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3163 pData->ap.capability) ||
3164 nla_put_u32(skb,
3165 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3166 pData->ieLength))
3167 {
3168 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3169 goto nla_put_failure;
3170 }
3171 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3172 pData->ieLength,
3173 pData->ie))
3174 {
3175 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3176 goto nla_put_failure;
3177 }
3178
3179 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303180 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303181 return;
3182
3183nla_put_failure:
3184 kfree_skb(skb);
3185 return;
3186}
3187
3188static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3189 void *pMsg)
3190{
3191 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3192 struct sk_buff *skb = NULL;
3193 tpSirEXTScanResultsAvailableIndParams pData =
3194 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3195
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303196 ENTER();
3197
3198 if (wlan_hdd_validate_context(pHddCtx)){
3199 return;
3200 }
3201 if (!pMsg)
3202 {
3203 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303204 return;
3205 }
3206
3207 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3208 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3209 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3210 GFP_KERNEL);
3211
3212 if (!skb) {
3213 hddLog(VOS_TRACE_LEVEL_ERROR,
3214 FL("cfg80211_vendor_event_alloc failed"));
3215 return;
3216 }
3217
3218 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3219 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3220 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3221 pData->numResultsAvailable);
3222 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3223 pData->requestId) ||
3224 nla_put_u32(skb,
3225 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3226 pData->numResultsAvailable)) {
3227 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3228 goto nla_put_failure;
3229 }
3230
3231 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303232 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303233 return;
3234
3235nla_put_failure:
3236 kfree_skb(skb);
3237 return;
3238}
3239
3240static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3241{
3242 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3243 struct sk_buff *skb = NULL;
3244 tpSirEXTScanProgressIndParams pData =
3245 (tpSirEXTScanProgressIndParams) pMsg;
3246
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303247 ENTER();
3248
3249 if (wlan_hdd_validate_context(pHddCtx)){
3250 return;
3251 }
3252 if (!pMsg)
3253 {
3254 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303255 return;
3256 }
3257
3258 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3259 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3260 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3261 GFP_KERNEL);
3262
3263 if (!skb) {
3264 hddLog(VOS_TRACE_LEVEL_ERROR,
3265 FL("cfg80211_vendor_event_alloc failed"));
3266 return;
3267 }
3268 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3269 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3270 pData->extScanEventType);
3271 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3272 pData->status);
3273
3274 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3275 pData->extScanEventType) ||
3276 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303277 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3278 pData->requestId) ||
3279 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303280 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3281 pData->status)) {
3282 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3283 goto nla_put_failure;
3284 }
3285
3286 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303287 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303288 return;
3289
3290nla_put_failure:
3291 kfree_skb(skb);
3292 return;
3293}
3294
3295void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3296 void *pMsg)
3297{
3298 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3299
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303300 ENTER();
3301
Dino Mycle6fb96c12014-06-10 11:52:40 +05303302 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303303 return;
3304 }
3305
3306 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3307
3308
3309 switch(evType) {
3310 case SIR_HAL_EXTSCAN_START_RSP:
3311 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3312 break;
3313
3314 case SIR_HAL_EXTSCAN_STOP_RSP:
3315 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3316 break;
3317 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3318 /* There is no need to send this response to upper layer
3319 Just log the message */
3320 hddLog(VOS_TRACE_LEVEL_INFO,
3321 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3322 break;
3323 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3324 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3325 break;
3326
3327 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3328 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3329 break;
3330
3331 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3332 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3333 break;
3334
3335 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3336 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3337 break;
3338 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3339 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3340 break;
3341 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3342 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3343 break;
3344 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3345 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3346 break;
3347 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3348 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3349 break;
3350 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3351 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3352 break;
3353 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3354 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3355 break;
3356 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3357 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3358 break;
3359 default:
3360 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3361 break;
3362 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303363 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303364}
3365
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303366static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3367 struct wireless_dev *wdev,
3368 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303369{
Dino Myclee8843b32014-07-04 14:21:45 +05303370 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303371 struct net_device *dev = wdev->netdev;
3372 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3373 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3374 struct nlattr
3375 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3376 eHalStatus status;
3377
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303378 ENTER();
3379
Dino Mycle6fb96c12014-06-10 11:52:40 +05303380 status = wlan_hdd_validate_context(pHddCtx);
3381 if (0 != status)
3382 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303383 return -EINVAL;
3384 }
Dino Myclee8843b32014-07-04 14:21:45 +05303385 /* check the EXTScan Capability */
3386 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3387 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3388 {
3389 hddLog(VOS_TRACE_LEVEL_ERROR,
3390 FL("EXTScan not enabled/supported by Firmware"));
3391 return -EINVAL;
3392 }
3393
Dino Mycle6fb96c12014-06-10 11:52:40 +05303394 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3395 data, dataLen,
3396 wlan_hdd_extscan_config_policy)) {
3397 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3398 return -EINVAL;
3399 }
3400
3401 /* Parse and fetch request Id */
3402 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3403 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3404 return -EINVAL;
3405 }
3406
Dino Mycle6fb96c12014-06-10 11:52:40 +05303407
Dino Myclee8843b32014-07-04 14:21:45 +05303408 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303409 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303410 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303411
Dino Myclee8843b32014-07-04 14:21:45 +05303412 reqMsg.sessionId = pAdapter->sessionId;
3413 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303414
Dino Myclee8843b32014-07-04 14:21:45 +05303415 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303416 if (!HAL_STATUS_SUCCESS(status)) {
3417 hddLog(VOS_TRACE_LEVEL_ERROR,
3418 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303419 return -EINVAL;
3420 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303421 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303422 return 0;
3423}
3424
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303425static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3426 struct wireless_dev *wdev,
3427 const void *data, int dataLen)
3428{
3429 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303430
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303431 vos_ssr_protect(__func__);
3432 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3433 vos_ssr_unprotect(__func__);
3434
3435 return ret;
3436}
3437
3438static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3439 struct wireless_dev *wdev,
3440 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303441{
Dino Myclee8843b32014-07-04 14:21:45 +05303442 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303443 struct net_device *dev = wdev->netdev;
3444 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3445 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3446 struct nlattr
3447 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3448 eHalStatus status;
3449
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303450 ENTER();
3451
Dino Mycle6fb96c12014-06-10 11:52:40 +05303452 status = wlan_hdd_validate_context(pHddCtx);
3453 if (0 != status)
3454 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303455 return -EINVAL;
3456 }
Dino Myclee8843b32014-07-04 14:21:45 +05303457 /* check the EXTScan Capability */
3458 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3459 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3460 {
3461 hddLog(VOS_TRACE_LEVEL_ERROR,
3462 FL("EXTScan not enabled/supported by Firmware"));
3463 return -EINVAL;
3464 }
3465
Dino Mycle6fb96c12014-06-10 11:52:40 +05303466 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3467 data, dataLen,
3468 wlan_hdd_extscan_config_policy)) {
3469 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3470 return -EINVAL;
3471 }
3472 /* Parse and fetch request Id */
3473 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3474 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3475 return -EINVAL;
3476 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303477
Dino Myclee8843b32014-07-04 14:21:45 +05303478 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303479 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3480
Dino Myclee8843b32014-07-04 14:21:45 +05303481 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303482
Dino Myclee8843b32014-07-04 14:21:45 +05303483 reqMsg.sessionId = pAdapter->sessionId;
3484 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303485
3486 /* Parse and fetch flush parameter */
3487 if (!tb
3488 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3489 {
3490 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3491 goto failed;
3492 }
Dino Myclee8843b32014-07-04 14:21:45 +05303493 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303494 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3495
Dino Myclee8843b32014-07-04 14:21:45 +05303496 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303497
Dino Myclee8843b32014-07-04 14:21:45 +05303498 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303499 if (!HAL_STATUS_SUCCESS(status)) {
3500 hddLog(VOS_TRACE_LEVEL_ERROR,
3501 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303502 return -EINVAL;
3503 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303504 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303505 return 0;
3506
3507failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303508 return -EINVAL;
3509}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303510static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3511 struct wireless_dev *wdev,
3512 const void *data, int dataLen)
3513{
3514 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303515
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303516 vos_ssr_protect(__func__);
3517 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3518 vos_ssr_unprotect(__func__);
3519
3520 return ret;
3521}
3522
3523static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303524 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303525 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303526{
3527 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3528 struct net_device *dev = wdev->netdev;
3529 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3530 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3531 struct nlattr
3532 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3533 struct nlattr
3534 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3535 struct nlattr *apTh;
3536 eHalStatus status;
3537 tANI_U8 i = 0;
3538 int rem;
3539
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303540 ENTER();
3541
Dino Mycle6fb96c12014-06-10 11:52:40 +05303542 status = wlan_hdd_validate_context(pHddCtx);
3543 if (0 != status)
3544 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303545 return -EINVAL;
3546 }
Dino Myclee8843b32014-07-04 14:21:45 +05303547 /* check the EXTScan Capability */
3548 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3549 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3550 {
3551 hddLog(VOS_TRACE_LEVEL_ERROR,
3552 FL("EXTScan not enabled/supported by Firmware"));
3553 return -EINVAL;
3554 }
3555
Dino Mycle6fb96c12014-06-10 11:52:40 +05303556 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3557 data, dataLen,
3558 wlan_hdd_extscan_config_policy)) {
3559 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3560 return -EINVAL;
3561 }
3562
3563 /* Parse and fetch request Id */
3564 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3565 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3566 return -EINVAL;
3567 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303568 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3569 vos_mem_malloc(sizeof(*pReqMsg));
3570 if (!pReqMsg) {
3571 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3572 return -ENOMEM;
3573 }
3574
Dino Myclee8843b32014-07-04 14:21:45 +05303575
Dino Mycle6fb96c12014-06-10 11:52:40 +05303576 pReqMsg->requestId = nla_get_u32(
3577 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3578 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3579
3580 /* Parse and fetch number of APs */
3581 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3582 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3583 goto fail;
3584 }
3585
3586 pReqMsg->sessionId = pAdapter->sessionId;
3587 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3588
3589 pReqMsg->numAp = nla_get_u32(
3590 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3591 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3592
3593 nla_for_each_nested(apTh,
3594 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3595 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3596 nla_data(apTh), nla_len(apTh),
3597 NULL)) {
3598 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3599 goto fail;
3600 }
3601
3602 /* Parse and fetch MAC address */
3603 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3604 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3605 goto fail;
3606 }
3607 memcpy(pReqMsg->ap[i].bssid, nla_data(
3608 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3609 sizeof(tSirMacAddr));
3610 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3611
3612 /* Parse and fetch low RSSI */
3613 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3614 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3615 goto fail;
3616 }
3617 pReqMsg->ap[i].low = nla_get_s32(
3618 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3619 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3620
3621 /* Parse and fetch high RSSI */
3622 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3623 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3624 goto fail;
3625 }
3626 pReqMsg->ap[i].high = nla_get_s32(
3627 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3628 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3629 pReqMsg->ap[i].high);
3630
3631 /* Parse and fetch channel */
3632 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3633 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3634 goto fail;
3635 }
3636 pReqMsg->ap[i].channel = nla_get_u32(
3637 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3638 hddLog(VOS_TRACE_LEVEL_INFO,
3639 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3640 i++;
3641 }
3642 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3643 if (!HAL_STATUS_SUCCESS(status)) {
3644 hddLog(VOS_TRACE_LEVEL_ERROR,
3645 FL("sme_SetBssHotlist failed(err=%d)"), status);
3646 vos_mem_free(pReqMsg);
3647 return -EINVAL;
3648 }
3649
Dino Myclee8843b32014-07-04 14:21:45 +05303650 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303651 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303652 return 0;
3653
3654fail:
3655 vos_mem_free(pReqMsg);
3656 return -EINVAL;
3657}
3658
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303659static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3660 struct wireless_dev *wdev,
3661 const void *data, int dataLen)
3662{
3663 int ret = 0;
3664
3665 vos_ssr_protect(__func__);
3666 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3667 dataLen);
3668 vos_ssr_unprotect(__func__);
3669
3670 return ret;
3671}
3672
3673static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303674 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303675 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303676{
3677 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3678 struct net_device *dev = wdev->netdev;
3679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3680 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3681 struct nlattr
3682 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3683 struct nlattr
3684 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3685 struct nlattr *apTh;
3686 eHalStatus status;
3687 int i = 0;
3688 int rem;
3689
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303690 ENTER();
3691
Dino Mycle6fb96c12014-06-10 11:52:40 +05303692 status = wlan_hdd_validate_context(pHddCtx);
3693 if (0 != status)
3694 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303695 return -EINVAL;
3696 }
Dino Myclee8843b32014-07-04 14:21:45 +05303697 /* check the EXTScan Capability */
3698 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3699 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3700 {
3701 hddLog(VOS_TRACE_LEVEL_ERROR,
3702 FL("EXTScan not enabled/supported by Firmware"));
3703 return -EINVAL;
3704 }
3705
Dino Mycle6fb96c12014-06-10 11:52:40 +05303706 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3707 data, dataLen,
3708 wlan_hdd_extscan_config_policy)) {
3709 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3710 return -EINVAL;
3711 }
3712
3713 /* Parse and fetch request Id */
3714 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3715 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3716 return -EINVAL;
3717 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303718 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303719 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303720 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303721 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3722 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303723 }
3724
Dino Myclee8843b32014-07-04 14:21:45 +05303725
3726
Dino Mycle6fb96c12014-06-10 11:52:40 +05303727 pReqMsg->requestId = nla_get_u32(
3728 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3729 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3730
3731 /* Parse and fetch RSSI sample size */
3732 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3733 {
3734 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3735 goto fail;
3736 }
3737 pReqMsg->rssiSampleSize = nla_get_u32(
3738 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3739 hddLog(VOS_TRACE_LEVEL_INFO,
3740 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3741
3742 /* Parse and fetch lost AP sample size */
3743 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3744 {
3745 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3746 goto fail;
3747 }
3748 pReqMsg->lostApSampleSize = nla_get_u32(
3749 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3750 hddLog(VOS_TRACE_LEVEL_INFO,
3751 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3752 /* Parse and fetch minimum Breaching */
3753 if (!tb
3754 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3755 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3756 goto fail;
3757 }
3758 pReqMsg->minBreaching = nla_get_u32(
3759 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3760 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3761
3762 /* Parse and fetch number of APs */
3763 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3764 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3765 goto fail;
3766 }
3767 pReqMsg->numAp = nla_get_u32(
3768 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3769 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3770
3771 pReqMsg->sessionId = pAdapter->sessionId;
3772 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3773
3774 nla_for_each_nested(apTh,
3775 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3776 if(nla_parse(tb2,
3777 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3778 nla_data(apTh), nla_len(apTh),
3779 NULL)) {
3780 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3781 goto fail;
3782 }
3783
3784 /* Parse and fetch MAC address */
3785 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3786 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3787 goto fail;
3788 }
3789 memcpy(pReqMsg->ap[i].bssid, nla_data(
3790 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3791 sizeof(tSirMacAddr));
3792
3793 /* Parse and fetch low RSSI */
3794 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3795 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3796 goto fail;
3797 }
3798 pReqMsg->ap[i].low = nla_get_s32(
3799 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3800 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3801
3802 /* Parse and fetch high RSSI */
3803 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3804 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3805 goto fail;
3806 }
3807 pReqMsg->ap[i].high = nla_get_s32(
3808 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3809 hddLog(VOS_TRACE_LEVEL_INFO,
3810 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3811
3812 /* Parse and fetch channel */
3813 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3814 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3815 goto fail;
3816 }
3817 pReqMsg->ap[i].channel = nla_get_u32(
3818 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3819 hddLog(VOS_TRACE_LEVEL_INFO,
3820 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3821 i++;
3822 }
3823
3824 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3825 if (!HAL_STATUS_SUCCESS(status)) {
3826 hddLog(VOS_TRACE_LEVEL_ERROR,
3827 FL("sme_SetSignificantChange failed(err=%d)"), status);
3828 vos_mem_free(pReqMsg);
3829 return -EINVAL;
3830 }
Dino Myclee8843b32014-07-04 14:21:45 +05303831 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303832 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303833 return 0;
3834
3835fail:
3836 vos_mem_free(pReqMsg);
3837 return -EINVAL;
3838}
3839
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303840static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3841 struct wireless_dev *wdev,
3842 const void *data, int dataLen)
3843{
3844 int ret = 0;
3845
3846 vos_ssr_protect(__func__);
3847 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3848 dataLen);
3849 vos_ssr_unprotect(__func__);
3850
3851 return ret;
3852}
3853
3854static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303855 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303856 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303857{
3858 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3859 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3860 tANI_U8 numChannels = 0;
3861 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3862 tANI_U32 requestId;
3863 tWifiBand wifiBand;
3864 eHalStatus status;
3865 struct sk_buff *replySkb;
3866 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303867 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303868
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303869 ENTER();
3870
Dino Mycle6fb96c12014-06-10 11:52:40 +05303871 status = wlan_hdd_validate_context(pHddCtx);
3872 if (0 != status)
3873 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303874 return -EINVAL;
3875 }
Dino Myclee8843b32014-07-04 14:21:45 +05303876 /* check the EXTScan Capability */
3877 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3878 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3879 {
3880 hddLog(VOS_TRACE_LEVEL_ERROR,
3881 FL("EXTScan not enabled/supported by Firmware"));
3882 return -EINVAL;
3883 }
3884
Dino Mycle6fb96c12014-06-10 11:52:40 +05303885 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3886 data, dataLen,
3887 wlan_hdd_extscan_config_policy)) {
3888 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3889 return -EINVAL;
3890 }
3891
3892 /* Parse and fetch request Id */
3893 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3894 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3895 return -EINVAL;
3896 }
3897 requestId = nla_get_u32(
3898 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3899 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3900
3901 /* Parse and fetch wifi band */
3902 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3903 {
3904 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3905 return -EINVAL;
3906 }
3907 wifiBand = nla_get_u32(
3908 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3909 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3910
3911 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3912 wifiBand, ChannelList,
3913 &numChannels);
3914 if (eHAL_STATUS_SUCCESS != status) {
3915 hddLog(VOS_TRACE_LEVEL_ERROR,
3916 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3917 return -EINVAL;
3918 }
3919 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3920 for (i = 0; i < numChannels; i++)
3921 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3922
3923 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3924 sizeof(u32) * numChannels +
3925 NLMSG_HDRLEN);
3926
3927 if (!replySkb) {
3928 hddLog(VOS_TRACE_LEVEL_ERROR,
3929 FL("valid channels: buffer alloc fail"));
3930 return -EINVAL;
3931 }
3932 if (nla_put_u32(replySkb,
3933 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3934 numChannels) ||
3935 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3936 sizeof(u32) * numChannels, ChannelList)) {
3937
3938 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3939 kfree_skb(replySkb);
3940 return -EINVAL;
3941 }
3942
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303943 ret = cfg80211_vendor_cmd_reply(replySkb);
3944
3945 EXIT();
3946 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303947}
3948
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303949static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3950 struct wireless_dev *wdev,
3951 const void *data, int dataLen)
3952{
3953 int ret = 0;
3954
3955 vos_ssr_protect(__func__);
3956 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
3957 dataLen);
3958 vos_ssr_unprotect(__func__);
3959
3960 return ret;
3961}
3962
3963static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303964 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303965 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303966{
Dino Myclee8843b32014-07-04 14:21:45 +05303967 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303968 struct net_device *dev = wdev->netdev;
3969 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3970 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3971 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3972 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3973 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3974 struct nlattr *buckets;
3975 struct nlattr *channels;
3976 int rem1;
3977 int rem2;
3978 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303979 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303980
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303981 ENTER();
3982
Dino Mycle6fb96c12014-06-10 11:52:40 +05303983 status = wlan_hdd_validate_context(pHddCtx);
3984 if (0 != status)
3985 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303986 return -EINVAL;
3987 }
Dino Myclee8843b32014-07-04 14:21:45 +05303988 /* check the EXTScan Capability */
3989 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3990 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3991 {
3992 hddLog(VOS_TRACE_LEVEL_ERROR,
3993 FL("EXTScan not enabled/supported by Firmware"));
3994 return -EINVAL;
3995 }
3996
Dino Mycle6fb96c12014-06-10 11:52:40 +05303997 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3998 data, dataLen,
3999 wlan_hdd_extscan_config_policy)) {
4000 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4001 return -EINVAL;
4002 }
4003
4004 /* Parse and fetch request Id */
4005 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4006 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4007 return -EINVAL;
4008 }
4009
Dino Myclee8843b32014-07-04 14:21:45 +05304010 pReqMsg = (tpSirEXTScanStartReqParams)
4011 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304012 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304013 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4014 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304015 }
4016
4017 pReqMsg->requestId = nla_get_u32(
4018 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4019 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4020
4021 pReqMsg->sessionId = pAdapter->sessionId;
4022 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4023
4024 /* Parse and fetch base period */
4025 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4026 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4027 goto fail;
4028 }
4029 pReqMsg->basePeriod = nla_get_u32(
4030 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4031 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4032 pReqMsg->basePeriod);
4033
4034 /* Parse and fetch max AP per scan */
4035 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4036 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4037 goto fail;
4038 }
4039 pReqMsg->maxAPperScan = nla_get_u32(
4040 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4041 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4042 pReqMsg->maxAPperScan);
4043
4044 /* Parse and fetch report threshold */
4045 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4046 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4047 goto fail;
4048 }
4049 pReqMsg->reportThreshold = nla_get_u8(
4050 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4051 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4052 pReqMsg->reportThreshold);
4053
4054 /* Parse and fetch number of buckets */
4055 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4056 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4057 goto fail;
4058 }
4059 pReqMsg->numBuckets = nla_get_u8(
4060 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4061 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4062 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4063 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4064 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4065 }
4066 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4067 pReqMsg->numBuckets);
4068 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4069 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4070 goto fail;
4071 }
4072
4073 nla_for_each_nested(buckets,
4074 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4075 if(nla_parse(bucket,
4076 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4077 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4078 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4079 goto fail;
4080 }
4081
4082 /* Parse and fetch bucket spec */
4083 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4084 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4085 goto fail;
4086 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304087
4088 pReqMsg->buckets[index].bucket = nla_get_u8(
4089 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4090
4091 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4092 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304093
4094 /* Parse and fetch wifi band */
4095 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4096 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4097 goto fail;
4098 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304099 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304100 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4101 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304102 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304103
4104 /* Parse and fetch period */
4105 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4106 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4107 goto fail;
4108 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304109 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304110 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4111 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304112 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304113
4114 /* Parse and fetch report events */
4115 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4116 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4117 goto fail;
4118 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304119 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304120 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4121 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304122 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304123
4124 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304125 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4126 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304127 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4128 goto fail;
4129 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304130 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304131 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4132 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304133 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304134
4135 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4136 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4137 goto fail;
4138 }
4139
4140 j = 0;
4141 nla_for_each_nested(channels,
4142 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4143 if(nla_parse(channel,
4144 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4145 nla_data(channels), nla_len(channels),
4146 NULL)) { //wlan_hdd_extscan_config_policy here
4147 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4148 goto fail;
4149 }
4150
4151 /* Parse and fetch channel */
4152 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4153 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4154 goto fail;
4155 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304156 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304157 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4158 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304159 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304160
4161 /* Parse and fetch dwell time */
4162 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4163 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4164 goto fail;
4165 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304166 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304167 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4168 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304169 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304170
4171 /* Parse and fetch channel spec passive */
4172 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4173 hddLog(VOS_TRACE_LEVEL_ERROR,
4174 FL("attr channel spec passive failed"));
4175 goto fail;
4176 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304177 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304178 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4179 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304180 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304181 j++;
4182 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304183 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304184 }
4185 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4186 if (!HAL_STATUS_SUCCESS(status)) {
4187 hddLog(VOS_TRACE_LEVEL_ERROR,
4188 FL("sme_EXTScanStart failed(err=%d)"), status);
4189 vos_mem_free(pReqMsg);
4190 return -EINVAL;
4191 }
4192
Dino Myclee8843b32014-07-04 14:21:45 +05304193 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304194 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304195 return 0;
4196
4197fail:
4198 vos_mem_free(pReqMsg);
4199 return -EINVAL;
4200}
4201
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304202static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4203 struct wireless_dev *wdev,
4204 const void *data, int dataLen)
4205{
4206 int ret = 0;
4207
4208 vos_ssr_protect(__func__);
4209 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4210 vos_ssr_unprotect(__func__);
4211
4212 return ret;
4213}
4214
4215static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304216 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304217 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304218{
Dino Myclee8843b32014-07-04 14:21:45 +05304219 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304220 struct net_device *dev = wdev->netdev;
4221 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4222 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4223 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4224 eHalStatus status;
4225
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304226 ENTER();
4227
Dino Mycle6fb96c12014-06-10 11:52:40 +05304228 status = wlan_hdd_validate_context(pHddCtx);
4229 if (0 != status)
4230 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304231 return -EINVAL;
4232 }
Dino Myclee8843b32014-07-04 14:21:45 +05304233 /* check the EXTScan Capability */
4234 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4235 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4236 {
4237 hddLog(VOS_TRACE_LEVEL_ERROR,
4238 FL("EXTScan not enabled/supported by Firmware"));
4239 return -EINVAL;
4240 }
4241
Dino Mycle6fb96c12014-06-10 11:52:40 +05304242 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4243 data, dataLen,
4244 wlan_hdd_extscan_config_policy)) {
4245 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4246 return -EINVAL;
4247 }
4248
4249 /* Parse and fetch request Id */
4250 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4251 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4252 return -EINVAL;
4253 }
4254
Dino Myclee8843b32014-07-04 14:21:45 +05304255 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304256 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304257 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304258
Dino Myclee8843b32014-07-04 14:21:45 +05304259 reqMsg.sessionId = pAdapter->sessionId;
4260 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304261
Dino Myclee8843b32014-07-04 14:21:45 +05304262 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304263 if (!HAL_STATUS_SUCCESS(status)) {
4264 hddLog(VOS_TRACE_LEVEL_ERROR,
4265 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304266 return -EINVAL;
4267 }
4268
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304269 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304270 return 0;
4271}
4272
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304273static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4274 struct wireless_dev *wdev,
4275 const void *data, int dataLen)
4276{
4277 int ret = 0;
4278
4279 vos_ssr_protect(__func__);
4280 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4281 vos_ssr_unprotect(__func__);
4282
4283 return ret;
4284}
4285
4286static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304287 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304288 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304289{
Dino Myclee8843b32014-07-04 14:21:45 +05304290 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304291 struct net_device *dev = wdev->netdev;
4292 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4293 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4294 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4295 eHalStatus status;
4296
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304297 ENTER();
4298
Dino Mycle6fb96c12014-06-10 11:52:40 +05304299 status = wlan_hdd_validate_context(pHddCtx);
4300 if (0 != status)
4301 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304302 return -EINVAL;
4303 }
Dino Myclee8843b32014-07-04 14:21:45 +05304304 /* check the EXTScan Capability */
4305 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4306 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4307 {
4308 hddLog(VOS_TRACE_LEVEL_ERROR,
4309 FL("EXTScan not enabled/supported by Firmware"));
4310 return -EINVAL;
4311 }
4312
Dino Mycle6fb96c12014-06-10 11:52:40 +05304313 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4314 data, dataLen,
4315 wlan_hdd_extscan_config_policy)) {
4316 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4317 return -EINVAL;
4318 }
4319
4320 /* Parse and fetch request Id */
4321 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4322 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4323 return -EINVAL;
4324 }
4325
Dino Myclee8843b32014-07-04 14:21:45 +05304326 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304327 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304328 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304329
Dino Myclee8843b32014-07-04 14:21:45 +05304330 reqMsg.sessionId = pAdapter->sessionId;
4331 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304332
Dino Myclee8843b32014-07-04 14:21:45 +05304333 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304334 if (!HAL_STATUS_SUCCESS(status)) {
4335 hddLog(VOS_TRACE_LEVEL_ERROR,
4336 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304337 return -EINVAL;
4338 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304339 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304340 return 0;
4341}
4342
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304343static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4344 struct wireless_dev *wdev,
4345 const void *data, int dataLen)
4346{
4347 int ret = 0;
4348
4349 vos_ssr_protect(__func__);
4350 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4351 vos_ssr_unprotect(__func__);
4352
4353 return ret;
4354}
4355
4356static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304357 struct wiphy *wiphy,
4358 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304359 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304360{
Dino Myclee8843b32014-07-04 14:21:45 +05304361 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304362 struct net_device *dev = wdev->netdev;
4363 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4364 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4365 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4366 eHalStatus status;
4367
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304368 ENTER();
4369
Dino Mycle6fb96c12014-06-10 11:52:40 +05304370 status = wlan_hdd_validate_context(pHddCtx);
4371 if (0 != status)
4372 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304373 return -EINVAL;
4374 }
Dino Myclee8843b32014-07-04 14:21:45 +05304375 /* check the EXTScan Capability */
4376 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4377 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4378 {
4379 hddLog(VOS_TRACE_LEVEL_ERROR,
4380 FL("EXTScan not enabled/supported by Firmware"));
4381 return -EINVAL;
4382 }
4383
Dino Mycle6fb96c12014-06-10 11:52:40 +05304384 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4385 data, dataLen,
4386 wlan_hdd_extscan_config_policy)) {
4387 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4388 return -EINVAL;
4389 }
4390
4391 /* Parse and fetch request Id */
4392 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4393 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4394 return -EINVAL;
4395 }
4396
Dino Mycle6fb96c12014-06-10 11:52:40 +05304397
Dino Myclee8843b32014-07-04 14:21:45 +05304398 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304399 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304400 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304401
Dino Myclee8843b32014-07-04 14:21:45 +05304402 reqMsg.sessionId = pAdapter->sessionId;
4403 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304404
Dino Myclee8843b32014-07-04 14:21:45 +05304405 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304406 if (!HAL_STATUS_SUCCESS(status)) {
4407 hddLog(VOS_TRACE_LEVEL_ERROR,
4408 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304409 return -EINVAL;
4410 }
4411
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304412 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304413 return 0;
4414}
4415
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304416static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4417 struct wiphy *wiphy,
4418 struct wireless_dev *wdev,
4419 const void *data, int dataLen)
4420{
4421 int ret = 0;
4422
4423 vos_ssr_protect(__func__);
4424 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4425 wdev, data,
4426 dataLen);
4427 vos_ssr_unprotect(__func__);
4428
4429 return ret;
4430}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304431#endif /* WLAN_FEATURE_EXTSCAN */
4432
Atul Mittal115287b2014-07-08 13:26:33 +05304433/*EXT TDLS*/
4434static const struct nla_policy
4435wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4436{
4437 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4438 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4439 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4440 {.type = NLA_S32 },
4441 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4442 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4443
4444};
4445
4446static const struct nla_policy
4447wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4448{
4449 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4450
4451};
4452
4453static const struct nla_policy
4454wlan_hdd_tdls_config_state_change_policy[
4455 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4456{
4457 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4458 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4459 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304460 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4461 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4462 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304463
4464};
4465
4466static const struct nla_policy
4467wlan_hdd_tdls_config_get_status_policy[
4468 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4469{
4470 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4471 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4472 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304473 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4474 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4475 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304476
4477};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304478
4479static const struct nla_policy
4480wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4481{
4482 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4483};
4484
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304485static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304486 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304487 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304488 int data_len)
4489{
4490
4491 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4492 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4493
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304494 ENTER();
4495
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304496 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304497 return -EINVAL;
4498 }
4499 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
4500 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN disabled in ini"));
4501 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304502 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304503 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
4504 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN not supported by FW"));
4505 return -ENOTSUPP;
4506 }
4507
4508 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4509 data, data_len, wlan_hdd_mac_config)) {
4510 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4511 return -EINVAL;
4512 }
4513
4514 /* Parse and fetch mac address */
4515 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4517 return -EINVAL;
4518 }
4519
4520 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4521 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4522 VOS_MAC_ADDR_LAST_3_BYTES);
4523
Siddharth Bhal76972212014-10-15 16:22:51 +05304524 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4525
4526 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304527 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4528 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304529 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4530 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4531 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4532 {
4533 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4534 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4535 VOS_MAC_ADDRESS_LEN);
4536 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304537 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304538
Siddharth Bhal76972212014-10-15 16:22:51 +05304539 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4540 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304541 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4542 }
4543
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304544 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304545 return 0;
4546}
4547
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304548static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4549 struct wireless_dev *wdev,
4550 const void *data,
4551 int data_len)
4552{
4553 int ret = 0;
4554
4555 vos_ssr_protect(__func__);
4556 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4557 vos_ssr_unprotect(__func__);
4558
4559 return ret;
4560}
4561
4562static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304563 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304564 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304565 int data_len)
4566{
4567 u8 peer[6] = {0};
4568 struct net_device *dev = wdev->netdev;
4569 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4570 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4571 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4572 eHalStatus ret;
4573 tANI_S32 state;
4574 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304575 tANI_S32 global_operating_class = 0;
4576 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304577 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304578 int retVal;
4579
4580 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304581
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304582 if (!pAdapter) {
4583 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4584 return -EINVAL;
4585 }
4586
Atul Mittal115287b2014-07-08 13:26:33 +05304587 ret = wlan_hdd_validate_context(pHddCtx);
4588 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304589 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304590 return -EINVAL;
4591 }
4592 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304593 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304594 return -ENOTSUPP;
4595 }
4596 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4597 data, data_len,
4598 wlan_hdd_tdls_config_get_status_policy)) {
4599 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4600 return -EINVAL;
4601 }
4602
4603 /* Parse and fetch mac address */
4604 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4605 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4606 return -EINVAL;
4607 }
4608
4609 memcpy(peer, nla_data(
4610 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4611 sizeof(peer));
4612 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4613
4614 ret = wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
4615
4616 if (0 != ret) {
4617 hddLog(VOS_TRACE_LEVEL_ERROR,
4618 FL("get status Failed"));
4619 return -EINVAL;
4620 }
4621 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304622 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304623 NLMSG_HDRLEN);
4624
4625 if (!skb) {
4626 hddLog(VOS_TRACE_LEVEL_ERROR,
4627 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4628 return -EINVAL;
4629 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304630 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reason (%d) Status (%d) class (%d) channel (%d) peer" MAC_ADDRESS_STR),
Atul Mittal115287b2014-07-08 13:26:33 +05304631 reason,
4632 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304633 global_operating_class,
4634 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304635 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304636 if (nla_put_s32(skb,
4637 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4638 state) ||
4639 nla_put_s32(skb,
4640 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4641 reason) ||
4642 nla_put_s32(skb,
4643 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4644 global_operating_class) ||
4645 nla_put_s32(skb,
4646 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4647 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304648
4649 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4650 goto nla_put_failure;
4651 }
4652
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304653 retVal = cfg80211_vendor_cmd_reply(skb);
4654 EXIT();
4655 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304656
4657nla_put_failure:
4658 kfree_skb(skb);
4659 return -EINVAL;
4660}
4661
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304662static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4663 struct wireless_dev *wdev,
4664 const void *data,
4665 int data_len)
4666{
4667 int ret = 0;
4668
4669 vos_ssr_protect(__func__);
4670 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4671 vos_ssr_unprotect(__func__);
4672
4673 return ret;
4674}
4675
Atul Mittal115287b2014-07-08 13:26:33 +05304676static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac,
4677 tANI_S32 state,
4678 tANI_S32 reason,
4679 void *ctx)
4680{
4681 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304682 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304683 tANI_S32 global_operating_class = 0;
4684 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304685 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304686
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304687 ENTER();
4688
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304689 if (!pAdapter) {
4690 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4691 return -EINVAL;
4692 }
4693
4694 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304695 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304696 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304697 return -EINVAL;
4698 }
4699
4700 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304701 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304702 return -ENOTSUPP;
4703 }
4704 skb = cfg80211_vendor_event_alloc(
4705 pHddCtx->wiphy,
4706 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4707 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4708 GFP_KERNEL);
4709
4710 if (!skb) {
4711 hddLog(VOS_TRACE_LEVEL_ERROR,
4712 FL("cfg80211_vendor_event_alloc failed"));
4713 return -EINVAL;
4714 }
4715 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304716 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4717 reason,
4718 state,
4719 global_operating_class,
4720 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304721 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4722 MAC_ADDR_ARRAY(mac));
4723
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304724 if (nla_put(skb,
4725 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4726 VOS_MAC_ADDR_SIZE, mac) ||
4727 nla_put_s32(skb,
4728 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4729 state) ||
4730 nla_put_s32(skb,
4731 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4732 reason) ||
4733 nla_put_s32(skb,
4734 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4735 channel) ||
4736 nla_put_s32(skb,
4737 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4738 global_operating_class)
4739 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304740 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4741 goto nla_put_failure;
4742 }
4743
4744 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304745 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304746 return (0);
4747
4748nla_put_failure:
4749 kfree_skb(skb);
4750 return -EINVAL;
4751}
4752
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304753static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304754 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304755 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304756 int data_len)
4757{
4758 u8 peer[6] = {0};
4759 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304760 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4761 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4762 eHalStatus status;
4763 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304764 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304765 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304766
4767 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304768
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304769 if (!dev) {
4770 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4771 return -EINVAL;
4772 }
4773
4774 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4775 if (!pAdapter) {
4776 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4777 return -EINVAL;
4778 }
4779
Atul Mittal115287b2014-07-08 13:26:33 +05304780 status = wlan_hdd_validate_context(pHddCtx);
4781 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304782 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304783 return -EINVAL;
4784 }
4785 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304786 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304787 return -ENOTSUPP;
4788 }
4789 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4790 data, data_len,
4791 wlan_hdd_tdls_config_enable_policy)) {
4792 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4793 return -EINVAL;
4794 }
4795
4796 /* Parse and fetch mac address */
4797 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4798 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4799 return -EINVAL;
4800 }
4801
4802 memcpy(peer, nla_data(
4803 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4804 sizeof(peer));
4805 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4806
4807 /* Parse and fetch channel */
4808 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4809 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4810 return -EINVAL;
4811 }
4812 pReqMsg.channel = nla_get_s32(
4813 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4814 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4815
4816 /* Parse and fetch global operating class */
4817 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4818 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4819 return -EINVAL;
4820 }
4821 pReqMsg.global_operating_class = nla_get_s32(
4822 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4823 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4824 pReqMsg.global_operating_class);
4825
4826 /* Parse and fetch latency ms */
4827 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4828 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4829 return -EINVAL;
4830 }
4831 pReqMsg.max_latency_ms = nla_get_s32(
4832 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4833 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4834 pReqMsg.max_latency_ms);
4835
4836 /* Parse and fetch required bandwidth kbps */
4837 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4838 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4839 return -EINVAL;
4840 }
4841
4842 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4843 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4844 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4845 pReqMsg.min_bandwidth_kbps);
4846
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304847 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304848 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304849 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304850 wlan_hdd_cfg80211_exttdls_callback);
4851
4852 EXIT();
4853 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304854}
4855
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304856static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4857 struct wireless_dev *wdev,
4858 const void *data,
4859 int data_len)
4860{
4861 int ret = 0;
4862
4863 vos_ssr_protect(__func__);
4864 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4865 vos_ssr_unprotect(__func__);
4866
4867 return ret;
4868}
4869
4870static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304871 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304872 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304873 int data_len)
4874{
4875 u8 peer[6] = {0};
4876 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304877 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4878 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4879 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304880 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304881 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304882
4883 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304884
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304885 if (!dev) {
4886 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4887 return -EINVAL;
4888 }
4889
4890 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4891 if (!pAdapter) {
4892 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4893 return -EINVAL;
4894 }
4895
Atul Mittal115287b2014-07-08 13:26:33 +05304896 status = wlan_hdd_validate_context(pHddCtx);
4897 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304898 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304899 return -EINVAL;
4900 }
4901 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304902 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304903 return -ENOTSUPP;
4904 }
4905 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4906 data, data_len,
4907 wlan_hdd_tdls_config_disable_policy)) {
4908 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4909 return -EINVAL;
4910 }
4911 /* Parse and fetch mac address */
4912 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4913 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4914 return -EINVAL;
4915 }
4916
4917 memcpy(peer, nla_data(
4918 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4919 sizeof(peer));
4920 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4921
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304922 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
4923
4924 EXIT();
4925 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304926}
4927
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304928static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4929 struct wireless_dev *wdev,
4930 const void *data,
4931 int data_len)
4932{
4933 int ret = 0;
4934
4935 vos_ssr_protect(__func__);
4936 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
4937 vos_ssr_unprotect(__func__);
4938
4939 return ret;
4940}
4941
Dasari Srinivas7875a302014-09-26 17:50:57 +05304942static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304943__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05304944 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304945 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05304946{
4947 struct net_device *dev = wdev->netdev;
4948 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4949 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4950 struct sk_buff *skb = NULL;
4951 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304952 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05304953
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304954 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304955
4956 ret = wlan_hdd_validate_context(pHddCtx);
4957 if (0 != ret)
4958 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304959 return ret;
4960 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304961 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4962 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4963 fset |= WIFI_FEATURE_INFRA;
4964 }
4965
4966 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4967 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4968 fset |= WIFI_FEATURE_INFRA_5G;
4969 }
4970
4971#ifdef WLAN_FEATURE_P2P
4972 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4973 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4974 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4975 fset |= WIFI_FEATURE_P2P;
4976 }
4977#endif
4978
4979 /* Soft-AP is supported currently by default */
4980 fset |= WIFI_FEATURE_SOFT_AP;
4981
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05304982 /* HOTSPOT is a supplicant feature, enable it by default */
4983 fset |= WIFI_FEATURE_HOTSPOT;
4984
Dasari Srinivas7875a302014-09-26 17:50:57 +05304985#ifdef WLAN_FEATURE_EXTSCAN
4986 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4987 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4988 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4989 fset |= WIFI_FEATURE_EXTSCAN;
4990 }
4991#endif
4992
Dasari Srinivas7875a302014-09-26 17:50:57 +05304993 if (sme_IsFeatureSupportedByFW(NAN)) {
4994 hddLog(LOG1, FL("NAN is supported by firmware"));
4995 fset |= WIFI_FEATURE_NAN;
4996 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304997
4998 /* D2D RTT is not supported currently by default */
4999 if (sme_IsFeatureSupportedByFW(RTT)) {
5000 hddLog(LOG1, FL("RTT is supported by firmware"));
5001 fset |= WIFI_FEATURE_D2AP_RTT;
5002 }
5003
5004#ifdef FEATURE_WLAN_BATCH_SCAN
5005 if (fset & WIFI_FEATURE_EXTSCAN) {
5006 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5007 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5008 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5009 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5010 fset |= WIFI_FEATURE_BATCH_SCAN;
5011 }
5012#endif
5013
5014#ifdef FEATURE_WLAN_SCAN_PNO
5015 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5016 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5017 hddLog(LOG1, FL("PNO is supported by firmware"));
5018 fset |= WIFI_FEATURE_PNO;
5019 }
5020#endif
5021
5022 /* STA+STA is supported currently by default */
5023 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5024
5025#ifdef FEATURE_WLAN_TDLS
5026 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5027 sme_IsFeatureSupportedByFW(TDLS)) {
5028 hddLog(LOG1, FL("TDLS is supported by firmware"));
5029 fset |= WIFI_FEATURE_TDLS;
5030 }
5031
5032 /* TDLS_OFFCHANNEL is not supported currently by default */
5033#endif
5034
5035#ifdef WLAN_AP_STA_CONCURRENCY
5036 /* AP+STA concurrency is supported currently by default */
5037 fset |= WIFI_FEATURE_AP_STA;
5038#endif
5039
5040 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5041 NLMSG_HDRLEN);
5042
5043 if (!skb) {
5044 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5045 return -EINVAL;
5046 }
5047 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5048
5049 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5050 hddLog(LOGE, FL("nla put fail"));
5051 goto nla_put_failure;
5052 }
5053
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305054 ret = cfg80211_vendor_cmd_reply(skb);
5055 EXIT();
5056 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305057
5058nla_put_failure:
5059 kfree_skb(skb);
5060 return -EINVAL;
5061}
5062
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305063static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305064wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5065 struct wireless_dev *wdev,
5066 const void *data, int data_len)
5067{
5068 int ret = 0;
5069
5070 vos_ssr_protect(__func__);
5071 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5072 vos_ssr_unprotect(__func__);
5073
5074 return ret;
5075}
5076
5077static int
5078__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305079 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305080 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305081{
5082 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5083 uint8_t i, feature_sets, max_feature_sets;
5084 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5085 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305086 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5087 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305088
5089 ENTER();
5090
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305091 ret = wlan_hdd_validate_context(pHddCtx);
5092 if (0 != ret)
5093 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305094 return ret;
5095 }
5096
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305097 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5098 data, data_len, NULL)) {
5099 hddLog(LOGE, FL("Invalid ATTR"));
5100 return -EINVAL;
5101 }
5102
5103 /* Parse and fetch max feature set */
5104 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5105 hddLog(LOGE, FL("Attr max feature set size failed"));
5106 return -EINVAL;
5107 }
5108 max_feature_sets = nla_get_u32(
5109 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5110 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5111
5112 /* Fill feature combination matrix */
5113 feature_sets = 0;
5114 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5115 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5116 WIFI_FEATURE_P2P;
5117
5118 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5119 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5120 WIFI_FEATURE_SOFT_AP;
5121
5122 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5123 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5124 WIFI_FEATURE_SOFT_AP;
5125
5126 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5127 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5128 WIFI_FEATURE_SOFT_AP |
5129 WIFI_FEATURE_P2P;
5130
5131 /* Add more feature combinations here */
5132
5133 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5134 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5135 hddLog(LOG1, "Feature set matrix");
5136 for (i = 0; i < feature_sets; i++)
5137 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5138
5139 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5140 sizeof(u32) * feature_sets +
5141 NLMSG_HDRLEN);
5142
5143 if (reply_skb) {
5144 if (nla_put_u32(reply_skb,
5145 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5146 feature_sets) ||
5147 nla_put(reply_skb,
5148 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5149 sizeof(u32) * feature_sets, feature_set_matrix)) {
5150 hddLog(LOGE, FL("nla put fail"));
5151 kfree_skb(reply_skb);
5152 return -EINVAL;
5153 }
5154
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305155 ret = cfg80211_vendor_cmd_reply(reply_skb);
5156 EXIT();
5157 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305158 }
5159 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5160 return -ENOMEM;
5161
5162max_buffer_err:
5163 hddLog(LOGE, FL("Feature set max buffer size reached. feature_sets(%d) max(%d)"),
5164 feature_sets, WLAN_HDD_MAX_FEATURE_SET);
5165 return -EINVAL;
5166}
5167
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305168static int
5169wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5170 struct wireless_dev *wdev,
5171 const void *data, int data_len)
5172{
5173 int ret = 0;
5174
5175 vos_ssr_protect(__func__);
5176 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5177 data_len);
5178 vos_ssr_unprotect(__func__);
5179
5180 return ret;
5181}
5182
Agarwal Ashish738843c2014-09-25 12:27:56 +05305183static const struct nla_policy
5184wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5185 +1] =
5186{
5187 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5188};
5189
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305190static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305191 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305192 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305193 int data_len)
5194{
5195 struct net_device *dev = wdev->netdev;
5196 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5197 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5198 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5199 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5200 eHalStatus status;
5201 u32 dfsFlag = 0;
5202
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305203 ENTER();
5204
Agarwal Ashish738843c2014-09-25 12:27:56 +05305205 status = wlan_hdd_validate_context(pHddCtx);
5206 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305207 return -EINVAL;
5208 }
5209 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5210 data, data_len,
5211 wlan_hdd_set_no_dfs_flag_config_policy)) {
5212 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5213 return -EINVAL;
5214 }
5215
5216 /* Parse and fetch required bandwidth kbps */
5217 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5218 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5219 return -EINVAL;
5220 }
5221
5222 dfsFlag = nla_get_u32(
5223 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5224 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5225 dfsFlag);
5226
5227 pHddCtx->disable_dfs_flag = dfsFlag;
5228
5229 sme_disable_dfs_channel(hHal, dfsFlag);
5230 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305231
5232 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305233 return 0;
5234}
Atul Mittal115287b2014-07-08 13:26:33 +05305235
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305236static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5237 struct wireless_dev *wdev,
5238 const void *data,
5239 int data_len)
5240{
5241 int ret = 0;
5242
5243 vos_ssr_protect(__func__);
5244 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5245 vos_ssr_unprotect(__func__);
5246
5247 return ret;
5248
5249}
5250
Mukul Sharma2a271632014-10-13 14:59:01 +05305251const struct
5252nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5253{
5254 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5255 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5256};
5257
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305258static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305259 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305260{
5261
5262 u8 bssid[6] = {0};
5263 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5264 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5265 eHalStatus status = eHAL_STATUS_SUCCESS;
5266 v_U32_t isFwrRoamEnabled = FALSE;
5267 int ret;
5268
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305269 ENTER();
5270
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305271 ret = wlan_hdd_validate_context(pHddCtx);
5272 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305273 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305274 }
5275
5276 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5277 data, data_len,
5278 qca_wlan_vendor_attr);
5279 if (ret){
5280 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5281 return -EINVAL;
5282 }
5283
5284 /* Parse and fetch Enable flag */
5285 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5286 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5287 return -EINVAL;
5288 }
5289
5290 isFwrRoamEnabled = nla_get_u32(
5291 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5292
5293 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5294
5295 /* Parse and fetch bssid */
5296 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5297 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5298 return -EINVAL;
5299 }
5300
5301 memcpy(bssid, nla_data(
5302 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5303 sizeof(bssid));
5304 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5305
5306 //Update roaming
5307 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305308 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305309 return status;
5310}
5311
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305312static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5313 struct wireless_dev *wdev, const void *data, int data_len)
5314{
5315 int ret = 0;
5316
5317 vos_ssr_protect(__func__);
5318 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5319 vos_ssr_unprotect(__func__);
5320
5321 return ret;
5322}
5323
Sunil Duttc69bccb2014-05-26 21:30:20 +05305324const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5325{
Mukul Sharma2a271632014-10-13 14:59:01 +05305326 {
5327 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5328 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5329 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5330 WIPHY_VENDOR_CMD_NEED_NETDEV |
5331 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305332 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305333 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305334
5335 {
5336 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5337 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5338 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5339 WIPHY_VENDOR_CMD_NEED_NETDEV |
5340 WIPHY_VENDOR_CMD_NEED_RUNNING,
5341 .doit = wlan_hdd_cfg80211_nan_request
5342 },
5343
Sunil Duttc69bccb2014-05-26 21:30:20 +05305344#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5345 {
5346 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5347 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5348 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5349 WIPHY_VENDOR_CMD_NEED_NETDEV |
5350 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305351 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305352 },
5353
5354 {
5355 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5356 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5357 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5358 WIPHY_VENDOR_CMD_NEED_NETDEV |
5359 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305360 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305361 },
5362
5363 {
5364 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5365 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5366 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5367 WIPHY_VENDOR_CMD_NEED_NETDEV |
5368 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305369 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305370 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305371#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305372#ifdef WLAN_FEATURE_EXTSCAN
5373 {
5374 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5375 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5376 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5377 WIPHY_VENDOR_CMD_NEED_NETDEV |
5378 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305379 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305380 },
5381 {
5382 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5383 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5384 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5385 WIPHY_VENDOR_CMD_NEED_NETDEV |
5386 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305387 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305388 },
5389 {
5390 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5391 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5392 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5393 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305394 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305395 },
5396 {
5397 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5398 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5399 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5400 WIPHY_VENDOR_CMD_NEED_NETDEV |
5401 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305402 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305403 },
5404 {
5405 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5406 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5407 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5408 WIPHY_VENDOR_CMD_NEED_NETDEV |
5409 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305410 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305411 },
5412 {
5413 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5414 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5415 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5416 WIPHY_VENDOR_CMD_NEED_NETDEV |
5417 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305418 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305419 },
5420 {
5421 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5422 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5423 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5424 WIPHY_VENDOR_CMD_NEED_NETDEV |
5425 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305426 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305427 },
5428 {
5429 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5430 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5431 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5432 WIPHY_VENDOR_CMD_NEED_NETDEV |
5433 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305434 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305435 },
5436 {
5437 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5438 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5439 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5440 WIPHY_VENDOR_CMD_NEED_NETDEV |
5441 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305442 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305443 },
5444#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305445/*EXT TDLS*/
5446 {
5447 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5448 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5449 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5450 WIPHY_VENDOR_CMD_NEED_NETDEV |
5451 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305452 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305453 },
5454 {
5455 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5456 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5457 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5458 WIPHY_VENDOR_CMD_NEED_NETDEV |
5459 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305460 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305461 },
5462 {
5463 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5464 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5465 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5466 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305467 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305468 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305469 {
5470 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5471 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5472 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5473 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305474 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305475 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305476 {
5477 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5478 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5479 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5480 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305481 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305482 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305483 {
5484 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5485 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5486 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5487 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305488 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305489 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305490 {
5491 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5492 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5493 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5494 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305495 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305496 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305497};
5498
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005499/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305500static const
5501struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005502{
5503#ifdef FEATURE_WLAN_CH_AVOID
5504 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305505 .vendor_id = QCA_NL80211_VENDOR_ID,
5506 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005507 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305508#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5509#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5510 {
5511 /* Index = 1*/
5512 .vendor_id = QCA_NL80211_VENDOR_ID,
5513 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5514 },
5515 {
5516 /* Index = 2*/
5517 .vendor_id = QCA_NL80211_VENDOR_ID,
5518 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5519 },
5520 {
5521 /* Index = 3*/
5522 .vendor_id = QCA_NL80211_VENDOR_ID,
5523 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5524 },
5525 {
5526 /* Index = 4*/
5527 .vendor_id = QCA_NL80211_VENDOR_ID,
5528 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5529 },
5530 {
5531 /* Index = 5*/
5532 .vendor_id = QCA_NL80211_VENDOR_ID,
5533 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5534 },
5535 {
5536 /* Index = 6*/
5537 .vendor_id = QCA_NL80211_VENDOR_ID,
5538 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5539 },
5540#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305541#ifdef WLAN_FEATURE_EXTSCAN
5542 {
5543 .vendor_id = QCA_NL80211_VENDOR_ID,
5544 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5545 },
5546 {
5547 .vendor_id = QCA_NL80211_VENDOR_ID,
5548 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5549 },
5550 {
5551 .vendor_id = QCA_NL80211_VENDOR_ID,
5552 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5553 },
5554 {
5555 .vendor_id = QCA_NL80211_VENDOR_ID,
5556 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5557 },
5558 {
5559 .vendor_id = QCA_NL80211_VENDOR_ID,
5560 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5561 },
5562 {
5563 .vendor_id = QCA_NL80211_VENDOR_ID,
5564 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5565 },
5566 {
5567 .vendor_id = QCA_NL80211_VENDOR_ID,
5568 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5569 },
5570 {
5571 .vendor_id = QCA_NL80211_VENDOR_ID,
5572 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5573 },
5574 {
5575 .vendor_id = QCA_NL80211_VENDOR_ID,
5576 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5577 },
5578 {
5579 .vendor_id = QCA_NL80211_VENDOR_ID,
5580 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5581 },
5582 {
5583 .vendor_id = QCA_NL80211_VENDOR_ID,
5584 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5585 },
5586 {
5587 .vendor_id = QCA_NL80211_VENDOR_ID,
5588 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5589 },
5590 {
5591 .vendor_id = QCA_NL80211_VENDOR_ID,
5592 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5593 },
5594#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305595/*EXT TDLS*/
5596 {
5597 .vendor_id = QCA_NL80211_VENDOR_ID,
5598 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5599 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305600
5601 {
5602 .vendor_id = QCA_NL80211_VENDOR_ID,
5603 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5604 },
5605
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005606};
5607
Jeff Johnson295189b2012-06-20 16:38:30 -07005608/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305609 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305610 * This function is called by hdd_wlan_startup()
5611 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305612 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305614struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005615{
5616 struct wiphy *wiphy;
5617 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305618 /*
5619 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 */
5621 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5622
5623 if (!wiphy)
5624 {
5625 /* Print error and jump into err label and free the memory */
5626 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5627 return NULL;
5628 }
5629
Sunil Duttc69bccb2014-05-26 21:30:20 +05305630
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 return wiphy;
5632}
5633
5634/*
5635 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305636 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 * private ioctl to change the band value
5638 */
5639int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5640{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305641 int i, j;
5642 eNVChannelEnabledType channelEnabledState;
5643
Jeff Johnsone7245742012-09-05 17:12:55 -07005644 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305645
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305646 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305648
5649 if (NULL == wiphy->bands[i])
5650 {
5651 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5652 __func__, i);
5653 continue;
5654 }
5655
5656 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5657 {
5658 struct ieee80211_supported_band *band = wiphy->bands[i];
5659
5660 channelEnabledState = vos_nv_getChannelEnabledState(
5661 band->channels[j].hw_value);
5662
5663 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5664 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305665 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305666 continue;
5667 }
5668 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5669 {
5670 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5671 continue;
5672 }
5673
5674 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5675 NV_CHANNEL_INVALID == channelEnabledState)
5676 {
5677 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5678 }
5679 else if (NV_CHANNEL_DFS == channelEnabledState)
5680 {
5681 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5682 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5683 }
5684 else
5685 {
5686 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5687 |IEEE80211_CHAN_RADAR);
5688 }
5689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 }
5691 return 0;
5692}
5693/*
5694 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305695 * This function is called by hdd_wlan_startup()
5696 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005697 * This function is used to initialize and register wiphy structure.
5698 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305699int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005700 struct wiphy *wiphy,
5701 hdd_config_t *pCfg
5702 )
5703{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305704 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305705 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5706
Jeff Johnsone7245742012-09-05 17:12:55 -07005707 ENTER();
5708
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 /* Now bind the underlying wlan device with wiphy */
5710 set_wiphy_dev(wiphy, dev);
5711
5712 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005713
Kiet Lam6c583332013-10-14 05:37:09 +05305714#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005715 /* the flag for the other case would be initialzed in
5716 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005717 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305718#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005719
Amar Singhalfddc28c2013-09-05 13:03:40 -07005720 /* This will disable updating of NL channels from passive to
5721 * active if a beacon is received on passive channel. */
5722 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07005723
Amar Singhalfddc28c2013-09-05 13:03:40 -07005724
Amar Singhala49cbc52013-10-08 18:37:44 -07005725
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005726#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005727 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5728 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5729 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005730 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05305731 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005732#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005733
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005734#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005735 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005736#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005737 || pCfg->isFastRoamIniFeatureEnabled
5738#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005739#ifdef FEATURE_WLAN_ESE
5740 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005741#endif
5742 )
5743 {
5744 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5745 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005746#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005747#ifdef FEATURE_WLAN_TDLS
5748 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5749 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5750#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305751#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305752 if (pCfg->configPNOScanSupport)
5753 {
5754 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5755 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5756 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5757 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5758 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305759#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005760
Abhishek Singh10d85972015-04-17 10:27:23 +05305761#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5762 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5763#endif
5764
Amar Singhalfddc28c2013-09-05 13:03:40 -07005765#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005766 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5767 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005768 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005769 driver need to determine what to do with both
5770 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005771
5772 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005773#else
5774 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005775#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005776
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305777 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5778
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305779 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005780
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305781 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5782
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305784 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5787 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 | BIT(NL80211_IFTYPE_AP);
5789
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305790 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005791 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305792#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5793 if( pCfg->enableMCC )
5794 {
5795 /* Currently, supports up to two channels */
5796 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005797
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305798 if( !pCfg->allowMCCGODiffBI )
5799 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005800
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305801 }
5802 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5803 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005804#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305805 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005806
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 /* Before registering we need to update the ht capabilitied based
5808 * on ini values*/
5809 if( !pCfg->ShortGI20MhzEnable )
5810 {
5811 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5812 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5813 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5814 }
5815
5816 if( !pCfg->ShortGI40MhzEnable )
5817 {
5818 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5819 }
5820
5821 if( !pCfg->nChannelBondingMode5GHz )
5822 {
5823 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5824 }
5825
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305826 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305827 if (true == hdd_is_5g_supported(pHddCtx))
5828 {
5829 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
5830 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305831
5832 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
5833 {
5834
5835 if (NULL == wiphy->bands[i])
5836 {
5837 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5838 __func__, i);
5839 continue;
5840 }
5841
5842 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5843 {
5844 struct ieee80211_supported_band *band = wiphy->bands[i];
5845
5846 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
5847 {
5848 // Enable social channels for P2P
5849 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
5850 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5851 else
5852 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5853 continue;
5854 }
5855 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
5856 {
5857 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5858 continue;
5859 }
5860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 }
5862 /*Initialise the supported cipher suite details*/
5863 wiphy->cipher_suites = hdd_cipher_suites;
5864 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5865
5866 /*signal strength in mBm (100*dBm) */
5867 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
5868
5869#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05305870 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07005871#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005872
Sunil Duttc69bccb2014-05-26 21:30:20 +05305873 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
5874 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005875 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
5876 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
5877
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305878 EXIT();
5879 return 0;
5880}
5881
5882/* In this function we are registering wiphy. */
5883int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
5884{
5885 ENTER();
5886 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005887 if (0 > wiphy_register(wiphy))
5888 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305889 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
5891 return -EIO;
5892 }
5893
5894 EXIT();
5895 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305896}
Jeff Johnson295189b2012-06-20 16:38:30 -07005897
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305898/* In this function we are updating channel list when,
5899 regulatory domain is FCC and country code is US.
5900 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5901 As per FCC smart phone is not a indoor device.
5902 GO should not opeate on indoor channels */
5903void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5904{
5905 int j;
5906 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5907 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5908 //Default counrtycode from NV at the time of wiphy initialization.
5909 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5910 &defaultCountryCode[0]))
5911 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005912 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305913 }
5914 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5915 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305916 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5917 {
5918 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5919 return;
5920 }
5921 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5922 {
5923 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5924 // Mark UNII -1 band channel as passive
5925 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5926 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5927 }
5928 }
5929}
5930
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305931/* This function registers for all frame which supplicant is interested in */
5932void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005933{
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5935 /* Register for all P2P action, public action etc frames */
5936 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5937
Jeff Johnsone7245742012-09-05 17:12:55 -07005938 ENTER();
5939
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 /* Right now we are registering these frame when driver is getting
5941 initialized. Once we will move to 2.6.37 kernel, in which we have
5942 frame register ops, we will move this code as a part of that */
5943 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305944 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5946
5947 /* GAS Initial Response */
5948 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5949 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305950
Jeff Johnson295189b2012-06-20 16:38:30 -07005951 /* GAS Comeback Request */
5952 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5953 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5954
5955 /* GAS Comeback Response */
5956 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5957 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5958
5959 /* P2P Public Action */
5960 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305961 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 P2P_PUBLIC_ACTION_FRAME_SIZE );
5963
5964 /* P2P Action */
5965 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5966 (v_U8_t*)P2P_ACTION_FRAME,
5967 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07005968
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05305969 /* WNM BSS Transition Request frame */
5970 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5971 (v_U8_t*)WNM_BSS_ACTION_FRAME,
5972 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005973
5974 /* WNM-Notification */
5975 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5976 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5977 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005978}
5979
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305980void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005981{
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5983 /* Register for all P2P action, public action etc frames */
5984 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5985
Jeff Johnsone7245742012-09-05 17:12:55 -07005986 ENTER();
5987
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 /* Right now we are registering these frame when driver is getting
5989 initialized. Once we will move to 2.6.37 kernel, in which we have
5990 frame register ops, we will move this code as a part of that */
5991 /* GAS Initial Request */
5992
5993 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5994 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5995
5996 /* GAS Initial Response */
5997 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5998 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305999
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 /* GAS Comeback Request */
6001 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6002 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6003
6004 /* GAS Comeback Response */
6005 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6006 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6007
6008 /* P2P Public Action */
6009 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306010 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 P2P_PUBLIC_ACTION_FRAME_SIZE );
6012
6013 /* P2P Action */
6014 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6015 (v_U8_t*)P2P_ACTION_FRAME,
6016 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006017 /* WNM-Notification */
6018 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6019 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6020 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006021}
6022
6023#ifdef FEATURE_WLAN_WAPI
6024void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
6025 const u8 *mac_addr, u8 *key , int key_Len)
6026{
6027 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6028 tCsrRoamSetKey setKey;
6029 v_BOOL_t isConnected = TRUE;
6030 int status = 0;
6031 v_U32_t roamId= 0xFF;
6032 tANI_U8 *pKeyPtr = NULL;
6033 int n = 0;
6034
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306035 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6036 __func__, hdd_device_modetoString(pAdapter->device_mode),
6037 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006038
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306039 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 setKey.keyId = key_index; // Store Key ID
6041 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6042 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6043 setKey.paeRole = 0 ; // the PAE role
6044 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6045 {
6046 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6047 }
6048 else
6049 {
6050 isConnected = hdd_connIsConnected(pHddStaCtx);
6051 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6052 }
6053 setKey.keyLength = key_Len;
6054 pKeyPtr = setKey.Key;
6055 memcpy( pKeyPtr, key, key_Len);
6056
Arif Hussain6d2a3322013-11-17 19:50:10 -08006057 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 __func__, key_Len);
6059 for (n = 0 ; n < key_Len; n++)
6060 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6061 __func__,n,setKey.Key[n]);
6062
6063 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6064 if ( isConnected )
6065 {
6066 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6067 pAdapter->sessionId, &setKey, &roamId );
6068 }
6069 if ( status != 0 )
6070 {
6071 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6072 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6073 __LINE__, status );
6074 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6075 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306076 /* Need to clear any trace of key value in the memory.
6077 * Thus zero out the memory even though it is local
6078 * variable.
6079 */
6080 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006081}
6082#endif /* FEATURE_WLAN_WAPI*/
6083
6084#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306085int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 beacon_data_t **ppBeacon,
6087 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006088#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306089int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006090 beacon_data_t **ppBeacon,
6091 struct cfg80211_beacon_data *params,
6092 int dtim_period)
6093#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306094{
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 int size;
6096 beacon_data_t *beacon = NULL;
6097 beacon_data_t *old = NULL;
6098 int head_len,tail_len;
6099
Jeff Johnsone7245742012-09-05 17:12:55 -07006100 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306102 {
6103 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6104 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006105 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006107
6108 old = pAdapter->sessionCtx.ap.beacon;
6109
6110 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306111 {
6112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6113 FL("session(%d) old and new heads points to NULL"),
6114 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306116 }
6117
6118 if (params->tail && !params->tail_len)
6119 {
6120 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6121 FL("tail_len is zero but tail is not NULL"));
6122 return -EINVAL;
6123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006124
Jeff Johnson295189b2012-06-20 16:38:30 -07006125#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6126 /* Kernel 3.0 is not updating dtim_period for set beacon */
6127 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306128 {
6129 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6130 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006133#endif
6134
6135 if(params->head)
6136 head_len = params->head_len;
6137 else
6138 head_len = old->head_len;
6139
6140 if(params->tail || !old)
6141 tail_len = params->tail_len;
6142 else
6143 tail_len = old->tail_len;
6144
6145 size = sizeof(beacon_data_t) + head_len + tail_len;
6146
6147 beacon = kzalloc(size, GFP_KERNEL);
6148
6149 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306150 {
6151 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6152 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006155
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006156#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 if(params->dtim_period || !old )
6158 beacon->dtim_period = params->dtim_period;
6159 else
6160 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006161#else
6162 if(dtim_period || !old )
6163 beacon->dtim_period = dtim_period;
6164 else
6165 beacon->dtim_period = old->dtim_period;
6166#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306167
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6169 beacon->tail = beacon->head + head_len;
6170 beacon->head_len = head_len;
6171 beacon->tail_len = tail_len;
6172
6173 if(params->head) {
6174 memcpy (beacon->head,params->head,beacon->head_len);
6175 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306176 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 if(old)
6178 memcpy (beacon->head,old->head,beacon->head_len);
6179 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306180
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 if(params->tail) {
6182 memcpy (beacon->tail,params->tail,beacon->tail_len);
6183 }
6184 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306185 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 memcpy (beacon->tail,old->tail,beacon->tail_len);
6187 }
6188
6189 *ppBeacon = beacon;
6190
6191 kfree(old);
6192
6193 return 0;
6194
6195}
Jeff Johnson295189b2012-06-20 16:38:30 -07006196
6197v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
6198{
6199 int left = length;
6200 v_U8_t *ptr = pIes;
6201 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306202
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306204 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 elem_id = ptr[0];
6206 elem_len = ptr[1];
6207 left -= 2;
6208 if(elem_len > left)
6209 {
6210 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006211 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 eid,elem_len,left);
6213 return NULL;
6214 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306215 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 {
6217 return ptr;
6218 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306219
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 left -= elem_len;
6221 ptr += (elem_len + 2);
6222 }
6223 return NULL;
6224}
6225
Jeff Johnson295189b2012-06-20 16:38:30 -07006226/* Check if rate is 11g rate or not */
6227static int wlan_hdd_rate_is_11g(u8 rate)
6228{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006229 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 u8 i;
6231 for (i = 0; i < 8; i++)
6232 {
6233 if(rate == gRateArray[i])
6234 return TRUE;
6235 }
6236 return FALSE;
6237}
6238
6239/* Check for 11g rate and set proper 11g only mode */
6240static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6241 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6242{
6243 u8 i, num_rates = pIe[0];
6244
6245 pIe += 1;
6246 for ( i = 0; i < num_rates; i++)
6247 {
6248 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6249 {
6250 /* If rate set have 11g rate than change the mode to 11G */
6251 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6252 if (pIe[i] & BASIC_RATE_MASK)
6253 {
6254 /* If we have 11g rate as basic rate, it means mode
6255 is 11g only mode.
6256 */
6257 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6258 *pCheckRatesfor11g = FALSE;
6259 }
6260 }
6261 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6262 {
6263 *require_ht = TRUE;
6264 }
6265 }
6266 return;
6267}
6268
6269static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6270{
6271 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6272 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6273 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6274 u8 checkRatesfor11g = TRUE;
6275 u8 require_ht = FALSE;
6276 u8 *pIe=NULL;
6277
6278 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6279
6280 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6281 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6282 if (pIe != NULL)
6283 {
6284 pIe += 1;
6285 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6286 &pConfig->SapHw_mode);
6287 }
6288
6289 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6290 WLAN_EID_EXT_SUPP_RATES);
6291 if (pIe != NULL)
6292 {
6293
6294 pIe += 1;
6295 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6296 &pConfig->SapHw_mode);
6297 }
6298
6299 if( pConfig->channel > 14 )
6300 {
6301 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6302 }
6303
6304 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6305 WLAN_EID_HT_CAPABILITY);
6306
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306307 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 {
6309 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6310 if(require_ht)
6311 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6312 }
6313}
6314
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306315static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6316 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6317{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006318 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306319 v_U8_t *pIe = NULL;
6320 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6321
6322 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6323 pBeacon->tail, pBeacon->tail_len);
6324
6325 if (pIe)
6326 {
6327 ielen = pIe[1] + 2;
6328 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6329 {
6330 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6331 }
6332 else
6333 {
6334 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6335 return -EINVAL;
6336 }
6337 *total_ielen += ielen;
6338 }
6339 return 0;
6340}
6341
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006342static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6343 v_U8_t *genie, v_U8_t *total_ielen)
6344{
6345 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6346 int left = pBeacon->tail_len;
6347 v_U8_t *ptr = pBeacon->tail;
6348 v_U8_t elem_id, elem_len;
6349 v_U16_t ielen = 0;
6350
6351 if ( NULL == ptr || 0 == left )
6352 return;
6353
6354 while (left >= 2)
6355 {
6356 elem_id = ptr[0];
6357 elem_len = ptr[1];
6358 left -= 2;
6359 if (elem_len > left)
6360 {
6361 hddLog( VOS_TRACE_LEVEL_ERROR,
6362 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6363 elem_id, elem_len, left);
6364 return;
6365 }
6366 if (IE_EID_VENDOR == elem_id)
6367 {
6368 /* skipping the VSIE's which we don't want to include or
6369 * it will be included by existing code
6370 */
6371 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6372#ifdef WLAN_FEATURE_WFD
6373 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6374#endif
6375 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6376 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6377 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6378 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6379 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6380 {
6381 ielen = ptr[1] + 2;
6382 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6383 {
6384 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6385 *total_ielen += ielen;
6386 }
6387 else
6388 {
6389 hddLog( VOS_TRACE_LEVEL_ERROR,
6390 "IE Length is too big "
6391 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6392 elem_id, elem_len, *total_ielen);
6393 }
6394 }
6395 }
6396
6397 left -= elem_len;
6398 ptr += (elem_len + 2);
6399 }
6400 return;
6401}
6402
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006403#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006404static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6405 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006406#else
6407static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6408 struct cfg80211_beacon_data *params)
6409#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006410{
6411 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306412 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006414 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006415
6416 genie = vos_mem_malloc(MAX_GENIE_LEN);
6417
6418 if(genie == NULL) {
6419
6420 return -ENOMEM;
6421 }
6422
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306423 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6424 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306426 hddLog(LOGE,
6427 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306428 ret = -EINVAL;
6429 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 }
6431
6432#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306433 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6434 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6435 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306436 hddLog(LOGE,
6437 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306438 ret = -EINVAL;
6439 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 }
6441#endif
6442
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306443 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6444 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306446 hddLog(LOGE,
6447 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306448 ret = -EINVAL;
6449 goto done;
6450 }
6451
6452 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6453 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006454 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006456
6457 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6458 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6459 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6460 {
6461 hddLog(LOGE,
6462 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006463 ret = -EINVAL;
6464 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 }
6466
6467 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6468 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6469 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6470 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6471 ==eHAL_STATUS_FAILURE)
6472 {
6473 hddLog(LOGE,
6474 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006475 ret = -EINVAL;
6476 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006477 }
6478
6479 // Added for ProResp IE
6480 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6481 {
6482 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6483 u8 probe_rsp_ie_len[3] = {0};
6484 u8 counter = 0;
6485 /* Check Probe Resp Length if it is greater then 255 then Store
6486 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6487 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6488 Store More then 255 bytes into One Variable.
6489 */
6490 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6491 {
6492 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6493 {
6494 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6495 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6496 }
6497 else
6498 {
6499 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6500 rem_probe_resp_ie_len = 0;
6501 }
6502 }
6503
6504 rem_probe_resp_ie_len = 0;
6505
6506 if (probe_rsp_ie_len[0] > 0)
6507 {
6508 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6509 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6510 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6511 probe_rsp_ie_len[0], NULL,
6512 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6513 {
6514 hddLog(LOGE,
6515 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006516 ret = -EINVAL;
6517 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 }
6519 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6520 }
6521
6522 if (probe_rsp_ie_len[1] > 0)
6523 {
6524 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6525 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6526 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6527 probe_rsp_ie_len[1], NULL,
6528 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6529 {
6530 hddLog(LOGE,
6531 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006532 ret = -EINVAL;
6533 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006534 }
6535 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6536 }
6537
6538 if (probe_rsp_ie_len[2] > 0)
6539 {
6540 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6541 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6542 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6543 probe_rsp_ie_len[2], NULL,
6544 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6545 {
6546 hddLog(LOGE,
6547 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006548 ret = -EINVAL;
6549 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006550 }
6551 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6552 }
6553
6554 if (probe_rsp_ie_len[1] == 0 )
6555 {
6556 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6557 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6558 eANI_BOOLEAN_FALSE) )
6559 {
6560 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006561 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006562 }
6563 }
6564
6565 if (probe_rsp_ie_len[2] == 0 )
6566 {
6567 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6568 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6569 eANI_BOOLEAN_FALSE) )
6570 {
6571 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006572 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006573 }
6574 }
6575
6576 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6577 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6578 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6579 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6580 == eHAL_STATUS_FAILURE)
6581 {
6582 hddLog(LOGE,
6583 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006584 ret = -EINVAL;
6585 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006586 }
6587 }
6588 else
6589 {
6590 // Reset WNI_CFG_PROBE_RSP Flags
6591 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6592
6593 hddLog(VOS_TRACE_LEVEL_INFO,
6594 "%s: No Probe Response IE received in set beacon",
6595 __func__);
6596 }
6597
6598 // Added for AssocResp IE
6599 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6600 {
6601 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6602 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6603 params->assocresp_ies_len, NULL,
6604 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6605 {
6606 hddLog(LOGE,
6607 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006608 ret = -EINVAL;
6609 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006610 }
6611
6612 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6613 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6614 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6615 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6616 == eHAL_STATUS_FAILURE)
6617 {
6618 hddLog(LOGE,
6619 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006620 ret = -EINVAL;
6621 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006622 }
6623 }
6624 else
6625 {
6626 hddLog(VOS_TRACE_LEVEL_INFO,
6627 "%s: No Assoc Response IE received in set beacon",
6628 __func__);
6629
6630 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6631 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6632 eANI_BOOLEAN_FALSE) )
6633 {
6634 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006635 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 }
6637 }
6638
Jeff Johnsone7245742012-09-05 17:12:55 -07006639done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306641 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006642}
Jeff Johnson295189b2012-06-20 16:38:30 -07006643
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306644/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 * FUNCTION: wlan_hdd_validate_operation_channel
6646 * called by wlan_hdd_cfg80211_start_bss() and
6647 * wlan_hdd_cfg80211_set_channel()
6648 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306649 * channel list.
6650 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006651VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006652{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306653
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 v_U32_t num_ch = 0;
6655 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6656 u32 indx = 0;
6657 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306658 v_U8_t fValidChannel = FALSE, count = 0;
6659 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306660
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6662
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306663 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306665 /* Validate the channel */
6666 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306668 if ( channel == rfChannels[count].channelNum )
6669 {
6670 fValidChannel = TRUE;
6671 break;
6672 }
6673 }
6674 if (fValidChannel != TRUE)
6675 {
6676 hddLog(VOS_TRACE_LEVEL_ERROR,
6677 "%s: Invalid Channel [%d]", __func__, channel);
6678 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 }
6680 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306681 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306683 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6684 valid_ch, &num_ch))
6685 {
6686 hddLog(VOS_TRACE_LEVEL_ERROR,
6687 "%s: failed to get valid channel list", __func__);
6688 return VOS_STATUS_E_FAILURE;
6689 }
6690 for (indx = 0; indx < num_ch; indx++)
6691 {
6692 if (channel == valid_ch[indx])
6693 {
6694 break;
6695 }
6696 }
6697
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306698 if (indx >= num_ch)
6699 {
6700 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6701 {
6702 eCsrBand band;
6703 unsigned int freq;
6704
6705 sme_GetFreqBand(hHal, &band);
6706
6707 if (eCSR_BAND_5G == band)
6708 {
6709#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6710 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6711 {
6712 freq = ieee80211_channel_to_frequency(channel,
6713 IEEE80211_BAND_2GHZ);
6714 }
6715 else
6716 {
6717 freq = ieee80211_channel_to_frequency(channel,
6718 IEEE80211_BAND_5GHZ);
6719 }
6720#else
6721 freq = ieee80211_channel_to_frequency(channel);
6722#endif
6723 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6724 return VOS_STATUS_SUCCESS;
6725 }
6726 }
6727
6728 hddLog(VOS_TRACE_LEVEL_ERROR,
6729 "%s: Invalid Channel [%d]", __func__, channel);
6730 return VOS_STATUS_E_FAILURE;
6731 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306733
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306735
Jeff Johnson295189b2012-06-20 16:38:30 -07006736}
6737
Viral Modi3a32cc52013-02-08 11:14:52 -08006738/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306739 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006740 * This function is used to set the channel number
6741 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306742static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006743 struct ieee80211_channel *chan,
6744 enum nl80211_channel_type channel_type
6745 )
6746{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306747 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006748 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006749 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006750 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306751 hdd_context_t *pHddCtx;
6752 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006753
6754 ENTER();
6755
6756 if( NULL == dev )
6757 {
6758 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006759 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006760 return -ENODEV;
6761 }
6762 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306763
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306764 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6765 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6766 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006767 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306768 "%s: device_mode = %s (%d) freq = %d", __func__,
6769 hdd_device_modetoString(pAdapter->device_mode),
6770 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306771
6772 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6773 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306774 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006775 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306776 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006777 }
6778
6779 /*
6780 * Do freq to chan conversion
6781 * TODO: for 11a
6782 */
6783
6784 channel = ieee80211_frequency_to_channel(freq);
6785
6786 /* Check freq range */
6787 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6788 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6789 {
6790 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006791 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006792 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6793 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6794 return -EINVAL;
6795 }
6796
6797 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6798
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306799 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6800 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006801 {
6802 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6803 {
6804 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006805 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006806 return -EINVAL;
6807 }
6808 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6809 "%s: set channel to [%d] for device mode =%d",
6810 __func__, channel,pAdapter->device_mode);
6811 }
6812 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006813 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08006814 )
6815 {
6816 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6817 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
6818 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6819
6820 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
6821 {
6822 /* Link is up then return cant set channel*/
6823 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006824 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006825 return -EINVAL;
6826 }
6827
6828 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
6829 pHddStaCtx->conn_info.operationChannel = channel;
6830 pRoamProfile->ChannelInfo.ChannelList =
6831 &pHddStaCtx->conn_info.operationChannel;
6832 }
6833 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08006834 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08006835 )
6836 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306837 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6838 {
6839 if(VOS_STATUS_SUCCESS !=
6840 wlan_hdd_validate_operation_channel(pAdapter,channel))
6841 {
6842 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006843 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306844 return -EINVAL;
6845 }
6846 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6847 }
6848 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08006849 {
6850 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
6851
6852 /* If auto channel selection is configured as enable/ 1 then ignore
6853 channel set by supplicant
6854 */
6855 if ( cfg_param->apAutoChannelSelection )
6856 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306857 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6858 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006859 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306860 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6861 __func__, hdd_device_modetoString(pAdapter->device_mode),
6862 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08006863 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306864 else
6865 {
6866 if(VOS_STATUS_SUCCESS !=
6867 wlan_hdd_validate_operation_channel(pAdapter,channel))
6868 {
6869 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006870 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306871 return -EINVAL;
6872 }
6873 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6874 }
Viral Modi3a32cc52013-02-08 11:14:52 -08006875 }
6876 }
6877 else
6878 {
6879 hddLog(VOS_TRACE_LEVEL_FATAL,
6880 "%s: Invalid device mode failed to set valid channel", __func__);
6881 return -EINVAL;
6882 }
6883 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306884 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006885}
6886
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306887static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
6888 struct net_device *dev,
6889 struct ieee80211_channel *chan,
6890 enum nl80211_channel_type channel_type
6891 )
6892{
6893 int ret;
6894
6895 vos_ssr_protect(__func__);
6896 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
6897 vos_ssr_unprotect(__func__);
6898
6899 return ret;
6900}
6901
Jeff Johnson295189b2012-06-20 16:38:30 -07006902#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6903static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6904 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006905#else
6906static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6907 struct cfg80211_beacon_data *params,
6908 const u8 *ssid, size_t ssid_len,
6909 enum nl80211_hidden_ssid hidden_ssid)
6910#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006911{
6912 tsap_Config_t *pConfig;
6913 beacon_data_t *pBeacon = NULL;
6914 struct ieee80211_mgmt *pMgmt_frame;
6915 v_U8_t *pIe=NULL;
6916 v_U16_t capab_info;
6917 eCsrAuthType RSNAuthType;
6918 eCsrEncryptionType RSNEncryptType;
6919 eCsrEncryptionType mcRSNEncryptType;
6920 int status = VOS_STATUS_SUCCESS;
6921 tpWLAN_SAPEventCB pSapEventCallback;
6922 hdd_hostapd_state_t *pHostapdState;
6923 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6924 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306925 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306927 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006929 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306930 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006931 v_BOOL_t MFPCapable = VOS_FALSE;
6932 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05306933 v_BOOL_t sapEnable11AC =
6934 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 ENTER();
6936
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306937 iniConfig = pHddCtx->cfg_ini;
6938
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
6940
6941 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6942
6943 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6944
6945 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6946
6947 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
6948
6949 //channel is already set in the set_channel Call back
6950 //pConfig->channel = pCommitConfig->channel;
6951
6952 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306953 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
6955
6956 pConfig->dtim_period = pBeacon->dtim_period;
6957
Arif Hussain6d2a3322013-11-17 19:50:10 -08006958 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07006959 pConfig->dtim_period);
6960
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08006961 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07006962 {
6963 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05306965 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
6966 {
6967 tANI_BOOLEAN restartNeeded;
6968 pConfig->ieee80211d = 1;
6969 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
6970 sme_setRegInfo(hHal, pConfig->countryCode);
6971 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
6972 }
6973 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07006975 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006976 pConfig->ieee80211d = 1;
6977 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
6978 sme_setRegInfo(hHal, pConfig->countryCode);
6979 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07006980 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006981 else
6982 {
6983 pConfig->ieee80211d = 0;
6984 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306985 /*
6986 * If auto channel is configured i.e. channel is 0,
6987 * so skip channel validation.
6988 */
6989 if( AUTO_CHANNEL_SELECT != pConfig->channel )
6990 {
6991 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
6992 {
6993 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006994 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306995 return -EINVAL;
6996 }
6997 }
6998 else
6999 {
7000 if(1 != pHddCtx->is_dynamic_channel_range_set)
7001 {
7002 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7003 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7004 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7005 }
7006 pHddCtx->is_dynamic_channel_range_set = 0;
7007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007008 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007009 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 {
7011 pConfig->ieee80211d = 0;
7012 }
7013 pConfig->authType = eSAP_AUTO_SWITCH;
7014
7015 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307016
7017 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007018 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7019
7020 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7021
7022 /*Set wps station to configured*/
7023 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7024
7025 if(pIe)
7026 {
7027 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7028 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007029 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 return -EINVAL;
7031 }
7032 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7033 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007034 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007035 /* Check 15 bit of WPS IE as it contain information for wps state
7036 * WPS state
7037 */
7038 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7039 {
7040 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7041 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7042 {
7043 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7044 }
7045 }
7046 }
7047 else
7048 {
7049 pConfig->wps_state = SAP_WPS_DISABLED;
7050 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307051 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007052
c_hpothufe599e92014-06-16 11:38:55 +05307053 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7054 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7055 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7056 eCSR_ENCRYPT_TYPE_NONE;
7057
Jeff Johnson295189b2012-06-20 16:38:30 -07007058 pConfig->RSNWPAReqIELength = 0;
7059 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307060 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007061 WLAN_EID_RSN);
7062 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307063 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007064 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7065 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7066 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307067 /* The actual processing may eventually be more extensive than
7068 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007069 * by the app.
7070 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307071 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007072 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7073 &RSNEncryptType,
7074 &mcRSNEncryptType,
7075 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007076 &MFPCapable,
7077 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007078 pConfig->pRSNWPAReqIE[1]+2,
7079 pConfig->pRSNWPAReqIE );
7080
7081 if( VOS_STATUS_SUCCESS == status )
7082 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307083 /* Now copy over all the security attributes you have
7084 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007085 * */
7086 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7087 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7088 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7089 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307090 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007091 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7093 }
7094 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307095
Jeff Johnson295189b2012-06-20 16:38:30 -07007096 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7097 pBeacon->tail, pBeacon->tail_len);
7098
7099 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7100 {
7101 if (pConfig->pRSNWPAReqIE)
7102 {
7103 /*Mixed mode WPA/WPA2*/
7104 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7105 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7106 }
7107 else
7108 {
7109 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7110 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7111 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307112 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7114 &RSNEncryptType,
7115 &mcRSNEncryptType,
7116 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007117 &MFPCapable,
7118 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 pConfig->pRSNWPAReqIE[1]+2,
7120 pConfig->pRSNWPAReqIE );
7121
7122 if( VOS_STATUS_SUCCESS == status )
7123 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307124 /* Now copy over all the security attributes you have
7125 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007126 * */
7127 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7128 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7129 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7130 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307131 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007132 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7134 }
7135 }
7136 }
7137
Jeff Johnson4416a782013-03-25 14:17:50 -07007138 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7139 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7140 return -EINVAL;
7141 }
7142
Jeff Johnson295189b2012-06-20 16:38:30 -07007143 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7144
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007145#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 if (params->ssid != NULL)
7147 {
7148 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7149 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7150 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7151 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7152 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007153#else
7154 if (ssid != NULL)
7155 {
7156 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7157 pConfig->SSIDinfo.ssid.length = ssid_len;
7158 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7159 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7160 }
7161#endif
7162
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307163 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007164 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307165
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 /* default value */
7167 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7168 pConfig->num_accept_mac = 0;
7169 pConfig->num_deny_mac = 0;
7170
7171 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7172 pBeacon->tail, pBeacon->tail_len);
7173
7174 /* pIe for black list is following form:
7175 type : 1 byte
7176 length : 1 byte
7177 OUI : 4 bytes
7178 acl type : 1 byte
7179 no of mac addr in black list: 1 byte
7180 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307181 */
7182 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007183 {
7184 pConfig->SapMacaddr_acl = pIe[6];
7185 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007186 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007187 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307188 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7189 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007190 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7191 for (i = 0; i < pConfig->num_deny_mac; i++)
7192 {
7193 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7194 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007196 }
7197 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7198 pBeacon->tail, pBeacon->tail_len);
7199
7200 /* pIe for white list is following form:
7201 type : 1 byte
7202 length : 1 byte
7203 OUI : 4 bytes
7204 acl type : 1 byte
7205 no of mac addr in white list: 1 byte
7206 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307207 */
7208 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 {
7210 pConfig->SapMacaddr_acl = pIe[6];
7211 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007212 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007213 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307214 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7215 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7217 for (i = 0; i < pConfig->num_accept_mac; i++)
7218 {
7219 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7220 acl_entry++;
7221 }
7222 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307223
Jeff Johnson295189b2012-06-20 16:38:30 -07007224 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7225
Jeff Johnsone7245742012-09-05 17:12:55 -07007226#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007227 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307228 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7229 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307230 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7231 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007232 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7233 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307234 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7235 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007236 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307237 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007238 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307239 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007240
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307241 /* If ACS disable and selected channel <= 14
7242 * OR
7243 * ACS enabled and ACS operating band is choosen as 2.4
7244 * AND
7245 * VHT in 2.4G Disabled
7246 * THEN
7247 * Fallback to 11N mode
7248 */
7249 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7250 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307251 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307252 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007253 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307254 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7255 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007256 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7257 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007258 }
7259#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307260
Jeff Johnson295189b2012-06-20 16:38:30 -07007261 // ht_capab is not what the name conveys,this is used for protection bitmap
7262 pConfig->ht_capab =
7263 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7264
7265 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7266 {
7267 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7268 return -EINVAL;
7269 }
7270
7271 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307272 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007273 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7274 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307275 pConfig->obssProtEnabled =
7276 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007277
Chet Lanctot8cecea22014-02-11 19:09:36 -08007278#ifdef WLAN_FEATURE_11W
7279 pConfig->mfpCapable = MFPCapable;
7280 pConfig->mfpRequired = MFPRequired;
7281 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7282 pConfig->mfpCapable, pConfig->mfpRequired);
7283#endif
7284
Arif Hussain6d2a3322013-11-17 19:50:10 -08007285 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007286 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007287 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7288 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7289 (int)pConfig->channel);
7290 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7291 pConfig->SapHw_mode, pConfig->privacy,
7292 pConfig->authType);
7293 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7294 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7295 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7296 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007297
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307298 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007299 {
7300 //Bss already started. just return.
7301 //TODO Probably it should update some beacon params.
7302 hddLog( LOGE, "Bss Already started...Ignore the request");
7303 EXIT();
7304 return 0;
7305 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307306
Agarwal Ashish51325b52014-06-16 16:50:49 +05307307 if (vos_max_concurrent_connections_reached()) {
7308 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7309 return -EINVAL;
7310 }
7311
Jeff Johnson295189b2012-06-20 16:38:30 -07007312 pConfig->persona = pHostapdAdapter->device_mode;
7313
Peng Xu2446a892014-09-05 17:21:18 +05307314 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7315 if ( NULL != psmeConfig)
7316 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307317 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307318 sme_GetConfigParam(hHal, psmeConfig);
7319 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307320#ifdef WLAN_FEATURE_AP_HT40_24G
7321 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7322 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7323 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7324 {
7325 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7326 sme_UpdateConfig (hHal, psmeConfig);
7327 }
7328#endif
Peng Xu2446a892014-09-05 17:21:18 +05307329 vos_mem_free(psmeConfig);
7330 }
Peng Xuafc34e32014-09-25 13:23:55 +05307331 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307332
Jeff Johnson295189b2012-06-20 16:38:30 -07007333 pSapEventCallback = hdd_hostapd_SAPEventCB;
7334 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7335 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7336 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007337 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 return -EINVAL;
7339 }
7340
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307341 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7343
7344 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307345
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307347 {
7348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007349 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007350 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 VOS_ASSERT(0);
7352 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307353
Jeff Johnson295189b2012-06-20 16:38:30 -07007354 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307355 /* Initialize WMM configuation */
7356 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307357 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007358
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007359#ifdef WLAN_FEATURE_P2P_DEBUG
7360 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7361 {
7362 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7363 {
7364 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7365 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007366 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007367 }
7368 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7369 {
7370 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7371 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007372 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007373 }
7374 }
7375#endif
7376
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 pHostapdState->bCommit = TRUE;
7378 EXIT();
7379
7380 return 0;
7381}
7382
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007383#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307384static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307385 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 struct beacon_parameters *params)
7387{
7388 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307389 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307390 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007391
7392 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307393
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307394 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7395 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7396 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307397 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7398 hdd_device_modetoString(pAdapter->device_mode),
7399 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007400
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307401 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7402 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307403 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007404 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307405 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007406 }
7407
Agarwal Ashish51325b52014-06-16 16:50:49 +05307408 if (vos_max_concurrent_connections_reached()) {
7409 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7410 return -EINVAL;
7411 }
7412
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307413 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007414 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007415 )
7416 {
7417 beacon_data_t *old,*new;
7418
7419 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307420
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307422 {
7423 hddLog(VOS_TRACE_LEVEL_WARN,
7424 FL("already beacon info added to session(%d)"),
7425 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007428
7429 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7430
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307431 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007432 {
7433 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007434 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007435 return -EINVAL;
7436 }
7437
7438 pAdapter->sessionCtx.ap.beacon = new;
7439
7440 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7441 }
7442
7443 EXIT();
7444 return status;
7445}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307446
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307447static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7448 struct net_device *dev,
7449 struct beacon_parameters *params)
7450{
7451 int ret;
7452
7453 vos_ssr_protect(__func__);
7454 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7455 vos_ssr_unprotect(__func__);
7456
7457 return ret;
7458}
7459
7460static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 struct net_device *dev,
7462 struct beacon_parameters *params)
7463{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307464 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307465 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7466 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307467 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007468
7469 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307470
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307471 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7472 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7473 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7474 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7475 __func__, hdd_device_modetoString(pAdapter->device_mode),
7476 pAdapter->device_mode);
7477
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307478 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7479 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307480 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007481 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307482 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007483 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307484
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307485 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307487 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 {
7489 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307490
Jeff Johnson295189b2012-06-20 16:38:30 -07007491 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307492
Jeff Johnson295189b2012-06-20 16:38:30 -07007493 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307494 {
7495 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7496 FL("session(%d) old and new heads points to NULL"),
7497 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007498 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007500
7501 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7502
7503 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307504 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007505 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007506 return -EINVAL;
7507 }
7508
7509 pAdapter->sessionCtx.ap.beacon = new;
7510
7511 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7512 }
7513
7514 EXIT();
7515 return status;
7516}
7517
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307518static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7519 struct net_device *dev,
7520 struct beacon_parameters *params)
7521{
7522 int ret;
7523
7524 vos_ssr_protect(__func__);
7525 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7526 vos_ssr_unprotect(__func__);
7527
7528 return ret;
7529}
7530
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007531#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7532
7533#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307534static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007535 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007536#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307537static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007538 struct net_device *dev)
7539#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007540{
7541 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007542 hdd_context_t *pHddCtx = NULL;
7543 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307544 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307545 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007546
7547 ENTER();
7548
7549 if (NULL == pAdapter)
7550 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307551 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007552 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007553 return -ENODEV;
7554 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007555
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307556 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7557 TRACE_CODE_HDD_CFG80211_STOP_AP,
7558 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307559 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7560 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307561 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007562 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307563 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007564 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007565
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007566 pScanInfo = &pHddCtx->scan_info;
7567
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307568 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7569 __func__, hdd_device_modetoString(pAdapter->device_mode),
7570 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007571
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307572 ret = wlan_hdd_scan_abort(pAdapter);
7573
Girish Gowli4bf7a632014-06-12 13:42:11 +05307574 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007575 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307576 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7577 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307578
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307579 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007580 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307581 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7582 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007583
Jeff Johnsone7245742012-09-05 17:12:55 -07007584 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307585 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007586 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307587 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007588 }
7589
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307590 /* Delete all associated STAs before stopping AP/P2P GO */
7591 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307592 hdd_hostapd_stop(dev);
7593
Jeff Johnson295189b2012-06-20 16:38:30 -07007594 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007595 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 )
7597 {
7598 beacon_data_t *old;
7599
7600 old = pAdapter->sessionCtx.ap.beacon;
7601
7602 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307603 {
7604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7605 FL("session(%d) beacon data points to NULL"),
7606 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007607 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007609
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007611
7612 mutex_lock(&pHddCtx->sap_lock);
7613 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7614 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007615 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 {
7617 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7618
7619 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7620
7621 if (!VOS_IS_STATUS_SUCCESS(status))
7622 {
7623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007624 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007625 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307626 }
7627 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007628 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307629 /* BSS stopped, clear the active sessions for this device mode */
7630 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007631 }
7632 mutex_unlock(&pHddCtx->sap_lock);
7633
7634 if(status != VOS_STATUS_SUCCESS)
7635 {
7636 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007637 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 return -EINVAL;
7639 }
7640
Jeff Johnson4416a782013-03-25 14:17:50 -07007641 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007642 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7643 ==eHAL_STATUS_FAILURE)
7644 {
7645 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007646 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 }
7648
Jeff Johnson4416a782013-03-25 14:17:50 -07007649 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007650 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7651 eANI_BOOLEAN_FALSE) )
7652 {
7653 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007654 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 }
7656
7657 // Reset WNI_CFG_PROBE_RSP Flags
7658 wlan_hdd_reset_prob_rspies(pAdapter);
7659
7660 pAdapter->sessionCtx.ap.beacon = NULL;
7661 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007662#ifdef WLAN_FEATURE_P2P_DEBUG
7663 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7664 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7665 {
7666 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7667 "GO got removed");
7668 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7669 }
7670#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 }
7672 EXIT();
7673 return status;
7674}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007675
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307676#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7677static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7678 struct net_device *dev)
7679{
7680 int ret;
7681
7682 vos_ssr_protect(__func__);
7683 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7684 vos_ssr_unprotect(__func__);
7685
7686 return ret;
7687}
7688#else
7689static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7690 struct net_device *dev)
7691{
7692 int ret;
7693
7694 vos_ssr_protect(__func__);
7695 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7696 vos_ssr_unprotect(__func__);
7697
7698 return ret;
7699}
7700#endif
7701
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007702#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7703
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307704static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307705 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007706 struct cfg80211_ap_settings *params)
7707{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307708 hdd_adapter_t *pAdapter;
7709 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307710 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007711
7712 ENTER();
7713
Girish Gowlib143d7a2015-02-18 19:39:55 +05307714 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007715 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307716 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307717 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307718 return -ENODEV;
7719 }
7720
7721 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7722 if (NULL == pAdapter)
7723 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307724 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307725 "%s: HDD adapter is Null", __func__);
7726 return -ENODEV;
7727 }
7728
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307729 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7730 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7731 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307732 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7733 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307734 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307735 "%s: HDD adapter magic is invalid", __func__);
7736 return -ENODEV;
7737 }
7738
7739 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307740 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307741 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307742 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307743 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307744 }
7745
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307746 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7747 __func__, hdd_device_modetoString(pAdapter->device_mode),
7748 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307749
7750 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007751 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007752 )
7753 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307754 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007755
7756 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307757
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007758 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307759 {
7760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7761 FL("already beacon info added to session(%d)"),
7762 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007763 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307764 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007765
Girish Gowlib143d7a2015-02-18 19:39:55 +05307766#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7767 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7768 &new,
7769 &params->beacon);
7770#else
7771 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7772 &new,
7773 &params->beacon,
7774 params->dtim_period);
7775#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007776
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307777 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007778 {
7779 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307780 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007781 return -EINVAL;
7782 }
7783 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007784#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007785 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7786#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7787 params->channel, params->channel_type);
7788#else
7789 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7790#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007791#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007792 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
7793 params->ssid_len, params->hidden_ssid);
7794 }
7795
7796 EXIT();
7797 return status;
7798}
7799
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307800static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
7801 struct net_device *dev,
7802 struct cfg80211_ap_settings *params)
7803{
7804 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007805
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307806 vos_ssr_protect(__func__);
7807 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
7808 vos_ssr_unprotect(__func__);
7809
7810 return ret;
7811}
7812
7813static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007814 struct net_device *dev,
7815 struct cfg80211_beacon_data *params)
7816{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307817 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307818 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307819 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007820
7821 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307822
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307823 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7824 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
7825 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007826 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007827 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307828
7829 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7830 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307831 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007832 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307833 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007834 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007835
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307836 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007837 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307838 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007839 {
7840 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307841
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007842 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307843
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007844 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307845 {
7846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7847 FL("session(%d) beacon data points to NULL"),
7848 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007849 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307850 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007851
7852 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
7853
7854 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307855 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007856 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007857 return -EINVAL;
7858 }
7859
7860 pAdapter->sessionCtx.ap.beacon = new;
7861
7862 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
7863 }
7864
7865 EXIT();
7866 return status;
7867}
7868
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307869static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
7870 struct net_device *dev,
7871 struct cfg80211_beacon_data *params)
7872{
7873 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007874
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307875 vos_ssr_protect(__func__);
7876 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
7877 vos_ssr_unprotect(__func__);
7878
7879 return ret;
7880}
7881
7882#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007883
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307884static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007885 struct net_device *dev,
7886 struct bss_parameters *params)
7887{
7888 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307889 hdd_context_t *pHddCtx;
7890 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007891
7892 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307893
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307894 if (NULL == pAdapter)
7895 {
7896 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7897 "%s: HDD adapter is Null", __func__);
7898 return -ENODEV;
7899 }
7900 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307901 ret = wlan_hdd_validate_context(pHddCtx);
7902 if (0 != ret)
7903 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307904 return ret;
7905 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307906 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7907 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
7908 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307909 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7910 __func__, hdd_device_modetoString(pAdapter->device_mode),
7911 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007912
7913 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307915 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007916 {
7917 /* ap_isolate == -1 means that in change bss, upper layer doesn't
7918 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307919 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 {
7921 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007923 }
7924
7925 EXIT();
7926 return 0;
7927}
7928
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307929static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
7930 struct net_device *dev,
7931 struct bss_parameters *params)
7932{
7933 int ret;
7934
7935 vos_ssr_protect(__func__);
7936 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
7937 vos_ssr_unprotect(__func__);
7938
7939 return ret;
7940}
Kiet Lam10841362013-11-01 11:36:50 +05307941/* FUNCTION: wlan_hdd_change_country_code_cd
7942* to wait for contry code completion
7943*/
7944void* wlan_hdd_change_country_code_cb(void *pAdapter)
7945{
7946 hdd_adapter_t *call_back_pAdapter = pAdapter;
7947 complete(&call_back_pAdapter->change_country_code);
7948 return NULL;
7949}
7950
Jeff Johnson295189b2012-06-20 16:38:30 -07007951/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307952 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
7954 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307955int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 struct net_device *ndev,
7957 enum nl80211_iftype type,
7958 u32 *flags,
7959 struct vif_params *params
7960 )
7961{
7962 struct wireless_dev *wdev;
7963 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007964 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07007965 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007966 tCsrRoamProfile *pRoamProfile = NULL;
7967 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307968 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007969 eMib_dot11DesiredBssType connectedBssType;
7970 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307971 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007972
7973 ENTER();
7974
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307975 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007976 {
7977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7978 "%s: Adapter context is null", __func__);
7979 return VOS_STATUS_E_FAILURE;
7980 }
7981
7982 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7983 if (!pHddCtx)
7984 {
7985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7986 "%s: HDD context is null", __func__);
7987 return VOS_STATUS_E_FAILURE;
7988 }
7989
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307990 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7991 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
7992 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307993 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307994 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007995 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307996 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 }
7998
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307999 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8000 __func__, hdd_device_modetoString(pAdapter->device_mode),
8001 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008002
Agarwal Ashish51325b52014-06-16 16:50:49 +05308003 if (vos_max_concurrent_connections_reached()) {
8004 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8005 return -EINVAL;
8006 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308007 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008008 wdev = ndev->ieee80211_ptr;
8009
8010#ifdef WLAN_BTAMP_FEATURE
8011 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8012 (NL80211_IFTYPE_ADHOC == type)||
8013 (NL80211_IFTYPE_AP == type)||
8014 (NL80211_IFTYPE_P2P_GO == type))
8015 {
8016 pHddCtx->isAmpAllowed = VOS_FALSE;
8017 // stop AMP traffic
8018 status = WLANBAP_StopAmp();
8019 if(VOS_STATUS_SUCCESS != status )
8020 {
8021 pHddCtx->isAmpAllowed = VOS_TRUE;
8022 hddLog(VOS_TRACE_LEVEL_FATAL,
8023 "%s: Failed to stop AMP", __func__);
8024 return -EINVAL;
8025 }
8026 }
8027#endif //WLAN_BTAMP_FEATURE
8028 /* Reset the current device mode bit mask*/
8029 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8030
8031 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008032 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008033 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008034 )
8035 {
8036 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008037 if (!pWextState)
8038 {
8039 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8040 "%s: pWextState is null", __func__);
8041 return VOS_STATUS_E_FAILURE;
8042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 pRoamProfile = &pWextState->roamProfile;
8044 LastBSSType = pRoamProfile->BSSType;
8045
8046 switch (type)
8047 {
8048 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 hddLog(VOS_TRACE_LEVEL_INFO,
8051 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8052 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008053#ifdef WLAN_FEATURE_11AC
8054 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8055 {
8056 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8057 }
8058#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308059 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008060 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008061 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008062 //Check for sub-string p2p to confirm its a p2p interface
8063 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308064 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008065 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8066 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8067 }
8068 else
8069 {
8070 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008071 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308074
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 case NL80211_IFTYPE_ADHOC:
8076 hddLog(VOS_TRACE_LEVEL_INFO,
8077 "%s: setting interface Type to ADHOC", __func__);
8078 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8079 pRoamProfile->phyMode =
8080 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008081 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008082 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308083 hdd_set_ibss_ops( pAdapter );
8084 hdd_ibss_init_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 break;
8086
8087 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 {
8090 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8091 "%s: setting interface Type to %s", __func__,
8092 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8093
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008094 //Cancel any remain on channel for GO mode
8095 if (NL80211_IFTYPE_P2P_GO == type)
8096 {
8097 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8098 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008099 if (NL80211_IFTYPE_AP == type)
8100 {
8101 /* As Loading WLAN Driver one interface being created for p2p device
8102 * address. This will take one HW STA and the max number of clients
8103 * that can connect to softAP will be reduced by one. so while changing
8104 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8105 * interface as it is not required in SoftAP mode.
8106 */
8107
8108 // Get P2P Adapter
8109 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8110
8111 if (pP2pAdapter)
8112 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308113 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308114 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008115 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8116 }
8117 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308118 //Disable IMPS & BMPS for SAP/GO
8119 if(VOS_STATUS_E_FAILURE ==
8120 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8121 {
8122 //Fail to Exit BMPS
8123 VOS_ASSERT(0);
8124 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308125
8126 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8127
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308128#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008129
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308130 /* A Mutex Lock is introduced while changing the mode to
8131 * protect the concurrent access for the Adapters by TDLS
8132 * module.
8133 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308134 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308135#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008136 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308137 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008138 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008139 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8140 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308141#ifdef FEATURE_WLAN_TDLS
8142 mutex_unlock(&pHddCtx->tdls_lock);
8143#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008144 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8145 (pConfig->apRandomBssidEnabled))
8146 {
8147 /* To meet Android requirements create a randomized
8148 MAC address of the form 02:1A:11:Fx:xx:xx */
8149 get_random_bytes(&ndev->dev_addr[3], 3);
8150 ndev->dev_addr[0] = 0x02;
8151 ndev->dev_addr[1] = 0x1A;
8152 ndev->dev_addr[2] = 0x11;
8153 ndev->dev_addr[3] |= 0xF0;
8154 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8155 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008156 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8157 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008158 }
8159
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 hdd_set_ap_ops( pAdapter->dev );
8161
Kiet Lam10841362013-11-01 11:36:50 +05308162 /* This is for only SAP mode where users can
8163 * control country through ini.
8164 * P2P GO follows station country code
8165 * acquired during the STA scanning. */
8166 if((NL80211_IFTYPE_AP == type) &&
8167 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8168 {
8169 int status = 0;
8170 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8171 "%s: setting country code from INI ", __func__);
8172 init_completion(&pAdapter->change_country_code);
8173 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8174 (void *)(tSmeChangeCountryCallback)
8175 wlan_hdd_change_country_code_cb,
8176 pConfig->apCntryCode, pAdapter,
8177 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308178 eSIR_FALSE,
8179 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308180 if (eHAL_STATUS_SUCCESS == status)
8181 {
8182 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308183 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308184 &pAdapter->change_country_code,
8185 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308186 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308187 {
8188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308189 FL("SME Timed out while setting country code %ld"),
8190 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008191
8192 if (pHddCtx->isLogpInProgress)
8193 {
8194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8195 "%s: LOGP in Progress. Ignore!!!", __func__);
8196 return -EAGAIN;
8197 }
Kiet Lam10841362013-11-01 11:36:50 +05308198 }
8199 }
8200 else
8201 {
8202 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008203 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308204 return -EINVAL;
8205 }
8206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008207 status = hdd_init_ap_mode(pAdapter);
8208 if(status != VOS_STATUS_SUCCESS)
8209 {
8210 hddLog(VOS_TRACE_LEVEL_FATAL,
8211 "%s: Error initializing the ap mode", __func__);
8212 return -EINVAL;
8213 }
8214 hdd_set_conparam(1);
8215
Jeff Johnson295189b2012-06-20 16:38:30 -07008216 /*interface type changed update in wiphy structure*/
8217 if(wdev)
8218 {
8219 wdev->iftype = type;
8220 pHddCtx->change_iface = type;
8221 }
8222 else
8223 {
8224 hddLog(VOS_TRACE_LEVEL_ERROR,
8225 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8226 return -EINVAL;
8227 }
8228 goto done;
8229 }
8230
8231 default:
8232 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8233 __func__);
8234 return -EOPNOTSUPP;
8235 }
8236 }
8237 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008238 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008239 )
8240 {
8241 switch(type)
8242 {
8243 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008244 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308246
8247 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308248#ifdef FEATURE_WLAN_TDLS
8249
8250 /* A Mutex Lock is introduced while changing the mode to
8251 * protect the concurrent access for the Adapters by TDLS
8252 * module.
8253 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308254 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308255#endif
c_hpothu002231a2015-02-05 14:58:51 +05308256 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008257 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008258 //Check for sub-string p2p to confirm its a p2p interface
8259 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008260 {
8261 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8262 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8263 }
8264 else
8265 {
8266 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008268 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008269 hdd_set_conparam(0);
8270 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008271 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8272 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308273#ifdef FEATURE_WLAN_TDLS
8274 mutex_unlock(&pHddCtx->tdls_lock);
8275#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308276 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008277 if( VOS_STATUS_SUCCESS != status )
8278 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008279 /* In case of JB, for P2P-GO, only change interface will be called,
8280 * This is the right place to enable back bmps_imps()
8281 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308282 if (pHddCtx->hdd_wlan_suspended)
8283 {
8284 hdd_set_pwrparams(pHddCtx);
8285 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008286 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 goto done;
8288 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008291 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8292 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008293 goto done;
8294 default:
8295 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8296 __func__);
8297 return -EOPNOTSUPP;
8298
8299 }
8300
8301 }
8302 else
8303 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308304 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8305 __func__, hdd_device_modetoString(pAdapter->device_mode),
8306 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008307 return -EOPNOTSUPP;
8308 }
8309
8310
8311 if(pRoamProfile)
8312 {
8313 if ( LastBSSType != pRoamProfile->BSSType )
8314 {
8315 /*interface type changed update in wiphy structure*/
8316 wdev->iftype = type;
8317
8318 /*the BSS mode changed, We need to issue disconnect
8319 if connected or in IBSS disconnect state*/
8320 if ( hdd_connGetConnectedBssType(
8321 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8322 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8323 {
8324 /*need to issue a disconnect to CSR.*/
8325 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8326 if( eHAL_STATUS_SUCCESS ==
8327 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8328 pAdapter->sessionId,
8329 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8330 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308331 ret = wait_for_completion_interruptible_timeout(
8332 &pAdapter->disconnect_comp_var,
8333 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8334 if (ret <= 0)
8335 {
8336 hddLog(VOS_TRACE_LEVEL_ERROR,
8337 FL("wait on disconnect_comp_var failed %ld"), ret);
8338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008339 }
8340 }
8341 }
8342 }
8343
8344done:
8345 /*set bitmask based on updated value*/
8346 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008347
8348 /* Only STA mode support TM now
8349 * all other mode, TM feature should be disabled */
8350 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8351 (~VOS_STA & pHddCtx->concurrency_mode) )
8352 {
8353 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8354 }
8355
Jeff Johnson295189b2012-06-20 16:38:30 -07008356#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308357 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308358 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008359 {
8360 //we are ok to do AMP
8361 pHddCtx->isAmpAllowed = VOS_TRUE;
8362 }
8363#endif //WLAN_BTAMP_FEATURE
8364 EXIT();
8365 return 0;
8366}
8367
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308368/*
8369 * FUNCTION: wlan_hdd_cfg80211_change_iface
8370 * wrapper function to protect the actual implementation from SSR.
8371 */
8372int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8373 struct net_device *ndev,
8374 enum nl80211_iftype type,
8375 u32 *flags,
8376 struct vif_params *params
8377 )
8378{
8379 int ret;
8380
8381 vos_ssr_protect(__func__);
8382 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8383 vos_ssr_unprotect(__func__);
8384
8385 return ret;
8386}
8387
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008388#ifdef FEATURE_WLAN_TDLS
8389static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
8390 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
8391{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008392 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008393 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308394 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308395 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308396 hdd_adapter_t *pAdapter;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008397
8398 ENTER();
8399
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308400 if (!dev) {
8401 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8402 return -EINVAL;
8403 }
8404
8405 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8406 if (!pAdapter) {
8407 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8408 return -EINVAL;
8409 }
8410
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308411 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008412 {
8413 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8414 "Invalid arguments");
8415 return -EINVAL;
8416 }
Hoonki Lee27511902013-03-14 18:19:06 -07008417
8418 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8419 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8420 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308421 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008422 "%s: TDLS mode is disabled OR not enabled in FW."
8423 MAC_ADDRESS_STR " Request declined.",
8424 __func__, MAC_ADDR_ARRAY(mac));
8425 return -ENOTSUPP;
8426 }
8427
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008428 if (pHddCtx->isLogpInProgress)
8429 {
8430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8431 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308432 wlan_hdd_tdls_set_link_status(pAdapter,
8433 mac,
8434 eTDLS_LINK_IDLE,
8435 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008436 return -EBUSY;
8437 }
8438
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308439 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008440
8441 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308442 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008443 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8444 __func__, MAC_ADDR_ARRAY(mac), update);
8445 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008446 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008447
8448 /* in add station, we accept existing valid staId if there is */
8449 if ((0 == update) &&
8450 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8451 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008452 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308453 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008454 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008455 " link_status %d. staId %d. add station ignored.",
8456 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8457 return 0;
8458 }
8459 /* in change station, we accept only when staId is valid */
8460 if ((1 == update) &&
8461 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8462 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8463 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308464 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008465 "%s: " MAC_ADDRESS_STR
8466 " link status %d. staId %d. change station %s.",
8467 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8468 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8469 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008470 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008471
8472 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308473 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008474 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008475 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8476 "%s: " MAC_ADDRESS_STR
8477 " TDLS setup is ongoing. Request declined.",
8478 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008479 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008480 }
8481
8482 /* first to check if we reached to maximum supported TDLS peer.
8483 TODO: for now, return -EPERM looks working fine,
8484 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308485 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8486 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008487 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008488 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8489 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308490 " TDLS Max peer already connected. Request declined."
8491 " Num of peers (%d), Max allowed (%d).",
8492 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8493 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008494 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008495 }
8496 else
8497 {
8498 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308499 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008500 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008501 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8503 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8504 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008505 return -EPERM;
8506 }
8507 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008508 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308509 wlan_hdd_tdls_set_link_status(pAdapter,
8510 mac,
8511 eTDLS_LINK_CONNECTING,
8512 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008513
Jeff Johnsond75fe012013-04-06 10:53:06 -07008514 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308515 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008516 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008518 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008519 if(StaParams->htcap_present)
8520 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308521 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008522 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008524 "ht_capa->extended_capabilities: %0x",
8525 StaParams->HTCap.extendedHtCapInfo);
8526 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308527 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008528 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008530 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008531 if(StaParams->vhtcap_present)
8532 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008534 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8535 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8536 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8537 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008538 {
8539 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008540 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008541 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308542 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008543 "[%d]: %x ", i, StaParams->supported_rates[i]);
8544 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008545 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308546 else if ((1 == update) && (NULL == StaParams))
8547 {
8548 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8549 "%s : update is true, but staParams is NULL. Error!", __func__);
8550 return -EPERM;
8551 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008552
8553 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8554
8555 if (!update)
8556 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308557 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008558 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308559 if (ret != eHAL_STATUS_SUCCESS) {
8560 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to add TDLS peer STA"));
8561 return -EPERM;
8562 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008563 }
8564 else
8565 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308566 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008567 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308568 if (ret != eHAL_STATUS_SUCCESS) {
8569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8570 return -EPERM;
8571 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008572 }
8573
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308574 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008575 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8576
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308577 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008578 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308580 "%s: timeout waiting for tdls add station indication %ld",
8581 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008582 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008583 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308584
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008585 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8586 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008587 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008588 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008589 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008590 }
8591
8592 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008593
8594error:
Atul Mittal115287b2014-07-08 13:26:33 +05308595 wlan_hdd_tdls_set_link_status(pAdapter,
8596 mac,
8597 eTDLS_LINK_IDLE,
8598 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008599 return -EPERM;
8600
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008601}
8602#endif
8603
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308604static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008605 struct net_device *dev,
8606 u8 *mac,
8607 struct station_parameters *params)
8608{
8609 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308610 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308611 hdd_context_t *pHddCtx;
8612 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008613 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308614 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008615#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008616 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008617 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308618 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008619#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008620
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308621 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308622
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308623 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308624 if ((NULL == pAdapter))
8625 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308627 "invalid adapter ");
8628 return -EINVAL;
8629 }
8630
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308631 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8632 TRACE_CODE_HDD_CHANGE_STATION,
8633 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308634 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308635
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308636 ret = wlan_hdd_validate_context(pHddCtx);
8637 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308638 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308639 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308640 }
8641
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308642 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8643
8644 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008645 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8647 "invalid HDD station context");
8648 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8651
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008652 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8653 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008654 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008655 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008656 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308657 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008658 WLANTL_STA_AUTHENTICATED);
8659
Gopichand Nakkala29149562013-05-10 21:43:41 +05308660 if (status != VOS_STATUS_SUCCESS)
8661 {
8662 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8663 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8664 return -EINVAL;
8665 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 }
8667 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008668 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8669 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308670#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008671 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8672 StaParams.capability = params->capability;
8673 StaParams.uapsd_queues = params->uapsd_queues;
8674 StaParams.max_sp = params->max_sp;
8675
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308676 /* Convert (first channel , number of channels) tuple to
8677 * the total list of channels. This goes with the assumption
8678 * that if the first channel is < 14, then the next channels
8679 * are an incremental of 1 else an incremental of 4 till the number
8680 * of channels.
8681 */
8682 if (0 != params->supported_channels_len) {
8683 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8684 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8685 {
8686 int wifi_chan_index;
8687 StaParams.supported_channels[j] = params->supported_channels[i];
8688 wifi_chan_index =
8689 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8690 no_of_channels = params->supported_channels[i+1];
8691 for(k=1; k <= no_of_channels; k++)
8692 {
8693 StaParams.supported_channels[j+1] =
8694 StaParams.supported_channels[j] + wifi_chan_index;
8695 j+=1;
8696 }
8697 }
8698 StaParams.supported_channels_len = j;
8699 }
8700 vos_mem_copy(StaParams.supported_oper_classes,
8701 params->supported_oper_classes,
8702 params->supported_oper_classes_len);
8703 StaParams.supported_oper_classes_len =
8704 params->supported_oper_classes_len;
8705
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008706 if (0 != params->ext_capab_len)
8707 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8708 sizeof(StaParams.extn_capability));
8709
8710 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008711 {
8712 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008713 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008714 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008715
8716 StaParams.supported_rates_len = params->supported_rates_len;
8717
8718 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8719 * The supported_rates array , for all the structures propogating till Add Sta
8720 * to the firmware has to be modified , if the supplicant (ieee80211) is
8721 * modified to send more rates.
8722 */
8723
8724 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8725 */
8726 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8727 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8728
8729 if (0 != StaParams.supported_rates_len) {
8730 int i = 0;
8731 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8732 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008733 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008734 "Supported Rates with Length %d", StaParams.supported_rates_len);
8735 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008736 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008737 "[%d]: %0x", i, StaParams.supported_rates[i]);
8738 }
8739
8740 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008741 {
8742 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008743 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008744 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008745
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008746 if (0 != params->ext_capab_len ) {
8747 /*Define A Macro : TODO Sunil*/
8748 if ((1<<4) & StaParams.extn_capability[3]) {
8749 isBufSta = 1;
8750 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308751 /* TDLS Channel Switching Support */
8752 if ((1<<6) & StaParams.extn_capability[3]) {
8753 isOffChannelSupported = 1;
8754 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008755 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308756 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
8757 &StaParams, isBufSta,
8758 isOffChannelSupported);
8759
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308760 if (VOS_STATUS_SUCCESS != status) {
8761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8762 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
8763 return -EINVAL;
8764 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008765 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
8766
8767 if (VOS_STATUS_SUCCESS != status) {
8768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8769 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
8770 return -EINVAL;
8771 }
8772 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008773#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05308774 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008775 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008776 return status;
8777}
8778
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308779static int wlan_hdd_change_station(struct wiphy *wiphy,
8780 struct net_device *dev,
8781 u8 *mac,
8782 struct station_parameters *params)
8783{
8784 int ret;
8785
8786 vos_ssr_protect(__func__);
8787 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
8788 vos_ssr_unprotect(__func__);
8789
8790 return ret;
8791}
8792
Jeff Johnson295189b2012-06-20 16:38:30 -07008793/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308794 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 * This function is used to initialize the key information
8796 */
8797#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308798static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 struct net_device *ndev,
8800 u8 key_index, bool pairwise,
8801 const u8 *mac_addr,
8802 struct key_params *params
8803 )
8804#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308805static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008806 struct net_device *ndev,
8807 u8 key_index, const u8 *mac_addr,
8808 struct key_params *params
8809 )
8810#endif
8811{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008812 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008813 tCsrRoamSetKey setKey;
8814 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308815 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008816 v_U32_t roamId= 0xFF;
8817 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 hdd_hostapd_state_t *pHostapdState;
8819 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008820 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308821 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008822
8823 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308824
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308825 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8826 TRACE_CODE_HDD_CFG80211_ADD_KEY,
8827 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308828 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8829 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308830 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008831 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308832 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008833 }
8834
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308835 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8836 __func__, hdd_device_modetoString(pAdapter->device_mode),
8837 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008838
8839 if (CSR_MAX_NUM_KEY <= key_index)
8840 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008841 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 key_index);
8843
8844 return -EINVAL;
8845 }
8846
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008847 if (CSR_MAX_KEY_LEN < params->key_len)
8848 {
8849 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
8850 params->key_len);
8851
8852 return -EINVAL;
8853 }
8854
8855 hddLog(VOS_TRACE_LEVEL_INFO,
8856 "%s: called with key index = %d & key length %d",
8857 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008858
8859 /*extract key idx, key len and key*/
8860 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8861 setKey.keyId = key_index;
8862 setKey.keyLength = params->key_len;
8863 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
8864
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008865 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07008866 {
8867 case WLAN_CIPHER_SUITE_WEP40:
8868 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8869 break;
8870
8871 case WLAN_CIPHER_SUITE_WEP104:
8872 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
8873 break;
8874
8875 case WLAN_CIPHER_SUITE_TKIP:
8876 {
8877 u8 *pKey = &setKey.Key[0];
8878 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
8879
8880 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
8881
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008882 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07008883
8884 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008885 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008886 |--------------|----------|----------|
8887 <---16bytes---><--8bytes--><--8bytes-->
8888
8889 */
8890 /*Sme expects the 32 bytes key to be in the below order
8891
8892 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008893 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008894 |--------------|----------|----------|
8895 <---16bytes---><--8bytes--><--8bytes-->
8896 */
8897 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008898 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07008899
8900 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008901 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008902
8903 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008904 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008905
8906
8907 break;
8908 }
8909
8910 case WLAN_CIPHER_SUITE_CCMP:
8911 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
8912 break;
8913
8914#ifdef FEATURE_WLAN_WAPI
8915 case WLAN_CIPHER_SUITE_SMS4:
8916 {
8917 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8918 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
8919 params->key, params->key_len);
8920 return 0;
8921 }
8922#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008923
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008924#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008925 case WLAN_CIPHER_SUITE_KRK:
8926 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
8927 break;
8928#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008929
8930#ifdef WLAN_FEATURE_11W
8931 case WLAN_CIPHER_SUITE_AES_CMAC:
8932 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07008933 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07008934#endif
8935
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008937 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07008938 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308939 status = -EOPNOTSUPP;
8940 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008941 }
8942
8943 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
8944 __func__, setKey.encType);
8945
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008946 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07008947#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8948 (!pairwise)
8949#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008950 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07008951#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008952 )
8953 {
8954 /* set group key*/
8955 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8956 "%s- %d: setting Broadcast key",
8957 __func__, __LINE__);
8958 setKey.keyDirection = eSIR_RX_ONLY;
8959 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
8960 }
8961 else
8962 {
8963 /* set pairwise key*/
8964 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8965 "%s- %d: setting pairwise key",
8966 __func__, __LINE__);
8967 setKey.keyDirection = eSIR_TX_RX;
8968 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
8969 }
8970 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
8971 {
8972 setKey.keyDirection = eSIR_TX_RX;
8973 /*Set the group key*/
8974 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8975 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008976
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008977 if ( 0 != status )
8978 {
8979 hddLog(VOS_TRACE_LEVEL_ERROR,
8980 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308981 status = -EINVAL;
8982 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008983 }
8984 /*Save the keys here and call sme_RoamSetKey for setting
8985 the PTK after peer joins the IBSS network*/
8986 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
8987 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308988 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008989 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05308990 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
8991 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
8992 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008993 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008994 if( pHostapdState->bssState == BSS_START )
8995 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008996 status = WLANSAP_SetKeySta( pVosContext, &setKey);
8997
8998 if ( status != eHAL_STATUS_SUCCESS )
8999 {
9000 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9001 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9002 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309003 status = -EINVAL;
9004 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009005 }
9006 }
9007
9008 /* Saving WEP keys */
9009 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9010 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9011 {
9012 //Save the wep key in ap context. Issue setkey after the BSS is started.
9013 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9014 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9015 }
9016 else
9017 {
9018 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009019 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009020 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9021 }
9022 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009023 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9024 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009025 {
9026 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9027 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9028
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309029#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9030 if (!pairwise)
9031#else
9032 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9033#endif
9034 {
9035 /* set group key*/
9036 if (pHddStaCtx->roam_info.deferKeyComplete)
9037 {
9038 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9039 "%s- %d: Perform Set key Complete",
9040 __func__, __LINE__);
9041 hdd_PerformRoamSetKeyComplete(pAdapter);
9042 }
9043 }
9044
Jeff Johnson295189b2012-06-20 16:38:30 -07009045 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9046
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009047 pWextState->roamProfile.Keys.defaultIndex = key_index;
9048
9049
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009050 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 params->key, params->key_len);
9052
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309053
Jeff Johnson295189b2012-06-20 16:38:30 -07009054 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9055
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309056 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309058 __func__, setKey.peerMac[0], setKey.peerMac[1],
9059 setKey.peerMac[2], setKey.peerMac[3],
9060 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009061 setKey.keyDirection);
9062
Nirav Shah4f765af2015-01-21 19:51:30 +05309063 /* Wait for EAPOL M4 before setting key.
9064 * No need to consider Dynamic WEP as we will receive M8.
9065 */
9066 if ( (setKey.encType == eCSR_ENCRYPT_TYPE_AES ||
9067 setKey.encType == eCSR_ENCRYPT_TYPE_TKIP) &&
9068 ( 1
9069#if defined WLAN_FEATURE_VOWIFI_11R
9070 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_FT_RSN
9071 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_FT_RSN_PSK
9072#endif
9073#ifdef FEATURE_WLAN_ESE
9074 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_CCKM_WPA
9075 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_CCKM_RSN
9076#endif
9077 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 {
Nirav Shah4f765af2015-01-21 19:51:30 +05309079 vos_status = wlan_hdd_check_ula_done(pAdapter);
9080
9081 if ( vos_status != VOS_STATUS_SUCCESS )
9082 {
9083 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009084 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9085 __LINE__, vos_status );
9086
Nirav Shah4f765af2015-01-21 19:51:30 +05309087 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009088
Nirav Shah4f765af2015-01-21 19:51:30 +05309089 status = -EINVAL;
9090 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009091
Nirav Shah4f765af2015-01-21 19:51:30 +05309092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009093 }
9094
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009095#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309096 /* The supplicant may attempt to set the PTK once pre-authentication
9097 is done. Save the key in the UMAC and include it in the ADD BSS
9098 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009099 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309100 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009101 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309102 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9103 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309104 status = 0;
9105 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309106 }
9107 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9108 {
9109 hddLog(VOS_TRACE_LEVEL_ERROR,
9110 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309111 status = -EINVAL;
9112 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009113 }
9114#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009115
9116 /* issue set key request to SME*/
9117 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9118 pAdapter->sessionId, &setKey, &roamId );
9119
9120 if ( 0 != status )
9121 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309122 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9124 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309125 status = -EINVAL;
9126 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009127 }
9128
9129
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309130 /* in case of IBSS as there was no information available about WEP keys during
9131 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009132 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309133 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9134 !( ( IW_AUTH_KEY_MGMT_802_1X
9135 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009136 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9137 )
9138 &&
9139 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9140 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9141 )
9142 )
9143 {
9144 setKey.keyDirection = eSIR_RX_ONLY;
9145 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9146
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309147 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309149 __func__, setKey.peerMac[0], setKey.peerMac[1],
9150 setKey.peerMac[2], setKey.peerMac[3],
9151 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009152 setKey.keyDirection);
9153
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309154 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009155 pAdapter->sessionId, &setKey, &roamId );
9156
9157 if ( 0 != status )
9158 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309159 hddLog(VOS_TRACE_LEVEL_ERROR,
9160 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 __func__, status);
9162 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309163 status = -EINVAL;
9164 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009165 }
9166 }
9167 }
9168
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309169end:
9170 /* Need to clear any trace of key value in the memory.
9171 * Thus zero out the memory even though it is local
9172 * variable.
9173 */
9174 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309175 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309176 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009177}
9178
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309179#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9180static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9181 struct net_device *ndev,
9182 u8 key_index, bool pairwise,
9183 const u8 *mac_addr,
9184 struct key_params *params
9185 )
9186#else
9187static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9188 struct net_device *ndev,
9189 u8 key_index, const u8 *mac_addr,
9190 struct key_params *params
9191 )
9192#endif
9193{
9194 int ret;
9195 vos_ssr_protect(__func__);
9196#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9197 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9198 mac_addr, params);
9199#else
9200 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9201 params);
9202#endif
9203 vos_ssr_unprotect(__func__);
9204
9205 return ret;
9206}
9207
Jeff Johnson295189b2012-06-20 16:38:30 -07009208/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309209 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 * This function is used to get the key information
9211 */
9212#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309213static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309214 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009215 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309216 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009217 const u8 *mac_addr, void *cookie,
9218 void (*callback)(void *cookie, struct key_params*)
9219 )
9220#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309221static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309222 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 struct net_device *ndev,
9224 u8 key_index, const u8 *mac_addr, void *cookie,
9225 void (*callback)(void *cookie, struct key_params*)
9226 )
9227#endif
9228{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309229 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309230 hdd_wext_state_t *pWextState = NULL;
9231 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009232 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309233 hdd_context_t *pHddCtx;
9234 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009235
9236 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309237
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309238 if (NULL == pAdapter)
9239 {
9240 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9241 "%s: HDD adapter is Null", __func__);
9242 return -ENODEV;
9243 }
9244
9245 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9246 ret = wlan_hdd_validate_context(pHddCtx);
9247 if (0 != ret)
9248 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309249 return ret;
9250 }
9251
9252 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9253 pRoamProfile = &(pWextState->roamProfile);
9254
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309255 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9256 __func__, hdd_device_modetoString(pAdapter->device_mode),
9257 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309258
Jeff Johnson295189b2012-06-20 16:38:30 -07009259 memset(&params, 0, sizeof(params));
9260
9261 if (CSR_MAX_NUM_KEY <= key_index)
9262 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309263 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009266
9267 switch(pRoamProfile->EncryptionType.encryptionType[0])
9268 {
9269 case eCSR_ENCRYPT_TYPE_NONE:
9270 params.cipher = IW_AUTH_CIPHER_NONE;
9271 break;
9272
9273 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9274 case eCSR_ENCRYPT_TYPE_WEP40:
9275 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9276 break;
9277
9278 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9279 case eCSR_ENCRYPT_TYPE_WEP104:
9280 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9281 break;
9282
9283 case eCSR_ENCRYPT_TYPE_TKIP:
9284 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9285 break;
9286
9287 case eCSR_ENCRYPT_TYPE_AES:
9288 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9289 break;
9290
9291 default:
9292 params.cipher = IW_AUTH_CIPHER_NONE;
9293 break;
9294 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309295
c_hpothuaaf19692014-05-17 17:01:48 +05309296 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9297 TRACE_CODE_HDD_CFG80211_GET_KEY,
9298 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309299
Jeff Johnson295189b2012-06-20 16:38:30 -07009300 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9301 params.seq_len = 0;
9302 params.seq = NULL;
9303 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9304 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309305 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009306 return 0;
9307}
9308
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309309#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9310static int wlan_hdd_cfg80211_get_key(
9311 struct wiphy *wiphy,
9312 struct net_device *ndev,
9313 u8 key_index, bool pairwise,
9314 const u8 *mac_addr, void *cookie,
9315 void (*callback)(void *cookie, struct key_params*)
9316 )
9317#else
9318static int wlan_hdd_cfg80211_get_key(
9319 struct wiphy *wiphy,
9320 struct net_device *ndev,
9321 u8 key_index, const u8 *mac_addr, void *cookie,
9322 void (*callback)(void *cookie, struct key_params*)
9323 )
9324#endif
9325{
9326 int ret;
9327
9328 vos_ssr_protect(__func__);
9329#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9330 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9331 mac_addr, cookie, callback);
9332#else
9333 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9334 callback);
9335#endif
9336 vos_ssr_unprotect(__func__);
9337
9338 return ret;
9339}
9340
Jeff Johnson295189b2012-06-20 16:38:30 -07009341/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309342 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 * This function is used to delete the key information
9344 */
9345#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309346static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309348 u8 key_index,
9349 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 const u8 *mac_addr
9351 )
9352#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309353static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 struct net_device *ndev,
9355 u8 key_index,
9356 const u8 *mac_addr
9357 )
9358#endif
9359{
9360 int status = 0;
9361
9362 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309363 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009364 //it is observed that this is invalidating peer
9365 //key index whenever re-key is done. This is affecting data link.
9366 //It should be ok to ignore del_key.
9367#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309368 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9369 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009370 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9371 tCsrRoamSetKey setKey;
9372 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309373
Jeff Johnson295189b2012-06-20 16:38:30 -07009374 ENTER();
9375
9376 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9377 __func__,pAdapter->device_mode);
9378
9379 if (CSR_MAX_NUM_KEY <= key_index)
9380 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309381 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009382 key_index);
9383
9384 return -EINVAL;
9385 }
9386
9387 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9388 setKey.keyId = key_index;
9389
9390 if (mac_addr)
9391 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9392 else
9393 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9394
9395 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9396
9397 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009398 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309399 )
9400 {
9401
9402 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009403 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9404 if( pHostapdState->bssState == BSS_START)
9405 {
9406 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309407
Jeff Johnson295189b2012-06-20 16:38:30 -07009408 if ( status != eHAL_STATUS_SUCCESS )
9409 {
9410 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9411 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9412 __LINE__, status );
9413 }
9414 }
9415 }
9416 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309417 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 )
9419 {
9420 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9421
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309422 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9423
9424 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009425 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309426 __func__, setKey.peerMac[0], setKey.peerMac[1],
9427 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009428 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309429 if(pAdapter->sessionCtx.station.conn_info.connState ==
9430 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309432 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309434
Jeff Johnson295189b2012-06-20 16:38:30 -07009435 if ( 0 != status )
9436 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309437 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 "%s: sme_RoamSetKey failure, returned %d",
9439 __func__, status);
9440 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9441 return -EINVAL;
9442 }
9443 }
9444 }
9445#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009446 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 return status;
9448}
9449
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309450#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9451static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9452 struct net_device *ndev,
9453 u8 key_index,
9454 bool pairwise,
9455 const u8 *mac_addr
9456 )
9457#else
9458static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9459 struct net_device *ndev,
9460 u8 key_index,
9461 const u8 *mac_addr
9462 )
9463#endif
9464{
9465 int ret;
9466
9467 vos_ssr_protect(__func__);
9468#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9469 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9470 mac_addr);
9471#else
9472 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9473#endif
9474 vos_ssr_unprotect(__func__);
9475
9476 return ret;
9477}
9478
Jeff Johnson295189b2012-06-20 16:38:30 -07009479/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309480 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009481 * This function is used to set the default tx key index
9482 */
9483#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309484static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 struct net_device *ndev,
9486 u8 key_index,
9487 bool unicast, bool multicast)
9488#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309489static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 struct net_device *ndev,
9491 u8 key_index)
9492#endif
9493{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309494 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309495 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309496 hdd_wext_state_t *pWextState;
9497 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309498 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009499
9500 ENTER();
9501
Gopichand Nakkala29149562013-05-10 21:43:41 +05309502 if ((NULL == pAdapter))
9503 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309504 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309505 "invalid adapter");
9506 return -EINVAL;
9507 }
9508
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309509 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9510 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9511 pAdapter->sessionId, key_index));
9512
Gopichand Nakkala29149562013-05-10 21:43:41 +05309513 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9514 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9515
9516 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9517 {
9518 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9519 "invalid Wext state or HDD context");
9520 return -EINVAL;
9521 }
9522
Arif Hussain6d2a3322013-11-17 19:50:10 -08009523 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309525
Jeff Johnson295189b2012-06-20 16:38:30 -07009526 if (CSR_MAX_NUM_KEY <= key_index)
9527 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309528 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 key_index);
9530
9531 return -EINVAL;
9532 }
9533
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309534 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9535 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309536 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009537 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309538 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009539 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309540
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009542 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309543 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009544 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309545 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009546 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309547 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009548 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309550 {
9551 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309553
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 tCsrRoamSetKey setKey;
9555 v_U32_t roamId= 0xFF;
9556 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309557
9558 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009559 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309560
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 Keys->defaultIndex = (u8)key_index;
9562 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9563 setKey.keyId = key_index;
9564 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309565
9566 vos_mem_copy(&setKey.Key[0],
9567 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009568 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309569
Gopichand Nakkala29149562013-05-10 21:43:41 +05309570 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309571
9572 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009573 &pHddStaCtx->conn_info.bssId[0],
9574 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309575
Gopichand Nakkala29149562013-05-10 21:43:41 +05309576 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9577 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9578 eCSR_ENCRYPT_TYPE_WEP104)
9579 {
9580 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9581 even though ap is configured for WEP-40 encryption. In this canse the key length
9582 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9583 type(104) and switching encryption type to 40*/
9584 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9585 eCSR_ENCRYPT_TYPE_WEP40;
9586 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9587 eCSR_ENCRYPT_TYPE_WEP40;
9588 }
9589
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309590 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309592
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309594 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009595 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309596
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 if ( 0 != status )
9598 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309599 hddLog(VOS_TRACE_LEVEL_ERROR,
9600 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 status);
9602 return -EINVAL;
9603 }
9604 }
9605 }
9606
9607 /* In SoftAp mode setting key direction for default mode */
9608 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9609 {
9610 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9611 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9612 (eCSR_ENCRYPT_TYPE_AES !=
9613 pWextState->roamProfile.EncryptionType.encryptionType[0])
9614 )
9615 {
9616 /* Saving key direction for default key index to TX default */
9617 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9618 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9619 }
9620 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309621 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009622 return status;
9623}
9624
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309625#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9626static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9627 struct net_device *ndev,
9628 u8 key_index,
9629 bool unicast, bool multicast)
9630#else
9631static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9632 struct net_device *ndev,
9633 u8 key_index)
9634#endif
9635{
9636 int ret;
9637 vos_ssr_protect(__func__);
9638#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9639 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9640 multicast);
9641#else
9642 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9643#endif
9644 vos_ssr_unprotect(__func__);
9645
9646 return ret;
9647}
9648
Jeff Johnson295189b2012-06-20 16:38:30 -07009649/*
9650 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9651 * This function is used to inform the BSS details to nl80211 interface.
9652 */
9653static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9654 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9655{
9656 struct net_device *dev = pAdapter->dev;
9657 struct wireless_dev *wdev = dev->ieee80211_ptr;
9658 struct wiphy *wiphy = wdev->wiphy;
9659 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9660 int chan_no;
9661 int ie_length;
9662 const char *ie;
9663 unsigned int freq;
9664 struct ieee80211_channel *chan;
9665 int rssi = 0;
9666 struct cfg80211_bss *bss = NULL;
9667
9668 ENTER();
9669
9670 if( NULL == pBssDesc )
9671 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009672 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 return bss;
9674 }
9675
9676 chan_no = pBssDesc->channelId;
9677 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9678 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9679
9680 if( NULL == ie )
9681 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009682 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 return bss;
9684 }
9685
9686#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9687 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9688 {
9689 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9690 }
9691 else
9692 {
9693 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9694 }
9695#else
9696 freq = ieee80211_channel_to_frequency(chan_no);
9697#endif
9698
9699 chan = __ieee80211_get_channel(wiphy, freq);
9700
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309701 if (!chan) {
9702 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9703 return NULL;
9704 }
9705
Abhishek Singhaee43942014-06-16 18:55:47 +05309706 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009707
Abhishek Singhaee43942014-06-16 18:55:47 +05309708 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309709 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009710 pBssDesc->capabilityInfo,
9711 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309712 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009713}
9714
9715
9716
9717/*
9718 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9719 * This function is used to inform the BSS details to nl80211 interface.
9720 */
9721struct cfg80211_bss*
9722wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9723 tSirBssDescription *bss_desc
9724 )
9725{
9726 /*
9727 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9728 already exists in bss data base of cfg80211 for that particular BSS ID.
9729 Using cfg80211_inform_bss_frame to update the bss entry instead of
9730 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9731 now there is no possibility to get the mgmt(probe response) frame from PE,
9732 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9733 cfg80211_inform_bss_frame.
9734 */
9735 struct net_device *dev = pAdapter->dev;
9736 struct wireless_dev *wdev = dev->ieee80211_ptr;
9737 struct wiphy *wiphy = wdev->wiphy;
9738 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009739#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9740 qcom_ie_age *qie_age = NULL;
9741 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
9742#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009743 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009744#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009745 const char *ie =
9746 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
9747 unsigned int freq;
9748 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309749 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009750 struct cfg80211_bss *bss_status = NULL;
9751 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
9752 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07009753 hdd_context_t *pHddCtx;
9754 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07009755#ifdef WLAN_OPEN_SOURCE
9756 struct timespec ts;
9757#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009758
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309759 ENTER();
9760
Wilson Yangf80a0542013-10-07 13:02:37 -07009761 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9762 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -07009763 if (0 != status)
9764 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009765 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009766 }
9767
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309768 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07009769 if (!mgmt)
9770 {
9771 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9772 "%s: memory allocation failed ", __func__);
9773 return NULL;
9774 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009775
Jeff Johnson295189b2012-06-20 16:38:30 -07009776 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07009777
9778#ifdef WLAN_OPEN_SOURCE
9779 /* Android does not want the timestamp from the frame.
9780 Instead it wants a monotonic increasing value */
9781 get_monotonic_boottime(&ts);
9782 mgmt->u.probe_resp.timestamp =
9783 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
9784#else
9785 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
9787 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07009788
9789#endif
9790
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
9792 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009793
9794#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9795 /* GPS Requirement: need age ie per entry. Using vendor specific. */
9796 /* Assuming this is the last IE, copy at the end */
9797 ie_length -=sizeof(qcom_ie_age);
9798 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
9799 qie_age->element_id = QCOM_VENDOR_IE_ID;
9800 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
9801 qie_age->oui_1 = QCOM_OUI1;
9802 qie_age->oui_2 = QCOM_OUI2;
9803 qie_age->oui_3 = QCOM_OUI3;
9804 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
9805 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
9806#endif
9807
Jeff Johnson295189b2012-06-20 16:38:30 -07009808 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05309809 if (bss_desc->fProbeRsp)
9810 {
9811 mgmt->frame_control |=
9812 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
9813 }
9814 else
9815 {
9816 mgmt->frame_control |=
9817 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
9818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009819
9820#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309821 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009822 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
9823 {
9824 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9825 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309826 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009827 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
9828
9829 {
9830 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9831 }
9832 else
9833 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309834 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
9835 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07009836 kfree(mgmt);
9837 return NULL;
9838 }
9839#else
9840 freq = ieee80211_channel_to_frequency(chan_no);
9841#endif
9842 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009843 /*when the band is changed on the fly using the GUI, three things are done
9844 * 1. scan abort 2.flush scan results from cache 3.update the band with the new band user specified(refer to the hdd_setBand_helper function)
9845 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
9846 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
9847 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
9848 * and discards the channels correponding to previous band and calls back with zero bss results.
9849 * but if the time between band update and scan done callback is very small then band change will not reflect in SME and SME reports to HDD
9850 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
9851 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
9852 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
9853 * So drop the bss and continue to next bss.
9854 */
9855 if(chan == NULL)
9856 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309857 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07009858 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009859 return NULL;
9860 }
Sachin Ahuja40530ed2015-04-20 00:20:58 +05309861 /* Supplicant takes the signal strength in terms of mBm(100*dBm) */
9862 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0)) * 100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009863
Nirav Shah20ac06f2013-12-12 18:14:06 +05309864 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
9865 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
9866 chan->center_freq, (int)(rssi/100));
9867
Jeff Johnson295189b2012-06-20 16:38:30 -07009868 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
9869 frame_len, rssi, GFP_KERNEL);
9870 kfree(mgmt);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309871 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009872 return bss_status;
9873}
9874
9875/*
9876 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
9877 * This function is used to update the BSS data base of CFG8011
9878 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309879struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009880 tCsrRoamInfo *pRoamInfo
9881 )
9882{
9883 tCsrRoamConnectedProfile roamProfile;
9884 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9885 struct cfg80211_bss *bss = NULL;
9886
9887 ENTER();
9888
9889 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
9890 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
9891
9892 if (NULL != roamProfile.pBssDesc)
9893 {
Girish Gowlif4b68022014-08-28 23:18:57 +05309894 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9895 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009896
9897 if (NULL == bss)
9898 {
9899 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
9900 __func__);
9901 }
9902
9903 sme_RoamFreeConnectProfile(hHal, &roamProfile);
9904 }
9905 else
9906 {
9907 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
9908 __func__);
9909 }
9910 return bss;
9911}
9912
9913/*
9914 * FUNCTION: wlan_hdd_cfg80211_update_bss
9915 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309916static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
9917 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309919{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309920 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009921 tCsrScanResultInfo *pScanResult;
9922 eHalStatus status = 0;
9923 tScanResultHandle pResult;
9924 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009925 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009926
9927 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309928
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309929 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9930 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
9931 NO_SESSION, pAdapter->sessionId));
9932
Wilson Yangf80a0542013-10-07 13:02:37 -07009933 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9934
9935 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07009936 {
Wilson Yangf80a0542013-10-07 13:02:37 -07009937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9938 "%s:LOGP in Progress. Ignore!!!",__func__);
9939 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009940 }
9941
Wilson Yangf80a0542013-10-07 13:02:37 -07009942
9943 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05309944 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07009945 {
9946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9947 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
9948 return VOS_STATUS_E_PERM;
9949 }
9950
9951
Jeff Johnson295189b2012-06-20 16:38:30 -07009952 /*
9953 * start getting scan results and populate cgf80211 BSS database
9954 */
9955 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
9956
9957 /* no scan results */
9958 if (NULL == pResult)
9959 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309960 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
9961 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 return status;
9963 }
9964
9965 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
9966
9967 while (pScanResult)
9968 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309969 /*
9970 * cfg80211_inform_bss() is not updating ie field of bss entry, if
9971 * entry already exists in bss data base of cfg80211 for that
9972 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
9973 * bss entry instead of cfg80211_inform_bss, But this call expects
9974 * mgmt packet as input. As of now there is no possibility to get
9975 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07009976 * ieee80211_mgmt(probe response) and passing to c
9977 * fg80211_inform_bss_frame.
9978 * */
9979
9980 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9981 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309982
Jeff Johnson295189b2012-06-20 16:38:30 -07009983
9984 if (NULL == bss_status)
9985 {
9986 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009987 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009988 }
9989 else
9990 {
Yue Maf49ba872013-08-19 12:04:25 -07009991 cfg80211_put_bss(
9992#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9993 wiphy,
9994#endif
9995 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009996 }
9997
9998 pScanResult = sme_ScanResultGetNext(hHal, pResult);
9999 }
10000
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010001 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010002
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010003 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010004}
10005
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010006void
10007hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10008{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010009 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010010 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010011} /****** end hddPrintMacAddr() ******/
10012
10013void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010014hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010015{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010016 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010017 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010018 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10019 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10020 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010021} /****** end hddPrintPmkId() ******/
10022
10023//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10024//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10025
10026//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10027//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10028
10029#define dump_bssid(bssid) \
10030 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010031 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10032 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010033 }
10034
10035#define dump_pmkid(pMac, pmkid) \
10036 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010037 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10038 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010039 }
10040
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010041#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010042/*
10043 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10044 * This function is used to notify the supplicant of a new PMKSA candidate.
10045 */
10046int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010047 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010048 int index, bool preauth )
10049{
Jeff Johnsone7245742012-09-05 17:12:55 -070010050#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010051 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010052 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010053
10054 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010055 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010056
10057 if( NULL == pRoamInfo )
10058 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010059 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010060 return -EINVAL;
10061 }
10062
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010063 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10064 {
10065 dump_bssid(pRoamInfo->bssid);
10066 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010067 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010068 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010069#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010070 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010071}
10072#endif //FEATURE_WLAN_LFR
10073
Yue Maef608272013-04-08 23:09:17 -070010074#ifdef FEATURE_WLAN_LFR_METRICS
10075/*
10076 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10077 * 802.11r/LFR metrics reporting function to report preauth initiation
10078 *
10079 */
10080#define MAX_LFR_METRICS_EVENT_LENGTH 100
10081VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10082 tCsrRoamInfo *pRoamInfo)
10083{
10084 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10085 union iwreq_data wrqu;
10086
10087 ENTER();
10088
10089 if (NULL == pAdapter)
10090 {
10091 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10092 return VOS_STATUS_E_FAILURE;
10093 }
10094
10095 /* create the event */
10096 memset(&wrqu, 0, sizeof(wrqu));
10097 memset(metrics_notification, 0, sizeof(metrics_notification));
10098
10099 wrqu.data.pointer = metrics_notification;
10100 wrqu.data.length = scnprintf(metrics_notification,
10101 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10102 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10103
10104 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10105
10106 EXIT();
10107
10108 return VOS_STATUS_SUCCESS;
10109}
10110
10111/*
10112 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10113 * 802.11r/LFR metrics reporting function to report preauth completion
10114 * or failure
10115 */
10116VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10117 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10118{
10119 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10120 union iwreq_data wrqu;
10121
10122 ENTER();
10123
10124 if (NULL == pAdapter)
10125 {
10126 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10127 return VOS_STATUS_E_FAILURE;
10128 }
10129
10130 /* create the event */
10131 memset(&wrqu, 0, sizeof(wrqu));
10132 memset(metrics_notification, 0, sizeof(metrics_notification));
10133
10134 scnprintf(metrics_notification, sizeof(metrics_notification),
10135 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10136 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10137
10138 if (1 == preauth_status)
10139 strncat(metrics_notification, " TRUE", 5);
10140 else
10141 strncat(metrics_notification, " FALSE", 6);
10142
10143 wrqu.data.pointer = metrics_notification;
10144 wrqu.data.length = strlen(metrics_notification);
10145
10146 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10147
10148 EXIT();
10149
10150 return VOS_STATUS_SUCCESS;
10151}
10152
10153/*
10154 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10155 * 802.11r/LFR metrics reporting function to report handover initiation
10156 *
10157 */
10158VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10159 tCsrRoamInfo *pRoamInfo)
10160{
10161 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10162 union iwreq_data wrqu;
10163
10164 ENTER();
10165
10166 if (NULL == pAdapter)
10167 {
10168 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10169 return VOS_STATUS_E_FAILURE;
10170 }
10171
10172 /* create the event */
10173 memset(&wrqu, 0, sizeof(wrqu));
10174 memset(metrics_notification, 0, sizeof(metrics_notification));
10175
10176 wrqu.data.pointer = metrics_notification;
10177 wrqu.data.length = scnprintf(metrics_notification,
10178 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10179 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10180
10181 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10182
10183 EXIT();
10184
10185 return VOS_STATUS_SUCCESS;
10186}
10187#endif
10188
Jeff Johnson295189b2012-06-20 16:38:30 -070010189/*
10190 * FUNCTION: hdd_cfg80211_scan_done_callback
10191 * scanning callback function, called after finishing scan
10192 *
10193 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010194static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010195 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10196{
10197 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010198 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010199 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010200 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010201 struct cfg80211_scan_request *req = NULL;
10202 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010203 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010204 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010205 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010206 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010207
10208 ENTER();
10209
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010210 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10211 if (0 != wlan_hdd_validate_context(pHddCtx)) {
10212 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
10213 goto allow_suspend;
10214 }
10215
10216 pScanInfo = &pHddCtx->scan_info;
10217
Jeff Johnson295189b2012-06-20 16:38:30 -070010218 hddLog(VOS_TRACE_LEVEL_INFO,
10219 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010220 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010221 __func__, halHandle, pContext, (int) scanId, (int) status);
10222
Kiet Lamac06e2c2013-10-23 16:25:07 +053010223 pScanInfo->mScanPendingCounter = 0;
10224
Jeff Johnson295189b2012-06-20 16:38:30 -070010225 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010226 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010227 &pScanInfo->scan_req_completion_event,
10228 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010229 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010230 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010231 hddLog(VOS_TRACE_LEVEL_ERROR,
10232 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010233 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010234 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010235 }
10236
Yue Maef608272013-04-08 23:09:17 -070010237 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010238 {
10239 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010240 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010241 }
10242
10243 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010244 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 {
10246 hddLog(VOS_TRACE_LEVEL_INFO,
10247 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010248 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010249 (int) scanId);
10250 }
10251
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010252 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010253 pAdapter);
10254
10255 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010256 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010257
10258
10259 /* If any client wait scan result through WEXT
10260 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010261 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010262 {
10263 /* The other scan request waiting for current scan finish
10264 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010265 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010266 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010267 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 }
10269 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010270 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010271 {
10272 struct net_device *dev = pAdapter->dev;
10273 union iwreq_data wrqu;
10274 int we_event;
10275 char *msg;
10276
10277 memset(&wrqu, '\0', sizeof(wrqu));
10278 we_event = SIOCGIWSCAN;
10279 msg = NULL;
10280 wireless_send_event(dev, we_event, &wrqu, msg);
10281 }
10282 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010283 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010284
10285 /* Get the Scan Req */
10286 req = pAdapter->request;
10287
10288 if (!req)
10289 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010290 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010291 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010292 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010293 }
10294
Jeff Johnson295189b2012-06-20 16:38:30 -070010295 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010296 /* Scan is no longer pending */
10297 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010298
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010299 /* last_scan_timestamp is used to decide if new scan
10300 * is needed or not on station interface. If last station
10301 * scan time and new station scan time is less then
10302 * last_scan_timestamp ; driver will return cached scan.
10303 */
10304 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10305 {
10306 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10307
10308 if ( req->n_channels )
10309 {
10310 for (i = 0; i < req->n_channels ; i++ )
10311 {
10312 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10313 }
10314 /* store no of channel scanned */
10315 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10316 }
10317
10318 }
10319
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010320 /*
10321 * cfg80211_scan_done informing NL80211 about completion
10322 * of scanning
10323 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010324 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10325 {
10326 aborted = true;
10327 }
10328 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010329 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010330
Siddharth Bhal76972212014-10-15 16:22:51 +053010331 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10332 /* Generate new random mac addr for next scan */
10333 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10334 hdd_processSpoofMacAddrRequest(pHddCtx);
10335 }
10336
Jeff Johnsone7245742012-09-05 17:12:55 -070010337allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010338 /* release the wake lock at the end of the scan*/
10339 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -070010340
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010341 /* Acquire wakelock to handle the case where APP's tries to suspend
10342 * immediatly after the driver gets connect request(i.e after scan)
10343 * from supplicant, this result in app's is suspending and not able
10344 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053010345 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010346
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010347#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010348 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010349#endif
10350
Jeff Johnson295189b2012-06-20 16:38:30 -070010351 EXIT();
10352 return 0;
10353}
10354
10355/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010356 * FUNCTION: hdd_isConnectionInProgress
10357 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010358 *
10359 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010360v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010361{
10362 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10363 hdd_station_ctx_t *pHddStaCtx = NULL;
10364 hdd_adapter_t *pAdapter = NULL;
10365 VOS_STATUS status = 0;
10366 v_U8_t staId = 0;
10367 v_U8_t *staMac = NULL;
10368
c_hpothu9b781ba2013-12-30 20:57:45 +053010369 if (TRUE == pHddCtx->btCoexModeSet)
10370 {
10371 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010372 FL("BTCoex Mode operation in progress"));
10373 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010374 }
10375
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010376 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10377
10378 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10379 {
10380 pAdapter = pAdapterNode->pAdapter;
10381
10382 if( pAdapter )
10383 {
10384 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010385 "%s: Adapter with device mode %s (%d) exists",
10386 __func__, hdd_device_modetoString(pAdapter->device_mode),
10387 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010388 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010389 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10390 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10391 (eConnectionState_Connecting ==
10392 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10393 {
10394 hddLog(VOS_TRACE_LEVEL_ERROR,
10395 "%s: %p(%d) Connection is in progress", __func__,
10396 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10397 return VOS_TRUE;
10398 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010399 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010400 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010401 {
10402 hddLog(VOS_TRACE_LEVEL_ERROR,
10403 "%s: %p(%d) Reassociation is in progress", __func__,
10404 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10405 return VOS_TRUE;
10406 }
10407 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010408 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10409 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010410 {
10411 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10412 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010413 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010414 {
10415 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10416 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010417 "%s: client " MAC_ADDRESS_STR
10418 " is in the middle of WPS/EAPOL exchange.", __func__,
10419 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010420 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010421 }
10422 }
10423 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10424 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10425 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010426 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10427 ptSapContext pSapCtx = NULL;
10428 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10429 if(pSapCtx == NULL){
10430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10431 FL("psapCtx is NULL"));
10432 return VOS_FALSE;
10433 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010434 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10435 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010436 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10437 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010438 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010439 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010440
10441 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010442 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10443 "middle of WPS/EAPOL exchange.", __func__,
10444 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010445 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010446 }
10447 }
10448 }
10449 }
10450 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10451 pAdapterNode = pNext;
10452 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010453 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010454}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010455
10456/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010457 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010458 * this scan respond to scan trigger and update cfg80211 scan database
10459 * later, scan dump command can be used to recieve scan results
10460 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010461int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010462#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10463 struct net_device *dev,
10464#endif
10465 struct cfg80211_scan_request *request)
10466{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010467 hdd_adapter_t *pAdapter = NULL;
10468 hdd_context_t *pHddCtx = NULL;
10469 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010470 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010471 tCsrScanRequest scanRequest;
10472 tANI_U8 *channelList = NULL, i;
10473 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010474 int status;
10475 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010476 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010477 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010478
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010479#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10480 struct net_device *dev = NULL;
10481 if (NULL == request)
10482 {
10483 hddLog(VOS_TRACE_LEVEL_ERROR,
10484 "%s: scan req param null", __func__);
10485 return -EINVAL;
10486 }
10487 dev = request->wdev->netdev;
10488#endif
10489
10490 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10491 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10492 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10493
Jeff Johnson295189b2012-06-20 16:38:30 -070010494 ENTER();
10495
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010496 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10497 __func__, hdd_device_modetoString(pAdapter->device_mode),
10498 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010499
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010500 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010501 if (0 != status)
10502 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010503 return status;
10504 }
10505
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010506 if (NULL == pwextBuf)
10507 {
10508 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10509 __func__);
10510 return -EIO;
10511 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010512 cfg_param = pHddCtx->cfg_ini;
10513 pScanInfo = &pHddCtx->scan_info;
10514
Jeff Johnson295189b2012-06-20 16:38:30 -070010515#ifdef WLAN_BTAMP_FEATURE
10516 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010517 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010518 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010519 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010520 "%s: No scanning when AMP is on", __func__);
10521 return -EOPNOTSUPP;
10522 }
10523#endif
10524 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010525 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010526 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010527 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010528 "%s: Not scanning on device_mode = %s (%d)",
10529 __func__, hdd_device_modetoString(pAdapter->device_mode),
10530 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010531 return -EOPNOTSUPP;
10532 }
10533
10534 if (TRUE == pScanInfo->mScanPending)
10535 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010536 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10537 {
10538 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10539 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010540 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010541 }
10542
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010543 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010544 //Channel and action frame is pending
10545 //Otherwise Cancel Remain On Channel and allow Scan
10546 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010547 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010548 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010549 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010550 return -EBUSY;
10551 }
10552
Jeff Johnson295189b2012-06-20 16:38:30 -070010553 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10554 {
10555 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010556 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010557 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010558 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010559 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10560 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010561 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010562 "%s: MAX TM Level Scan not allowed", __func__);
10563 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010564 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010565 }
10566 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10567
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010568 /* Check if scan is allowed at this point of time.
10569 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010570 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010571 {
10572 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10573 return -EBUSY;
10574 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010575
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10577
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010578 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
10579 (int)request->n_ssids);
10580
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010581
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010582 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10583 * Becasue of this, driver is assuming that this is not wildcard scan and so
10584 * is not aging out the scan results.
10585 */
10586 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010587 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010588 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010589 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010590
10591 if ((request->ssids) && (0 < request->n_ssids))
10592 {
10593 tCsrSSIDInfo *SsidInfo;
10594 int j;
10595 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10596 /* Allocate num_ssid tCsrSSIDInfo structure */
10597 SsidInfo = scanRequest.SSIDs.SSIDList =
10598 ( tCsrSSIDInfo *)vos_mem_malloc(
10599 request->n_ssids*sizeof(tCsrSSIDInfo));
10600
10601 if(NULL == scanRequest.SSIDs.SSIDList)
10602 {
10603 hddLog(VOS_TRACE_LEVEL_ERROR,
10604 "%s: memory alloc failed SSIDInfo buffer", __func__);
10605 return -ENOMEM;
10606 }
10607
10608 /* copy all the ssid's and their length */
10609 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10610 {
10611 /* get the ssid length */
10612 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10613 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10614 SsidInfo->SSID.length);
10615 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10616 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10617 j, SsidInfo->SSID.ssId);
10618 }
10619 /* set the scan type to active */
10620 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10621 }
10622 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010623 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010624 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10625 TRACE_CODE_HDD_CFG80211_SCAN,
10626 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010627 /* set the scan type to active */
10628 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010630 else
10631 {
10632 /*Set the scan type to default type, in this case it is ACTIVE*/
10633 scanRequest.scanType = pScanInfo->scan_mode;
10634 }
10635 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10636 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010637
10638 /* set BSSType to default type */
10639 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10640
10641 /*TODO: scan the requested channels only*/
10642
10643 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010644 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010645 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010646 hddLog(VOS_TRACE_LEVEL_WARN,
10647 "No of Scan Channels exceeded limit: %d", request->n_channels);
10648 request->n_channels = MAX_CHANNEL;
10649 }
10650
10651 hddLog(VOS_TRACE_LEVEL_INFO,
10652 "No of Scan Channels: %d", request->n_channels);
10653
10654
10655 if( request->n_channels )
10656 {
10657 char chList [(request->n_channels*5)+1];
10658 int len;
10659 channelList = vos_mem_malloc( request->n_channels );
10660 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010661 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010662 hddLog(VOS_TRACE_LEVEL_ERROR,
10663 "%s: memory alloc failed channelList", __func__);
10664 status = -ENOMEM;
10665 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010666 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010667
10668 for( i = 0, len = 0; i < request->n_channels ; i++ )
10669 {
10670 channelList[i] = request->channels[i]->hw_value;
10671 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10672 }
10673
Nirav Shah20ac06f2013-12-12 18:14:06 +053010674 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010675 "Channel-List: %s ", chList);
10676 }
c_hpothu53512302014-04-15 18:49:53 +053010677
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010678 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10679 scanRequest.ChannelInfo.ChannelList = channelList;
10680
10681 /* set requestType to full scan */
10682 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10683
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010684 /* if there is back to back scan happening in driver with in
10685 * nDeferScanTimeInterval interval driver should defer new scan request
10686 * and should provide last cached scan results instead of new channel list.
10687 * This rule is not applicable if scan is p2p scan.
10688 * This condition will work only in case when last request no of channels
10689 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010690 * This should be done only in connected state
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010691 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010692
Agarwal Ashish57e84372014-12-05 18:26:53 +053010693 if ((VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
10694 {
10695 if ( pScanInfo->last_scan_timestamp !=0 &&
10696 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
10697 {
10698 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
10699 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
10700 vos_mem_compare(pScanInfo->last_scan_channelList,
10701 channelList, pScanInfo->last_scan_numChannels))
10702 {
10703 hddLog(VOS_TRACE_LEVEL_WARN,
10704 " New and old station scan time differ is less then %u",
10705 pHddCtx->cfg_ini->nDeferScanTimeInterval);
10706
10707 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010708 pAdapter);
10709
Agarwal Ashish57e84372014-12-05 18:26:53 +053010710 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010711 "Return old cached scan as all channels and no of channels are same");
10712
Agarwal Ashish57e84372014-12-05 18:26:53 +053010713 if (0 > ret)
10714 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010715
Agarwal Ashish57e84372014-12-05 18:26:53 +053010716 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010717
10718 status = eHAL_STATUS_SUCCESS;
10719 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053010720 }
10721 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010722 }
10723
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010724 /* Flush the scan results(only p2p beacons) for STA scan and P2P
10725 * search (Flush on both full scan and social scan but not on single
10726 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
10727 */
10728
10729 /* Supplicant does single channel scan after 8-way handshake
10730 * and in that case driver shoudnt flush scan results. If
10731 * driver flushes the scan results here and unfortunately if
10732 * the AP doesnt respond to our probe req then association
10733 * fails which is not desired
10734 */
10735
10736 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
10737 {
10738 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
10739 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
10740 pAdapter->sessionId );
10741 }
10742
10743 if( request->ie_len )
10744 {
10745 /* save this for future association (join requires this) */
10746 /*TODO: Array needs to be converted to dynamic allocation,
10747 * as multiple ie.s can be sent in cfg80211_scan_request structure
10748 * CR 597966
10749 */
10750 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
10751 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
10752 pScanInfo->scanAddIE.length = request->ie_len;
10753
10754 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10755 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10756 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010757 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053010758 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070010759 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010760 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
10761 memcpy( pwextBuf->roamProfile.addIEScan,
10762 request->ie, request->ie_len);
10763 }
10764 else
10765 {
10766 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
10767 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070010768 }
10769
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010770 }
10771 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
10772 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
10773
10774 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
10775 request->ie_len);
10776 if (pP2pIe != NULL)
10777 {
10778#ifdef WLAN_FEATURE_P2P_DEBUG
10779 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
10780 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
10781 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053010782 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010783 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
10784 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10785 "Go nego completed to Connection is started");
10786 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10787 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053010788 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010789 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
10790 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010791 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010792 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
10793 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10794 "Disconnected state to Connection is started");
10795 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10796 "for 4way Handshake");
10797 }
10798#endif
10799
10800 /* no_cck will be set during p2p find to disable 11b rates */
10801 if(TRUE == request->no_cck)
10802 {
10803 hddLog(VOS_TRACE_LEVEL_INFO,
10804 "%s: This is a P2P Search", __func__);
10805 scanRequest.p2pSearch = 1;
10806
10807 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053010808 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010809 /* set requestType to P2P Discovery */
10810 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
10811 }
10812
10813 /*
10814 Skip Dfs Channel in case of P2P Search
10815 if it is set in ini file
10816 */
10817 if(cfg_param->skipDfsChnlInP2pSearch)
10818 {
10819 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010820 }
10821 else
10822 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010823 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010824 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010825
Agarwal Ashish4f616132013-12-30 23:32:50 +053010826 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010827 }
10828 }
10829
10830 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
10831
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010832#ifdef FEATURE_WLAN_TDLS
10833 /* if tdls disagree scan right now, return immediately.
10834 tdls will schedule the scan when scan is allowed. (return SUCCESS)
10835 or will reject the scan if any TDLS is in progress. (return -EBUSY)
10836 */
10837 status = wlan_hdd_tdls_scan_callback (pAdapter,
10838 wiphy,
10839#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10840 dev,
10841#endif
10842 request);
10843 if(status <= 0)
10844 {
10845 if(!status)
10846 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
10847 "scan rejected %d", __func__, status);
10848 else
10849 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
10850 __func__, status);
10851
10852 return status;
10853 }
10854#endif
10855
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010856 /* acquire the wakelock to avoid the apps suspend during the scan. To
10857 * address the following issues.
10858 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
10859 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
10860 * for long time, this result in apps running at full power for long time.
10861 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
10862 * be stuck in full power because of resume BMPS
10863 */
10864 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -070010865
Nirav Shah20ac06f2013-12-12 18:14:06 +053010866 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10867 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010868 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
10869 scanRequest.requestType, scanRequest.scanType,
10870 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053010871 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
10872
Siddharth Bhal76972212014-10-15 16:22:51 +053010873 if (pHddCtx->spoofMacAddr.isEnabled)
10874 {
10875 hddLog(VOS_TRACE_LEVEL_INFO,
10876 "%s: MAC Spoofing enabled for current scan", __func__);
10877 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
10878 * to fill TxBds for probe request during current scan
10879 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053010880 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053010881 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053010882
10883 if(status != VOS_STATUS_SUCCESS)
10884 {
10885 hdd_allow_suspend();
10886 status = -EFAULT;
10887 goto free_mem;
10888 }
Siddharth Bhal76972212014-10-15 16:22:51 +053010889 }
10890
Jeff Johnsone7245742012-09-05 17:12:55 -070010891 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010892 pAdapter->sessionId, &scanRequest, &scanId,
10893 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070010894
Jeff Johnson295189b2012-06-20 16:38:30 -070010895 if (eHAL_STATUS_SUCCESS != status)
10896 {
10897 hddLog(VOS_TRACE_LEVEL_ERROR,
10898 "%s: sme_ScanRequest returned error %d", __func__, status);
10899 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010900 if(eHAL_STATUS_RESOURCES == status)
10901 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010902 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
10903 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010904 status = -EBUSY;
10905 } else {
10906 status = -EIO;
10907 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010908 hdd_allow_suspend();
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010909
10910#ifdef FEATURE_WLAN_TDLS
10911 wlan_hdd_tdls_scan_done_callback(pAdapter);
10912#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010913 goto free_mem;
10914 }
10915
10916 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010917 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010918 pAdapter->request = request;
10919 pScanInfo->scanId = scanId;
10920
10921 complete(&pScanInfo->scan_req_completion_event);
10922
10923free_mem:
10924 if( scanRequest.SSIDs.SSIDList )
10925 {
10926 vos_mem_free(scanRequest.SSIDs.SSIDList);
10927 }
10928
10929 if( channelList )
10930 vos_mem_free( channelList );
10931
10932 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010933 return status;
10934}
10935
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010936int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
10937#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10938 struct net_device *dev,
10939#endif
10940 struct cfg80211_scan_request *request)
10941{
10942 int ret;
10943
10944 vos_ssr_protect(__func__);
10945 ret = __wlan_hdd_cfg80211_scan(wiphy,
10946#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10947 dev,
10948#endif
10949 request);
10950 vos_ssr_unprotect(__func__);
10951
10952 return ret;
10953}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010954
10955void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
10956{
10957 v_U8_t iniDot11Mode =
10958 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
10959 eHddDot11Mode hddDot11Mode = iniDot11Mode;
10960
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010961 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
10962 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010963 switch ( iniDot11Mode )
10964 {
10965 case eHDD_DOT11_MODE_AUTO:
10966 case eHDD_DOT11_MODE_11ac:
10967 case eHDD_DOT11_MODE_11ac_ONLY:
10968#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053010969 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
10970 sme_IsFeatureSupportedByFW(DOT11AC) )
10971 hddDot11Mode = eHDD_DOT11_MODE_11ac;
10972 else
10973 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010974#else
10975 hddDot11Mode = eHDD_DOT11_MODE_11n;
10976#endif
10977 break;
10978 case eHDD_DOT11_MODE_11n:
10979 case eHDD_DOT11_MODE_11n_ONLY:
10980 hddDot11Mode = eHDD_DOT11_MODE_11n;
10981 break;
10982 default:
10983 hddDot11Mode = iniDot11Mode;
10984 break;
10985 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053010986#ifdef WLAN_FEATURE_AP_HT40_24G
10987 if (operationChannel > SIR_11B_CHANNEL_END)
10988#endif
10989 {
10990 /* This call decides required channel bonding mode */
10991 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010992 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
10993 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053010994 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010995}
10996
Jeff Johnson295189b2012-06-20 16:38:30 -070010997/*
10998 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010999 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011000 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011001int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011002 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011003{
11004 int status = 0;
11005 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011006 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011007 v_U32_t roamId;
11008 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011009 eCsrAuthType RSNAuthType;
11010
11011 ENTER();
11012
11013 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011014 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11015
11016 status = wlan_hdd_validate_context(pHddCtx);
11017 if (status)
11018 {
Yue Mae36e3552014-03-05 17:06:20 -080011019 return status;
11020 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011021
Jeff Johnson295189b2012-06-20 16:38:30 -070011022 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11023 {
11024 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11025 return -EINVAL;
11026 }
11027
11028 pRoamProfile = &pWextState->roamProfile;
11029
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011030 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011031 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011032 hdd_station_ctx_t *pHddStaCtx;
11033 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011034
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011035 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011036 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11037 {
11038 /*QoS not enabled in cfg file*/
11039 pRoamProfile->uapsd_mask = 0;
11040 }
11041 else
11042 {
11043 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011044 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011045 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11046 }
11047
11048 pRoamProfile->SSIDs.numOfSSIDs = 1;
11049 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11050 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011051 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011052 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11053 ssid, ssid_len);
11054
11055 if (bssid)
11056 {
11057 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11058 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11059 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011060 /* Save BSSID in seperate variable as well, as RoamProfile
11061 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011062 case of join failure we should send valid BSSID to supplicant
11063 */
11064 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11065 WNI_CFG_BSSID_LEN);
11066 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011067 else
11068 {
11069 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011071
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011072 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11073 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011074 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11075 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011076 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011077 /*set gen ie*/
11078 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11079 /*set auth*/
11080 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11081 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011082#ifdef FEATURE_WLAN_WAPI
11083 if (pAdapter->wapi_info.nWapiMode)
11084 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011085 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011086 switch (pAdapter->wapi_info.wapiAuthMode)
11087 {
11088 case WAPI_AUTH_MODE_PSK:
11089 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011090 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011091 pAdapter->wapi_info.wapiAuthMode);
11092 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11093 break;
11094 }
11095 case WAPI_AUTH_MODE_CERT:
11096 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011097 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011098 pAdapter->wapi_info.wapiAuthMode);
11099 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11100 break;
11101 }
11102 } // End of switch
11103 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11104 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11105 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011106 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011107 pRoamProfile->AuthType.numEntries = 1;
11108 pRoamProfile->EncryptionType.numEntries = 1;
11109 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11110 pRoamProfile->mcEncryptionType.numEntries = 1;
11111 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11112 }
11113 }
11114#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011115#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011116 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011117 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11118 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11119 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011120 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11121 sizeof (tSirGtkOffloadParams));
11122 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011123 }
11124#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011125 pRoamProfile->csrPersona = pAdapter->device_mode;
11126
Jeff Johnson32d95a32012-09-10 13:15:23 -070011127 if( operatingChannel )
11128 {
11129 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11130 pRoamProfile->ChannelInfo.numOfChannels = 1;
11131 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011132 else
11133 {
11134 pRoamProfile->ChannelInfo.ChannelList = NULL;
11135 pRoamProfile->ChannelInfo.numOfChannels = 0;
11136 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011137 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11138 {
11139 hdd_select_cbmode(pAdapter,operatingChannel);
11140 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011141
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011142 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
11143 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011144 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011145 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011146 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
11147 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011148 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11149 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011150 {
11151 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11152 "%s: Set HDD connState to eConnectionState_Connecting",
11153 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011154 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11155 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011156 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011157 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011158 pAdapter->sessionId, pRoamProfile, &roamId);
11159
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011160 if ((eHAL_STATUS_SUCCESS != status) &&
11161 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11162 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011163
11164 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011165 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
11166 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
11167 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011168 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011169 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011170 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011171
11172 pRoamProfile->ChannelInfo.ChannelList = NULL;
11173 pRoamProfile->ChannelInfo.numOfChannels = 0;
11174
Jeff Johnson295189b2012-06-20 16:38:30 -070011175 }
11176 else
11177 {
11178 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11179 return -EINVAL;
11180 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011181 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011182 return status;
11183}
11184
11185/*
11186 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11187 * This function is used to set the authentication type (OPEN/SHARED).
11188 *
11189 */
11190static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11191 enum nl80211_auth_type auth_type)
11192{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011193 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011194 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11195
11196 ENTER();
11197
11198 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011199 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011200 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011201 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011202 hddLog(VOS_TRACE_LEVEL_INFO,
11203 "%s: set authentication type to AUTOSWITCH", __func__);
11204 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11205 break;
11206
11207 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011208#ifdef WLAN_FEATURE_VOWIFI_11R
11209 case NL80211_AUTHTYPE_FT:
11210#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011211 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011212 "%s: set authentication type to OPEN", __func__);
11213 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11214 break;
11215
11216 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011217 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011218 "%s: set authentication type to SHARED", __func__);
11219 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11220 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011221#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011222 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011223 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011224 "%s: set authentication type to CCKM WPA", __func__);
11225 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11226 break;
11227#endif
11228
11229
11230 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011231 hddLog(VOS_TRACE_LEVEL_ERROR,
11232 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011233 auth_type);
11234 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11235 return -EINVAL;
11236 }
11237
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011238 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011239 pHddStaCtx->conn_info.authType;
11240 return 0;
11241}
11242
11243/*
11244 * FUNCTION: wlan_hdd_set_akm_suite
11245 * This function is used to set the key mgmt type(PSK/8021x).
11246 *
11247 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011248static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011249 u32 key_mgmt
11250 )
11251{
11252 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11253 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011254 /* Should be in ieee802_11_defs.h */
11255#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11256#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011257 /*set key mgmt type*/
11258 switch(key_mgmt)
11259 {
11260 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011261 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011262#ifdef WLAN_FEATURE_VOWIFI_11R
11263 case WLAN_AKM_SUITE_FT_PSK:
11264#endif
11265 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011266 __func__);
11267 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11268 break;
11269
11270 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011271 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011272#ifdef WLAN_FEATURE_VOWIFI_11R
11273 case WLAN_AKM_SUITE_FT_8021X:
11274#endif
11275 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011276 __func__);
11277 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11278 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011279#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011280#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11281#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11282 case WLAN_AKM_SUITE_CCKM:
11283 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11284 __func__);
11285 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11286 break;
11287#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011288#ifndef WLAN_AKM_SUITE_OSEN
11289#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11290 case WLAN_AKM_SUITE_OSEN:
11291 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11292 __func__);
11293 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11294 break;
11295#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011296
11297 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011298 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011299 __func__, key_mgmt);
11300 return -EINVAL;
11301
11302 }
11303 return 0;
11304}
11305
11306/*
11307 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011308 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011309 * (NONE/WEP40/WEP104/TKIP/CCMP).
11310 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011311static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11312 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011313 bool ucast
11314 )
11315{
11316 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011317 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011318 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11319
11320 ENTER();
11321
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011322 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011323 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011324 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011325 __func__, cipher);
11326 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11327 }
11328 else
11329 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011330
Jeff Johnson295189b2012-06-20 16:38:30 -070011331 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011332 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011333 {
11334 case IW_AUTH_CIPHER_NONE:
11335 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11336 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011337
Jeff Johnson295189b2012-06-20 16:38:30 -070011338 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011339 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011340 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011341
Jeff Johnson295189b2012-06-20 16:38:30 -070011342 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011343 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011344 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011345
Jeff Johnson295189b2012-06-20 16:38:30 -070011346 case WLAN_CIPHER_SUITE_TKIP:
11347 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11348 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011349
Jeff Johnson295189b2012-06-20 16:38:30 -070011350 case WLAN_CIPHER_SUITE_CCMP:
11351 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11352 break;
11353#ifdef FEATURE_WLAN_WAPI
11354 case WLAN_CIPHER_SUITE_SMS4:
11355 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11356 break;
11357#endif
11358
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011359#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011360 case WLAN_CIPHER_SUITE_KRK:
11361 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11362 break;
11363#endif
11364 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011365 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011366 __func__, cipher);
11367 return -EOPNOTSUPP;
11368 }
11369 }
11370
11371 if (ucast)
11372 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011373 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 __func__, encryptionType);
11375 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11376 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011377 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011378 encryptionType;
11379 }
11380 else
11381 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011382 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011383 __func__, encryptionType);
11384 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11385 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11386 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11387 }
11388
11389 return 0;
11390}
11391
11392
11393/*
11394 * FUNCTION: wlan_hdd_cfg80211_set_ie
11395 * This function is used to parse WPA/RSN IE's.
11396 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011397int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
11398 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -070011399 size_t ie_len
11400 )
11401{
11402 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11403 u8 *genie = ie;
11404 v_U16_t remLen = ie_len;
11405#ifdef FEATURE_WLAN_WAPI
11406 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11407 u16 *tmp;
11408 v_U16_t akmsuiteCount;
11409 int *akmlist;
11410#endif
11411 ENTER();
11412
11413 /* clear previous assocAddIE */
11414 pWextState->assocAddIE.length = 0;
11415 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011416 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011417
11418 while (remLen >= 2)
11419 {
11420 v_U16_t eLen = 0;
11421 v_U8_t elementId;
11422 elementId = *genie++;
11423 eLen = *genie++;
11424 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011425
Arif Hussain6d2a3322013-11-17 19:50:10 -080011426 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011427 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011428
11429 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011430 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011431 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011432 if (4 > eLen) /* should have at least OUI which is 4 bytes so extra 2 bytes not needed */
Jeff Johnson295189b2012-06-20 16:38:30 -070011433 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011434 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011435 "%s: Invalid WPA IE", __func__);
11436 return -EINVAL;
11437 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011438 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011439 {
11440 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011441 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011442 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011443
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011444 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011445 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011446 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11447 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011448 VOS_ASSERT(0);
11449 return -ENOMEM;
11450 }
11451 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11452 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11453 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011454
Jeff Johnson295189b2012-06-20 16:38:30 -070011455 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11456 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11457 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11458 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011459 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11460 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011461 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11462 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11463 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11464 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11465 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11466 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011467 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011468 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011469 {
11470 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011471 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011472 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011473
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011474 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011475 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011476 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11477 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011478 VOS_ASSERT(0);
11479 return -ENOMEM;
11480 }
11481 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11482 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11483 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011484
Jeff Johnson295189b2012-06-20 16:38:30 -070011485 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11486 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11487 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011488#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011489 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11490 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011491 /*Consider WFD IE, only for P2P Client */
11492 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11493 {
11494 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011495 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011496 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011497
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011498 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011499 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011500 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11501 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011502 VOS_ASSERT(0);
11503 return -ENOMEM;
11504 }
11505 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11506 // WPS IE + P2P IE + WFD IE
11507 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11508 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011509
Jeff Johnson295189b2012-06-20 16:38:30 -070011510 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11511 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11512 }
11513#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011514 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011515 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011516 HS20_OUI_TYPE_SIZE)) )
11517 {
11518 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011519 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011520 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011521
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011522 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011523 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011524 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11525 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011526 VOS_ASSERT(0);
11527 return -ENOMEM;
11528 }
11529 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11530 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011531
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011532 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11533 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11534 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011535 /* Appending OSEN Information Element in Assiciation Request */
11536 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11537 OSEN_OUI_TYPE_SIZE)) )
11538 {
11539 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11540 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11541 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011542
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011543 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011544 {
11545 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11546 "Need bigger buffer space");
11547 VOS_ASSERT(0);
11548 return -ENOMEM;
11549 }
11550 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11551 pWextState->assocAddIE.length += eLen + 2;
11552
11553 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11554 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11555 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11556 }
11557
11558 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011559 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
11560
11561 /* populating as ADDIE in beacon frames */
11562 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11563 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
11564 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11565 {
11566 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11567 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11568 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11569 {
11570 hddLog(LOGE,
11571 "Coldn't pass "
11572 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11573 }
11574 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11575 else
11576 hddLog(LOGE,
11577 "Could not pass on "
11578 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11579
11580 /* IBSS mode doesn't contain params->proberesp_ies still
11581 beaconIE's need to be populated in probe response frames */
11582 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11583 {
11584 u16 rem_probe_resp_ie_len = eLen + 2;
11585 u8 probe_rsp_ie_len[3] = {0};
11586 u8 counter = 0;
11587
11588 /* Check Probe Resp Length if it is greater then 255 then
11589 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11590 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11591 not able Store More then 255 bytes into One Variable */
11592
11593 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11594 {
11595 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11596 {
11597 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11598 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11599 }
11600 else
11601 {
11602 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11603 rem_probe_resp_ie_len = 0;
11604 }
11605 }
11606
11607 rem_probe_resp_ie_len = 0;
11608
11609 if (probe_rsp_ie_len[0] > 0)
11610 {
11611 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11612 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11613 (tANI_U8*)(genie - 2),
11614 probe_rsp_ie_len[0], NULL,
11615 eANI_BOOLEAN_FALSE)
11616 == eHAL_STATUS_FAILURE)
11617 {
11618 hddLog(LOGE,
11619 "Could not pass"
11620 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11621 }
11622 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11623 }
11624
11625 if (probe_rsp_ie_len[1] > 0)
11626 {
11627 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11628 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11629 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11630 probe_rsp_ie_len[1], NULL,
11631 eANI_BOOLEAN_FALSE)
11632 == eHAL_STATUS_FAILURE)
11633 {
11634 hddLog(LOGE,
11635 "Could not pass"
11636 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11637 }
11638 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11639 }
11640
11641 if (probe_rsp_ie_len[2] > 0)
11642 {
11643 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11644 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11645 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11646 probe_rsp_ie_len[2], NULL,
11647 eANI_BOOLEAN_FALSE)
11648 == eHAL_STATUS_FAILURE)
11649 {
11650 hddLog(LOGE,
11651 "Could not pass"
11652 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11653 }
11654 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11655 }
11656
11657 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11658 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11659 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11660 {
11661 hddLog(LOGE,
11662 "Could not pass"
11663 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
11664 }
11665 }
11666 else
11667 {
11668 // Reset WNI_CFG_PROBE_RSP Flags
11669 wlan_hdd_reset_prob_rspies(pAdapter);
11670
11671 hddLog(VOS_TRACE_LEVEL_INFO,
11672 "%s: No Probe Response IE received in set beacon",
11673 __func__);
11674 }
11675 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011676 break;
11677 case DOT11F_EID_RSN:
11678 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
11679 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11680 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
11681 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
11682 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
11683 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053011684
11685 /* Appending Extended Capabilities with Interworking bit set
11686 * in Assoc Req.
11687 *
11688 * In assoc req this EXT Cap will only be taken into account if
11689 * interworkingService bit is set to 1. Currently
11690 * driver is only interested in interworkingService capability
11691 * from supplicant. If in future any other EXT Cap info is
11692 * required from supplicat, it needs to be handled while
11693 * sending Assoc Req in LIM.
11694 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011695 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011696 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011697 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011698 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011699 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011700
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011701 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011702 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011703 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11704 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011705 VOS_ASSERT(0);
11706 return -ENOMEM;
11707 }
11708 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11709 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011710
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011711 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11712 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11713 break;
11714 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011715#ifdef FEATURE_WLAN_WAPI
11716 case WLAN_EID_WAPI:
11717 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011718 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011719 pAdapter->wapi_info.nWapiMode);
11720 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011721 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070011722 akmsuiteCount = WPA_GET_LE16(tmp);
11723 tmp = tmp + 1;
11724 akmlist = (int *)(tmp);
11725 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
11726 {
11727 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
11728 }
11729 else
11730 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011731 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070011732 VOS_ASSERT(0);
11733 return -EINVAL;
11734 }
11735
11736 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
11737 {
11738 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011739 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011740 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011741 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011742 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011743 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011744 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011745 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011746 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
11747 }
11748 break;
11749#endif
11750 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011751 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011752 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011753 /* when Unknown IE is received we should break and continue
11754 * to the next IE in the buffer instead we were returning
11755 * so changing this to break */
11756 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011757 }
11758 genie += eLen;
11759 remLen -= eLen;
11760 }
11761 EXIT();
11762 return 0;
11763}
11764
11765/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053011766 * FUNCTION: hdd_isWPAIEPresent
11767 * Parse the received IE to find the WPA IE
11768 *
11769 */
11770static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
11771{
11772 v_U8_t eLen = 0;
11773 v_U16_t remLen = ie_len;
11774 v_U8_t elementId = 0;
11775
11776 while (remLen >= 2)
11777 {
11778 elementId = *ie++;
11779 eLen = *ie++;
11780 remLen -= 2;
11781 if (eLen > remLen)
11782 {
11783 hddLog(VOS_TRACE_LEVEL_ERROR,
11784 "%s: IE length is wrong %d", __func__, eLen);
11785 return FALSE;
11786 }
11787 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
11788 {
11789 /* OUI - 0x00 0X50 0XF2
11790 WPA Information Element - 0x01
11791 WPA version - 0x01*/
11792 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
11793 return TRUE;
11794 }
11795 ie += eLen;
11796 remLen -= eLen;
11797 }
11798 return FALSE;
11799}
11800
11801/*
Jeff Johnson295189b2012-06-20 16:38:30 -070011802 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011803 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011804 * parameters during connect operation.
11805 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011806int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 struct cfg80211_connect_params *req
11808 )
11809{
11810 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011811 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011812 ENTER();
11813
11814 /*set wpa version*/
11815 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11816
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011817 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053011819 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011820 {
11821 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11822 }
11823 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
11824 {
11825 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11826 }
11827 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011828
11829 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011830 pWextState->wpaVersion);
11831
11832 /*set authentication type*/
11833 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
11834
11835 if (0 > status)
11836 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011837 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011838 "%s: failed to set authentication type ", __func__);
11839 return status;
11840 }
11841
11842 /*set key mgmt type*/
11843 if (req->crypto.n_akm_suites)
11844 {
11845 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
11846 if (0 > status)
11847 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011848 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070011849 __func__);
11850 return status;
11851 }
11852 }
11853
11854 /*set pairwise cipher type*/
11855 if (req->crypto.n_ciphers_pairwise)
11856 {
11857 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
11858 req->crypto.ciphers_pairwise[0], true);
11859 if (0 > status)
11860 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011861 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011862 "%s: failed to set unicast cipher type", __func__);
11863 return status;
11864 }
11865 }
11866 else
11867 {
11868 /*Reset previous cipher suite to none*/
11869 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
11870 if (0 > status)
11871 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011872 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011873 "%s: failed to set unicast cipher type", __func__);
11874 return status;
11875 }
11876 }
11877
11878 /*set group cipher type*/
11879 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
11880 false);
11881
11882 if (0 > status)
11883 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011884 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070011885 __func__);
11886 return status;
11887 }
11888
Chet Lanctot186b5732013-03-18 10:26:30 -070011889#ifdef WLAN_FEATURE_11W
11890 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
11891#endif
11892
Jeff Johnson295189b2012-06-20 16:38:30 -070011893 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
11894 if (req->ie_len)
11895 {
11896 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
11897 if ( 0 > status)
11898 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011899 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070011900 __func__);
11901 return status;
11902 }
11903 }
11904
11905 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011906 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011907 {
11908 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
11909 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
11910 )
11911 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011912 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070011913 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
11914 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011915 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070011916 __func__);
11917 return -EOPNOTSUPP;
11918 }
11919 else
11920 {
11921 u8 key_len = req->key_len;
11922 u8 key_idx = req->key_idx;
11923
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011924 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011925 && (CSR_MAX_NUM_KEY > key_idx)
11926 )
11927 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011928 hddLog(VOS_TRACE_LEVEL_INFO,
11929 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011930 __func__, key_idx, key_len);
11931 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011932 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011933 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011934 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011935 (u8)key_len;
11936 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
11937 }
11938 }
11939 }
11940 }
11941
11942 return status;
11943}
11944
11945/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011946 * FUNCTION: wlan_hdd_try_disconnect
11947 * This function is used to disconnect from previous
11948 * connection
11949 */
11950static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
11951{
11952 long ret = 0;
11953 hdd_station_ctx_t *pHddStaCtx;
11954 eMib_dot11DesiredBssType connectedBssType;
11955
11956 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11957
11958 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
11959
11960 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
11961 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
11962 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
11963 {
11964 /* Issue disconnect to CSR */
11965 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11966 if( eHAL_STATUS_SUCCESS ==
11967 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
11968 pAdapter->sessionId,
11969 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
11970 {
11971 ret = wait_for_completion_interruptible_timeout(
11972 &pAdapter->disconnect_comp_var,
11973 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11974 if (0 >= ret)
11975 {
11976 hddLog(LOGE, FL("Failed to receive disconnect event"));
11977 return -EALREADY;
11978 }
11979 }
11980 }
11981 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
11982 {
11983 ret = wait_for_completion_interruptible_timeout(
11984 &pAdapter->disconnect_comp_var,
11985 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11986 if (0 >= ret)
11987 {
11988 hddLog(LOGE, FL("Failed to receive disconnect event"));
11989 return -EALREADY;
11990 }
11991 }
11992
11993 return 0;
11994}
11995
11996/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053011997 * FUNCTION: __wlan_hdd_cfg80211_connect
11998 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011999 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012000static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012001 struct net_device *ndev,
12002 struct cfg80211_connect_params *req
12003 )
12004{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012005 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012006 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012007 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012008 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012009
12010 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012011
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012012 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12013 TRACE_CODE_HDD_CFG80211_CONNECT,
12014 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012015 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012016 "%s: device_mode = %s (%d)", __func__,
12017 hdd_device_modetoString(pAdapter->device_mode),
12018 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012019
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012020 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012021 if (!pHddCtx)
12022 {
12023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12024 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012025 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012026 }
12027
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012028 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012029 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012030 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012031 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012032 }
12033
Agarwal Ashish51325b52014-06-16 16:50:49 +053012034 if (vos_max_concurrent_connections_reached()) {
12035 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12036 return -ECONNREFUSED;
12037 }
12038
Jeff Johnson295189b2012-06-20 16:38:30 -070012039#ifdef WLAN_BTAMP_FEATURE
12040 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012041 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012042 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012043 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012044 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012045 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012046 }
12047#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012048
12049 //If Device Mode is Station Concurrent Sessions Exit BMps
12050 //P2P Mode will be taken care in Open/close adapter
12051 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012052 (vos_concurrent_open_sessions_running())) {
12053 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12054 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012055 }
12056
12057 /*Try disconnecting if already in connected state*/
12058 status = wlan_hdd_try_disconnect(pAdapter);
12059 if ( 0 > status)
12060 {
12061 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12062 " connection"));
12063 return -EALREADY;
12064 }
12065
Jeff Johnson295189b2012-06-20 16:38:30 -070012066 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012067 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012068
12069 if ( 0 > status)
12070 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012071 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012072 __func__);
12073 return status;
12074 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012075 if ( req->channel )
12076 {
12077 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12078 req->ssid_len, req->bssid,
12079 req->channel->hw_value);
12080 }
12081 else
12082 {
12083 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012084 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012085 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012086
Sushant Kaushikd7083982015-03-18 14:33:24 +053012087 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012088 {
12089 //ReEnable BMPS if disabled
12090 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12091 (NULL != pHddCtx))
12092 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012093 if (pHddCtx->hdd_wlan_suspended)
12094 {
12095 hdd_set_pwrparams(pHddCtx);
12096 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012097 //ReEnable Bmps and Imps back
12098 hdd_enable_bmps_imps(pHddCtx);
12099 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012100 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012101 return status;
12102 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012103 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012104 EXIT();
12105 return status;
12106}
12107
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012108static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12109 struct net_device *ndev,
12110 struct cfg80211_connect_params *req)
12111{
12112 int ret;
12113 vos_ssr_protect(__func__);
12114 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12115 vos_ssr_unprotect(__func__);
12116
12117 return ret;
12118}
Jeff Johnson295189b2012-06-20 16:38:30 -070012119
12120/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012121 * FUNCTION: wlan_hdd_disconnect
12122 * This function is used to issue a disconnect request to SME
12123 */
12124int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12125{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012126 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012127 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012128 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012129 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012130
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012131 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012132
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012133 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012134 if (0 != status)
12135 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012136 return status;
12137 }
12138
12139 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012140
Agarwal Ashish47d18112014-08-04 19:55:07 +053012141 /* Need to apply spin lock before decreasing active sessions
12142 * as there can be chance for double decrement if context switch
12143 * Calls hdd_DisConnectHandler.
12144 */
12145
12146 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012147 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12148 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012149 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12150 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012151 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12152 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012153
Abhishek Singhf4669da2014-05-26 15:07:49 +053012154 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012155 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12156
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012157 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012158
Mihir Shete182a0b22014-08-18 16:08:48 +053012159 /*
12160 * stop tx queues before deleting STA/BSS context from the firmware.
12161 * tx has to be disabled because the firmware can get busy dropping
12162 * the tx frames after BSS/STA has been deleted and will not send
12163 * back a response resulting in WDI timeout
12164 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012165 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012166 netif_tx_disable(pAdapter->dev);
12167 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012168
Mihir Shete182a0b22014-08-18 16:08:48 +053012169 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012170 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12171 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012172 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12173 {
12174 hddLog(VOS_TRACE_LEVEL_INFO,
12175 FL("status = %d, already disconnected"),
12176 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012177
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012178 }
12179 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012180 {
12181 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012182 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012183 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012184 result = -EINVAL;
12185 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012186 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012187 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012188 &pAdapter->disconnect_comp_var,
12189 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012190 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012191 {
12192 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012193 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012194 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012195 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012196 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012197 {
12198 hddLog(VOS_TRACE_LEVEL_ERROR,
12199 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012200 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012201 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012202disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012203 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12204 FL("Set HDD connState to eConnectionState_NotConnected"));
12205 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12206
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012207 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012208 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012209}
12210
12211
12212/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012213 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012214 * This function is used to issue a disconnect request to SME
12215 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012216static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012217 struct net_device *dev,
12218 u16 reason
12219 )
12220{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012221 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012222 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012223 tCsrRoamProfile *pRoamProfile;
12224 hdd_station_ctx_t *pHddStaCtx;
12225 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012226#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012227 tANI_U8 staIdx;
12228#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012229
Jeff Johnson295189b2012-06-20 16:38:30 -070012230 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012231
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012232 if (!pAdapter) {
12233 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12234 return -EINVAL;
12235 }
12236
12237 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12238 if (!pHddStaCtx) {
12239 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12240 return -EINVAL;
12241 }
12242
12243 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12244 status = wlan_hdd_validate_context(pHddCtx);
12245 if (0 != status)
12246 {
12247 return status;
12248 }
12249
12250 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12251
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012252 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12253 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12254 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012255 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12256 __func__, hdd_device_modetoString(pAdapter->device_mode),
12257 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012258
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012259 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12260 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012261
Jeff Johnson295189b2012-06-20 16:38:30 -070012262 if (NULL != pRoamProfile)
12263 {
12264 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012265 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12266 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012267 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012268 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012270 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012271 switch(reason)
12272 {
12273 case WLAN_REASON_MIC_FAILURE:
12274 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12275 break;
12276
12277 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12278 case WLAN_REASON_DISASSOC_AP_BUSY:
12279 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12280 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12281 break;
12282
12283 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12284 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012285 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012286 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12287 break;
12288
Jeff Johnson295189b2012-06-20 16:38:30 -070012289 default:
12290 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12291 break;
12292 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012293 pScanInfo = &pHddCtx->scan_info;
12294 if (pScanInfo->mScanPending)
12295 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012296 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012297 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012298 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012299 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012300 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012301
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012302#ifdef FEATURE_WLAN_TDLS
12303 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012304 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012305 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012306 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12307 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012308 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012309 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012310 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012311 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012312 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012313 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012314 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012315 status = sme_DeleteTdlsPeerSta(
12316 WLAN_HDD_GET_HAL_CTX(pAdapter),
12317 pAdapter->sessionId,
12318 mac);
12319 if (status != eHAL_STATUS_SUCCESS) {
12320 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12321 return -EPERM;
12322 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012323 }
12324 }
12325#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012326 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012327 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12328 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012329 {
12330 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012331 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 __func__, (int)status );
12333 return -EINVAL;
12334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012336 else
12337 {
12338 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12339 "called while in %d state", __func__,
12340 pHddStaCtx->conn_info.connState);
12341 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012342 }
12343 else
12344 {
12345 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12346 }
12347
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012348 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012349 return status;
12350}
12351
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012352static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12353 struct net_device *dev,
12354 u16 reason
12355 )
12356{
12357 int ret;
12358 vos_ssr_protect(__func__);
12359 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12360 vos_ssr_unprotect(__func__);
12361
12362 return ret;
12363}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012364
Jeff Johnson295189b2012-06-20 16:38:30 -070012365/*
12366 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012367 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 * settings in IBSS mode.
12369 */
12370static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012371 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012372 struct cfg80211_ibss_params *params
12373 )
12374{
12375 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012376 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12378 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012379
Jeff Johnson295189b2012-06-20 16:38:30 -070012380 ENTER();
12381
12382 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012383 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012384
12385 if (params->ie_len && ( NULL != params->ie) )
12386 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012387 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12388 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012389 {
12390 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12391 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12392 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012393 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012395 tDot11fIEWPA dot11WPAIE;
12396 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012397 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012398
Wilson Yang00256342013-10-10 23:13:38 -070012399 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012400 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12401 params->ie_len, DOT11F_EID_WPA);
12402 if ( NULL != ie )
12403 {
12404 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12405 // Unpack the WPA IE
12406 //Skip past the EID byte and length byte - and four byte WiFi OUI
12407 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12408 &ie[2+4],
12409 ie[1] - 4,
12410 &dot11WPAIE);
12411 /*Extract the multicast cipher, the encType for unicast
12412 cipher for wpa-none is none*/
12413 encryptionType =
12414 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12415 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012416 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012417
Jeff Johnson295189b2012-06-20 16:38:30 -070012418 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12419
12420 if (0 > status)
12421 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012422 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 __func__);
12424 return status;
12425 }
12426 }
12427
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012428 pWextState->roamProfile.AuthType.authType[0] =
12429 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012430 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12431
12432 if (params->privacy)
12433 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012434 /* Security enabled IBSS, At this time there is no information available
12435 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012437 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012438 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012439 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012440 *enable privacy bit in beacons */
12441
12442 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12443 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012444 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12445 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12447 pWextState->roamProfile.EncryptionType.numEntries = 1;
12448 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012449 return status;
12450}
12451
12452/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012453 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012454 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012455 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012456static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012457 struct net_device *dev,
12458 struct cfg80211_ibss_params *params
12459 )
12460{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012461 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12463 tCsrRoamProfile *pRoamProfile;
12464 int status;
krunal sonie9002db2013-11-25 14:24:17 -080012465 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012466 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12467 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012468
12469 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012470
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012471 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12472 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12473 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012474 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012475 "%s: device_mode = %s (%d)", __func__,
12476 hdd_device_modetoString(pAdapter->device_mode),
12477 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012478
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012479 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012480 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012481 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012482 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012483 }
12484
12485 if (NULL == pWextState)
12486 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012487 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012488 __func__);
12489 return -EIO;
12490 }
12491
Agarwal Ashish51325b52014-06-16 16:50:49 +053012492 if (vos_max_concurrent_connections_reached()) {
12493 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12494 return -ECONNREFUSED;
12495 }
12496
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012497 /*Try disconnecting if already in connected state*/
12498 status = wlan_hdd_try_disconnect(pAdapter);
12499 if ( 0 > status)
12500 {
12501 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12502 " IBSS connection"));
12503 return -EALREADY;
12504 }
12505
Jeff Johnson295189b2012-06-20 16:38:30 -070012506 pRoamProfile = &pWextState->roamProfile;
12507
12508 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12509 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012510 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012511 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012512 return -EINVAL;
12513 }
12514
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012515 /* BSSID is provided by upper layers hence no need to AUTO generate */
12516 if (NULL != params->bssid) {
12517 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12518 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12519 hddLog (VOS_TRACE_LEVEL_ERROR,
12520 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12521 return -EIO;
12522 }
12523 }
krunal sonie9002db2013-11-25 14:24:17 -080012524 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12525 {
12526 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12527 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12528 {
12529 hddLog (VOS_TRACE_LEVEL_ERROR,
12530 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12531 return -EIO;
12532 }
Sachin Ahuja46ff4912015-03-23 22:48:43 +053012533 params->bssid = vos_mem_malloc(VOS_MAC_ADDR_SIZE);
krunal sonie9002db2013-11-25 14:24:17 -080012534 if (!params->bssid)
12535 {
12536 hddLog (VOS_TRACE_LEVEL_ERROR,
12537 "%s:Failed memory allocation", __func__);
12538 return -EIO;
12539 }
12540 vos_mem_copy((v_U8_t *)params->bssid,
12541 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
12542 VOS_MAC_ADDR_SIZE);
12543 alloc_bssid = VOS_TRUE;
12544 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012545
Jeff Johnson295189b2012-06-20 16:38:30 -070012546 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012547 if (NULL !=
12548#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12549 params->chandef.chan)
12550#else
12551 params->channel)
12552#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 {
12554 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012555 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12556 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12557 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12558 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012559
12560 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012561 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012562 ieee80211_frequency_to_channel(
12563#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12564 params->chandef.chan->center_freq);
12565#else
12566 params->channel->center_freq);
12567#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012568
12569 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12570 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012571 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012572 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12573 __func__);
12574 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012575 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012576
12577 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012578 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012579 if (channelNum == validChan[indx])
12580 {
12581 break;
12582 }
12583 }
12584 if (indx >= numChans)
12585 {
12586 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012587 __func__, channelNum);
12588 return -EINVAL;
12589 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012590 /* Set the Operational Channel */
12591 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12592 channelNum);
12593 pRoamProfile->ChannelInfo.numOfChannels = 1;
12594 pHddStaCtx->conn_info.operationChannel = channelNum;
12595 pRoamProfile->ChannelInfo.ChannelList =
12596 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 }
12598
12599 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012600 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 if (status < 0)
12602 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012603 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012604 __func__);
12605 return status;
12606 }
12607
12608 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012609 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012610 params->ssid_len, params->bssid,
12611 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012612
12613 if (0 > status)
12614 {
12615 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
12616 return status;
12617 }
12618
krunal sonie9002db2013-11-25 14:24:17 -080012619 if (NULL != params->bssid &&
12620 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
12621 alloc_bssid == VOS_TRUE)
12622 {
12623 vos_mem_free(params->bssid);
12624 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012625 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 return 0;
12627}
12628
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012629static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12630 struct net_device *dev,
12631 struct cfg80211_ibss_params *params
12632 )
12633{
12634 int ret = 0;
12635
12636 vos_ssr_protect(__func__);
12637 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12638 vos_ssr_unprotect(__func__);
12639
12640 return ret;
12641}
12642
Jeff Johnson295189b2012-06-20 16:38:30 -070012643/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012644 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012645 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012646 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012647static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012648 struct net_device *dev
12649 )
12650{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012651 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012652 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12653 tCsrRoamProfile *pRoamProfile;
12654 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012655 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012656
12657 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012658
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012659 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12660 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12661 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012662 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012663 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012664 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012665 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012666 }
12667
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012668 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
12669 hdd_device_modetoString(pAdapter->device_mode),
12670 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012671 if (NULL == pWextState)
12672 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012673 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012674 __func__);
12675 return -EIO;
12676 }
12677
12678 pRoamProfile = &pWextState->roamProfile;
12679
12680 /* Issue disconnect only if interface type is set to IBSS */
12681 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
12682 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012683 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070012684 __func__);
12685 return -EINVAL;
12686 }
12687
12688 /* Issue Disconnect request */
12689 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12690 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12691 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
12692
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012693 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012694 return 0;
12695}
12696
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012697static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
12698 struct net_device *dev
12699 )
12700{
12701 int ret = 0;
12702
12703 vos_ssr_protect(__func__);
12704 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
12705 vos_ssr_unprotect(__func__);
12706
12707 return ret;
12708}
12709
Jeff Johnson295189b2012-06-20 16:38:30 -070012710/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012711 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070012712 * This function is used to set the phy parameters
12713 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
12714 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012715static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012716 u32 changed)
12717{
12718 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
12719 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012720 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012721
12722 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012723
12724 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012725 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
12726 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012727
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012728 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012729 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012730 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012731 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012732 }
12733
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
12735 {
12736 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
12737 WNI_CFG_RTS_THRESHOLD_STAMAX :
12738 wiphy->rts_threshold;
12739
12740 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012741 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012743 hddLog(VOS_TRACE_LEVEL_ERROR,
12744 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012745 __func__, rts_threshold);
12746 return -EINVAL;
12747 }
12748
12749 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
12750 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012751 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012752 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012753 hddLog(VOS_TRACE_LEVEL_ERROR,
12754 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 __func__, rts_threshold);
12756 return -EIO;
12757 }
12758
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012759 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012760 rts_threshold);
12761 }
12762
12763 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
12764 {
12765 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
12766 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
12767 wiphy->frag_threshold;
12768
12769 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012770 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012771 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012772 hddLog(VOS_TRACE_LEVEL_ERROR,
12773 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012774 frag_threshold);
12775 return -EINVAL;
12776 }
12777
12778 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
12779 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012780 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012781 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012782 hddLog(VOS_TRACE_LEVEL_ERROR,
12783 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 __func__, frag_threshold);
12785 return -EIO;
12786 }
12787
12788 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
12789 frag_threshold);
12790 }
12791
12792 if ((changed & WIPHY_PARAM_RETRY_SHORT)
12793 || (changed & WIPHY_PARAM_RETRY_LONG))
12794 {
12795 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
12796 wiphy->retry_short :
12797 wiphy->retry_long;
12798
12799 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
12800 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
12801 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012802 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012803 __func__, retry_value);
12804 return -EINVAL;
12805 }
12806
12807 if (changed & WIPHY_PARAM_RETRY_SHORT)
12808 {
12809 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
12810 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012811 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012812 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012813 hddLog(VOS_TRACE_LEVEL_ERROR,
12814 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012815 __func__, retry_value);
12816 return -EIO;
12817 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012818 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012819 __func__, retry_value);
12820 }
12821 else if (changed & WIPHY_PARAM_RETRY_SHORT)
12822 {
12823 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
12824 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012825 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012826 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012827 hddLog(VOS_TRACE_LEVEL_ERROR,
12828 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012829 __func__, retry_value);
12830 return -EIO;
12831 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012832 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012833 __func__, retry_value);
12834 }
12835 }
12836
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012837 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 return 0;
12839}
12840
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012841static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
12842 u32 changed)
12843{
12844 int ret;
12845
12846 vos_ssr_protect(__func__);
12847 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
12848 vos_ssr_unprotect(__func__);
12849
12850 return ret;
12851}
12852
Jeff Johnson295189b2012-06-20 16:38:30 -070012853/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012854 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070012855 * This function is used to set the txpower
12856 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012857static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070012858#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12859 struct wireless_dev *wdev,
12860#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012861#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012862 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070012863#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012864 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070012865#endif
12866 int dbm)
12867{
12868 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012869 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012870 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
12871 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012872 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012873
12874 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012875
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012876 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12877 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
12878 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012879 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012880 if (0 != status)
12881 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012882 return status;
12883 }
12884
12885 hHal = pHddCtx->hHal;
12886
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012887 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
12888 dbm, ccmCfgSetCallback,
12889 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012890 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012891 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012892 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
12893 return -EIO;
12894 }
12895
12896 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
12897 dbm);
12898
12899 switch(type)
12900 {
12901 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
12902 /* Fall through */
12903 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
12904 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
12905 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012906 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
12907 __func__);
12908 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012909 }
12910 break;
12911 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012912 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012913 __func__);
12914 return -EOPNOTSUPP;
12915 break;
12916 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012917 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
12918 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070012919 return -EIO;
12920 }
12921
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012922 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012923 return 0;
12924}
12925
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012926static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
12927#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12928 struct wireless_dev *wdev,
12929#endif
12930#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12931 enum tx_power_setting type,
12932#else
12933 enum nl80211_tx_power_setting type,
12934#endif
12935 int dbm)
12936{
12937 int ret;
12938 vos_ssr_protect(__func__);
12939 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
12940#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12941 wdev,
12942#endif
12943#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12944 type,
12945#else
12946 type,
12947#endif
12948 dbm);
12949 vos_ssr_unprotect(__func__);
12950
12951 return ret;
12952}
12953
Jeff Johnson295189b2012-06-20 16:38:30 -070012954/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012955 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070012956 * This function is used to read the txpower
12957 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012958static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070012959#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12960 struct wireless_dev *wdev,
12961#endif
12962 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070012963{
12964
12965 hdd_adapter_t *pAdapter;
12966 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012967 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012968
Jeff Johnsone7245742012-09-05 17:12:55 -070012969 ENTER();
12970
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012971 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012972 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012973 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012974 *dbm = 0;
12975 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012976 }
12977
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
12979 if (NULL == pAdapter)
12980 {
12981 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
12982 return -ENOENT;
12983 }
12984
12985 wlan_hdd_get_classAstats(pAdapter);
12986 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
12987
Jeff Johnsone7245742012-09-05 17:12:55 -070012988 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012989 return 0;
12990}
12991
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012992static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
12993#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12994 struct wireless_dev *wdev,
12995#endif
12996 int *dbm)
12997{
12998 int ret;
12999
13000 vos_ssr_protect(__func__);
13001 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13002#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13003 wdev,
13004#endif
13005 dbm);
13006 vos_ssr_unprotect(__func__);
13007
13008 return ret;
13009}
13010
13011
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013012static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 u8* mac, struct station_info *sinfo)
13014{
13015 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13016 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13017 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013018 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013019
13020 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13021 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013022
13023 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13024 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13025 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13026 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13027 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13028 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13029 tANI_U16 maxRate = 0;
13030 tANI_U16 myRate;
13031 tANI_U16 currentRate = 0;
13032 tANI_U8 maxSpeedMCS = 0;
13033 tANI_U8 maxMCSIdx = 0;
13034 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013035 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013036 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013037 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013038
Leo Chang6f8870f2013-03-26 18:11:36 -070013039#ifdef WLAN_FEATURE_11AC
13040 tANI_U32 vht_mcs_map;
13041 eDataRate11ACMaxMcs vhtMaxMcs;
13042#endif /* WLAN_FEATURE_11AC */
13043
Jeff Johnsone7245742012-09-05 17:12:55 -070013044 ENTER();
13045
Jeff Johnson295189b2012-06-20 16:38:30 -070013046 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13047 (0 == ssidlen))
13048 {
13049 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13050 " Invalid ssidlen, %d", __func__, ssidlen);
13051 /*To keep GUI happy*/
13052 return 0;
13053 }
13054
Mukul Sharma811205f2014-07-09 21:07:30 +053013055 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13056 {
13057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13058 "%s: Roaming in progress, so unable to proceed this request", __func__);
13059 return 0;
13060 }
13061
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013062 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013063 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013064 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013065 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013066 }
13067
Jeff Johnson295189b2012-06-20 16:38:30 -070013068
Kiet Lam3b17fc82013-09-27 05:24:08 +053013069 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13070 sinfo->filled |= STATION_INFO_SIGNAL;
13071
c_hpothu09f19542014-05-30 21:53:31 +053013072 wlan_hdd_get_station_stats(pAdapter);
13073 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
13074
13075 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013076 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13077 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013078 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013079 {
13080 rate_flags = pAdapter->maxRateFlags;
13081 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013082
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 //convert to the UI units of 100kbps
13084 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13085
13086#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013087 pr_info("RSSI %d, RLMS %u, rate %d, rssi high %d, rssi mid %d, rssi low %d, rate_flags 0x%x, MCS %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -070013088 sinfo->signal,
13089 pCfg->reportMaxLinkSpeed,
13090 myRate,
13091 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013092 (int) pCfg->linkSpeedRssiMid,
13093 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013094 (int) rate_flags,
13095 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013096#endif //LINKSPEED_DEBUG_ENABLED
13097
13098 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13099 {
13100 // we do not want to necessarily report the current speed
13101 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13102 {
13103 // report the max possible speed
13104 rssidx = 0;
13105 }
13106 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13107 {
13108 // report the max possible speed with RSSI scaling
13109 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13110 {
13111 // report the max possible speed
13112 rssidx = 0;
13113 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013114 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013115 {
13116 // report middle speed
13117 rssidx = 1;
13118 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013119 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13120 {
13121 // report middle speed
13122 rssidx = 2;
13123 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013124 else
13125 {
13126 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013127 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013128 }
13129 }
13130 else
13131 {
13132 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13133 hddLog(VOS_TRACE_LEVEL_ERROR,
13134 "%s: Invalid value for reportMaxLinkSpeed: %u",
13135 __func__, pCfg->reportMaxLinkSpeed);
13136 rssidx = 0;
13137 }
13138
13139 maxRate = 0;
13140
13141 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013142 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13143 OperationalRates, &ORLeng))
13144 {
13145 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13146 /*To keep GUI happy*/
13147 return 0;
13148 }
13149
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 for (i = 0; i < ORLeng; i++)
13151 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013152 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013153 {
13154 /* Validate Rate Set */
13155 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13156 {
13157 currentRate = supported_data_rate[j].supported_rate[rssidx];
13158 break;
13159 }
13160 }
13161 /* Update MAX rate */
13162 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13163 }
13164
13165 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013166 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13167 ExtendedRates, &ERLeng))
13168 {
13169 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13170 /*To keep GUI happy*/
13171 return 0;
13172 }
13173
Jeff Johnson295189b2012-06-20 16:38:30 -070013174 for (i = 0; i < ERLeng; i++)
13175 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013176 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 {
13178 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13179 {
13180 currentRate = supported_data_rate[j].supported_rate[rssidx];
13181 break;
13182 }
13183 }
13184 /* Update MAX rate */
13185 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13186 }
c_hpothu79aab322014-07-14 21:11:01 +053013187
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013188 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013189 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013190 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013191 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013192 {
c_hpothu79aab322014-07-14 21:11:01 +053013193 if (rate_flags & eHAL_TX_RATE_VHT80)
13194 mode = 2;
13195 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13196 mode = 1;
13197 else
13198 mode = 0;
13199
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013200 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13201 MCSRates, &MCSLeng))
13202 {
13203 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13204 /*To keep GUI happy*/
13205 return 0;
13206 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013207 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013208#ifdef WLAN_FEATURE_11AC
13209 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013210 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013211 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013212 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013213 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013214 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013215 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013216 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013217 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013218 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013219 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013220 maxMCSIdx = 7;
13221 }
13222 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13223 {
13224 maxMCSIdx = 8;
13225 }
13226 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13227 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013228 //VHT20 is supporting 0~8
13229 if (rate_flags & eHAL_TX_RATE_VHT20)
13230 maxMCSIdx = 8;
13231 else
13232 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013233 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013234
c_hpothu79aab322014-07-14 21:11:01 +053013235 if (0 != rssidx)/*check for scaled */
13236 {
13237 //get middle rate MCS index if rssi=1/2
13238 for (i=0; i <= maxMCSIdx; i++)
13239 {
13240 if (sinfo->signal <= rssiMcsTbl[mode][i])
13241 {
13242 maxMCSIdx = i;
13243 break;
13244 }
13245 }
13246 }
13247
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013248 if (rate_flags & eHAL_TX_RATE_VHT80)
13249 {
13250 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13251 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13252 }
13253 else if (rate_flags & eHAL_TX_RATE_VHT40)
13254 {
13255 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13256 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13257 }
13258 else if (rate_flags & eHAL_TX_RATE_VHT20)
13259 {
13260 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13261 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13262 }
13263
Leo Chang6f8870f2013-03-26 18:11:36 -070013264 maxSpeedMCS = 1;
13265 if (currentRate > maxRate)
13266 {
13267 maxRate = currentRate;
13268 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013269
Leo Chang6f8870f2013-03-26 18:11:36 -070013270 }
13271 else
13272#endif /* WLAN_FEATURE_11AC */
13273 {
13274 if (rate_flags & eHAL_TX_RATE_HT40)
13275 {
13276 rateFlag |= 1;
13277 }
13278 if (rate_flags & eHAL_TX_RATE_SGI)
13279 {
13280 rateFlag |= 2;
13281 }
13282
Girish Gowli01abcee2014-07-31 20:18:55 +053013283 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013284 if (rssidx == 1 || rssidx == 2)
13285 {
13286 //get middle rate MCS index if rssi=1/2
13287 for (i=0; i <= 7; i++)
13288 {
13289 if (sinfo->signal <= rssiMcsTbl[mode][i])
13290 {
13291 temp = i+1;
13292 break;
13293 }
13294 }
13295 }
c_hpothu79aab322014-07-14 21:11:01 +053013296
13297 for (i = 0; i < MCSLeng; i++)
13298 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013299 for (j = 0; j < temp; j++)
13300 {
13301 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13302 {
13303 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
13304 break;
13305 }
13306 }
13307 if ((j < temp) && (currentRate > maxRate))
13308 {
13309 maxRate = currentRate;
13310 maxSpeedMCS = 1;
13311 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
13312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013313 }
13314 }
13315 }
13316
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013317 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13318 {
13319 maxRate = myRate;
13320 maxSpeedMCS = 1;
13321 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13322 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013324 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013325 {
13326 maxRate = myRate;
13327 if (rate_flags & eHAL_TX_RATE_LEGACY)
13328 {
13329 maxSpeedMCS = 0;
13330 }
13331 else
13332 {
13333 maxSpeedMCS = 1;
13334 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13335 }
13336 }
13337
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013338 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013339 {
13340 sinfo->txrate.legacy = maxRate;
13341#ifdef LINKSPEED_DEBUG_ENABLED
13342 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13343#endif //LINKSPEED_DEBUG_ENABLED
13344 }
13345 else
13346 {
13347 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013348#ifdef WLAN_FEATURE_11AC
13349 sinfo->txrate.nss = 1;
13350 if (rate_flags & eHAL_TX_RATE_VHT80)
13351 {
13352 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013353 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013354 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013355 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013356 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013357 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13358 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13359 }
13360 else if (rate_flags & eHAL_TX_RATE_VHT20)
13361 {
13362 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13363 }
13364#endif /* WLAN_FEATURE_11AC */
13365 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13366 {
13367 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13368 if (rate_flags & eHAL_TX_RATE_HT40)
13369 {
13370 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13371 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013372 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 if (rate_flags & eHAL_TX_RATE_SGI)
13374 {
13375 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13376 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013377
Jeff Johnson295189b2012-06-20 16:38:30 -070013378#ifdef LINKSPEED_DEBUG_ENABLED
13379 pr_info("Reporting MCS rate %d flags %x\n",
13380 sinfo->txrate.mcs,
13381 sinfo->txrate.flags );
13382#endif //LINKSPEED_DEBUG_ENABLED
13383 }
13384 }
13385 else
13386 {
13387 // report current rate instead of max rate
13388
13389 if (rate_flags & eHAL_TX_RATE_LEGACY)
13390 {
13391 //provide to the UI in units of 100kbps
13392 sinfo->txrate.legacy = myRate;
13393#ifdef LINKSPEED_DEBUG_ENABLED
13394 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13395#endif //LINKSPEED_DEBUG_ENABLED
13396 }
13397 else
13398 {
13399 //must be MCS
13400 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013401#ifdef WLAN_FEATURE_11AC
13402 sinfo->txrate.nss = 1;
13403 if (rate_flags & eHAL_TX_RATE_VHT80)
13404 {
13405 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13406 }
13407 else
13408#endif /* WLAN_FEATURE_11AC */
13409 {
13410 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13411 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013412 if (rate_flags & eHAL_TX_RATE_SGI)
13413 {
13414 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13415 }
13416 if (rate_flags & eHAL_TX_RATE_HT40)
13417 {
13418 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13419 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013420#ifdef WLAN_FEATURE_11AC
13421 else if (rate_flags & eHAL_TX_RATE_VHT80)
13422 {
13423 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13424 }
13425#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013426#ifdef LINKSPEED_DEBUG_ENABLED
13427 pr_info("Reporting actual MCS rate %d flags %x\n",
13428 sinfo->txrate.mcs,
13429 sinfo->txrate.flags );
13430#endif //LINKSPEED_DEBUG_ENABLED
13431 }
13432 }
13433 sinfo->filled |= STATION_INFO_TX_BITRATE;
13434
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013435 sinfo->tx_packets =
13436 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13437 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13438 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13439 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13440
13441 sinfo->tx_retries =
13442 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13443 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13444 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13445 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13446
13447 sinfo->tx_failed =
13448 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13449 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13450 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13451 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13452
13453 sinfo->filled |=
13454 STATION_INFO_TX_PACKETS |
13455 STATION_INFO_TX_RETRIES |
13456 STATION_INFO_TX_FAILED;
13457
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013458 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13459 TRACE_CODE_HDD_CFG80211_GET_STA,
13460 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013461 EXIT();
13462 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013463}
13464
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013465static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13466 u8* mac, struct station_info *sinfo)
13467{
13468 int ret;
13469
13470 vos_ssr_protect(__func__);
13471 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13472 vos_ssr_unprotect(__func__);
13473
13474 return ret;
13475}
13476
13477static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013478 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013479{
13480 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013481 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013483 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013484
Jeff Johnsone7245742012-09-05 17:12:55 -070013485 ENTER();
13486
Jeff Johnson295189b2012-06-20 16:38:30 -070013487 if (NULL == pAdapter)
13488 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013489 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 return -ENODEV;
13491 }
13492
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013493 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13494 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13495 pAdapter->sessionId, timeout));
13496
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013497 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013498 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013499 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013500 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013501 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013502 }
13503
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013504 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13505 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13506 (pHddCtx->cfg_ini->fhostArpOffload) &&
13507 (eConnectionState_Associated ==
13508 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13509 {
Amar Singhald53568e2013-09-26 11:03:45 -070013510
13511 hddLog(VOS_TRACE_LEVEL_INFO,
13512 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013513 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013514 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13515 {
13516 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013517 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013518 __func__, vos_status);
13519 }
13520 }
13521
Jeff Johnson295189b2012-06-20 16:38:30 -070013522 /**The get power cmd from the supplicant gets updated by the nl only
13523 *on successful execution of the function call
13524 *we are oppositely mapped w.r.t mode in the driver
13525 **/
13526 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13527
13528 if (VOS_STATUS_E_FAILURE == vos_status)
13529 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013530 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13531 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013532 return -EINVAL;
13533 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013534 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013535 return 0;
13536}
13537
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013538static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13539 struct net_device *dev, bool mode, int timeout)
13540{
13541 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013542
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013543 vos_ssr_protect(__func__);
13544 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13545 vos_ssr_unprotect(__func__);
13546
13547 return ret;
13548}
Jeff Johnson295189b2012-06-20 16:38:30 -070013549#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013550static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13551 struct net_device *netdev,
13552 u8 key_index)
13553{
13554 ENTER();
13555 return 0;
13556}
13557
Jeff Johnson295189b2012-06-20 16:38:30 -070013558static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013559 struct net_device *netdev,
13560 u8 key_index)
13561{
13562 int ret;
13563 vos_ssr_protect(__func__);
13564 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13565 vos_ssr_unprotect(__func__);
13566 return ret;
13567}
13568#endif //LINUX_VERSION_CODE
13569
13570#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13571static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13572 struct net_device *dev,
13573 struct ieee80211_txq_params *params)
13574{
13575 ENTER();
13576 return 0;
13577}
13578#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13579static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13580 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013581{
Jeff Johnsone7245742012-09-05 17:12:55 -070013582 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013583 return 0;
13584}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013585#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013586
13587#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13588static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013589 struct net_device *dev,
13590 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013591{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013592 int ret;
13593
13594 vos_ssr_protect(__func__);
13595 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13596 vos_ssr_unprotect(__func__);
13597 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013598}
13599#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13600static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13601 struct ieee80211_txq_params *params)
13602{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013603 int ret;
13604
13605 vos_ssr_protect(__func__);
13606 ret = __wlan_hdd_set_txq_params(wiphy, params);
13607 vos_ssr_unprotect(__func__);
13608 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013609}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013610#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013611
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013612static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013613 struct net_device *dev,
13614 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013615{
13616 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013617 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013618 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013619 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013620 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013621 v_CONTEXT_t pVosContext = NULL;
13622 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013623
Jeff Johnsone7245742012-09-05 17:12:55 -070013624 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013625
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013626 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013627 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013628 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013629 return -EINVAL;
13630 }
13631
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013632 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13633 TRACE_CODE_HDD_CFG80211_DEL_STA,
13634 pAdapter->sessionId, pAdapter->device_mode));
13635
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013636 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13637 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013638 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013639 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013640 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013641 }
13642
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 )
13646 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013647 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13648 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13649 if(pSapCtx == NULL){
13650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13651 FL("psapCtx is NULL"));
13652 return -ENOENT;
13653 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013654 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013655 {
13656 v_U16_t i;
13657 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
13658 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013659 if ((pSapCtx->aStaInfo[i].isUsed) &&
13660 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013662 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013663 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013664 ETHER_ADDR_LEN);
13665
Jeff Johnson295189b2012-06-20 16:38:30 -070013666 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013667 "%s: Delete STA with MAC::"
13668 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013669 __func__,
13670 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
13671 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070013672 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013673 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 }
13675 }
13676 }
13677 else
13678 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013679
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013680 vos_status = hdd_softap_GetStaId(pAdapter,
13681 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013682 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13683 {
13684 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013685 "%s: Skip this DEL STA as this is not used::"
13686 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013687 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013688 return -ENOENT;
13689 }
13690
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013691 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013692 {
13693 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013694 "%s: Skip this DEL STA as deauth is in progress::"
13695 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013696 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013697 return -ENOENT;
13698 }
13699
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013700 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013701
Jeff Johnson295189b2012-06-20 16:38:30 -070013702 hddLog(VOS_TRACE_LEVEL_INFO,
13703 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013704 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013705 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013706 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013707
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013708 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013709 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13710 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013711 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013712 hddLog(VOS_TRACE_LEVEL_INFO,
13713 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013714 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013715 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013716 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013717 return -ENOENT;
13718 }
13719
Jeff Johnson295189b2012-06-20 16:38:30 -070013720 }
13721 }
13722
13723 EXIT();
13724
13725 return 0;
13726}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013727
13728#ifdef CFG80211_DEL_STA_V2
13729static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13730 struct net_device *dev,
13731 struct station_del_parameters *param)
13732#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013733static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13734 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013735#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013736{
13737 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013738 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070013739
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013740 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013741
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013742#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013743 if (NULL == param) {
13744 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013745 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013746 return -EINVAL;
13747 }
13748
13749 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
13750 param->subtype, &delStaParams);
13751
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013752#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053013753 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013754 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013755#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013756 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
13757
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013758 vos_ssr_unprotect(__func__);
13759
13760 return ret;
13761}
13762
13763static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013764 struct net_device *dev, u8 *mac, struct station_parameters *params)
13765{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013766 hdd_adapter_t *pAdapter;
13767 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013768 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013769#ifdef FEATURE_WLAN_TDLS
13770 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013771
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013772 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013773
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013774 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13775 if (NULL == pAdapter)
13776 {
13777 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13778 "%s: Adapter is NULL",__func__);
13779 return -EINVAL;
13780 }
13781 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13782 status = wlan_hdd_validate_context(pHddCtx);
13783 if (0 != status)
13784 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013785 return status;
13786 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013787
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013788 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13789 TRACE_CODE_HDD_CFG80211_ADD_STA,
13790 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013791 mask = params->sta_flags_mask;
13792
13793 set = params->sta_flags_set;
13794
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053013795 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013796 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
13797 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013798
13799 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
13800 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013801 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013802 }
13803 }
13804#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013805 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013806 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013807}
13808
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013809static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
13810 struct net_device *dev, u8 *mac, struct station_parameters *params)
13811{
13812 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013813
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013814 vos_ssr_protect(__func__);
13815 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
13816 vos_ssr_unprotect(__func__);
13817
13818 return ret;
13819}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013820#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070013821
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013822static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070013823 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013824{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013825 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13826 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013827 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013828 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013829 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013830 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070013831
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013832 ENTER();
13833
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013834 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013835 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013836 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013837 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013838 return -EINVAL;
13839 }
13840
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013841 if (!pmksa) {
13842 hddLog(LOGE, FL("pmksa is NULL"));
13843 return -EINVAL;
13844 }
13845
13846 if (!pmksa->bssid || !pmksa->pmkid) {
13847 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
13848 pmksa->bssid, pmksa->pmkid);
13849 return -EINVAL;
13850 }
13851
13852 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
13853 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
13854
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013855 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13856 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013857 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013858 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013859 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013860 }
13861
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013862 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013863 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13864
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013865 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
13866 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013867
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013868 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013869 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013870 &pmk_id, 1, FALSE);
13871
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013872 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13873 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
13874 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013875
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013876 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013877 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013878}
13879
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013880static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
13881 struct cfg80211_pmksa *pmksa)
13882{
13883 int ret;
13884
13885 vos_ssr_protect(__func__);
13886 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
13887 vos_ssr_unprotect(__func__);
13888
13889 return ret;
13890}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013891
Wilson Yang6507c4e2013-10-01 20:11:19 -070013892
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013893static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070013894 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013895{
Wilson Yang6507c4e2013-10-01 20:11:19 -070013896 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13897 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013898 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080013899 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013900
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013901 ENTER();
13902
Wilson Yang6507c4e2013-10-01 20:11:19 -070013903 /* Validate pAdapter */
13904 if (NULL == pAdapter)
13905 {
13906 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
13907 return -EINVAL;
13908 }
13909
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013910 if (!pmksa) {
13911 hddLog(LOGE, FL("pmksa is NULL"));
13912 return -EINVAL;
13913 }
13914
13915 if (!pmksa->bssid) {
13916 hddLog(LOGE, FL("pmksa->bssid is NULL"));
13917 return -EINVAL;
13918 }
13919
Kiet Lam98c46a12014-10-31 15:34:57 -070013920 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
13921 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
13922
Wilson Yang6507c4e2013-10-01 20:11:19 -070013923 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13924 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070013925 if (0 != status)
13926 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070013927 return status;
13928 }
13929
13930 /*Retrieve halHandle*/
13931 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13932
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013933 /* Delete the PMKID CSR cache */
13934 if (eHAL_STATUS_SUCCESS !=
13935 sme_RoamDelPMKIDfromCache(halHandle,
13936 pAdapter->sessionId, pmksa->bssid, FALSE)) {
13937 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
13938 MAC_ADDR_ARRAY(pmksa->bssid));
13939 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013940 }
13941
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013942 EXIT();
13943 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013944}
13945
Wilson Yang6507c4e2013-10-01 20:11:19 -070013946
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013947static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
13948 struct cfg80211_pmksa *pmksa)
13949{
13950 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013951
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013952 vos_ssr_protect(__func__);
13953 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
13954 vos_ssr_unprotect(__func__);
13955
13956 return ret;
13957
13958}
13959
13960static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013961{
Wilson Yang6507c4e2013-10-01 20:11:19 -070013962 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13963 tHalHandle halHandle;
13964 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080013965 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013966
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013967 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070013968
13969 /* Validate pAdapter */
13970 if (NULL == pAdapter)
13971 {
13972 hddLog(VOS_TRACE_LEVEL_ERROR,
13973 "%s: Invalid Adapter" ,__func__);
13974 return -EINVAL;
13975 }
13976
13977 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13978 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070013979 if (0 != status)
13980 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070013981 return status;
13982 }
13983
13984 /*Retrieve halHandle*/
13985 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13986
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013987 /* Flush the PMKID cache in CSR */
13988 if (eHAL_STATUS_SUCCESS !=
13989 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
13990 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
13991 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013992 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013993 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080013994 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013995}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013996
13997static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
13998{
13999 int ret;
14000
14001 vos_ssr_protect(__func__);
14002 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14003 vos_ssr_unprotect(__func__);
14004
14005 return ret;
14006}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014007#endif
14008
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014009#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014010static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14011 struct net_device *dev,
14012 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014013{
14014 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14015 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014016 hdd_context_t *pHddCtx;
14017 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014018
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014019 ENTER();
14020
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014021 if (NULL == pAdapter)
14022 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014023 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014024 return -ENODEV;
14025 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014026 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14027 ret = wlan_hdd_validate_context(pHddCtx);
14028 if (0 != ret)
14029 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014030 return ret;
14031 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014032 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014033 if (NULL == pHddStaCtx)
14034 {
14035 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14036 return -EINVAL;
14037 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014038
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014039 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14040 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14041 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014042 // Added for debug on reception of Re-assoc Req.
14043 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14044 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014045 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014046 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014047 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014048 }
14049
14050#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014051 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014052 ftie->ie_len);
14053#endif
14054
14055 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014056 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14057 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014058 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014059
14060 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014061 return 0;
14062}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014063
14064static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14065 struct net_device *dev,
14066 struct cfg80211_update_ft_ies_params *ftie)
14067{
14068 int ret;
14069
14070 vos_ssr_protect(__func__);
14071 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14072 vos_ssr_unprotect(__func__);
14073
14074 return ret;
14075}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014076#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014077
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014078#ifdef FEATURE_WLAN_SCAN_PNO
14079
14080void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14081 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14082{
14083 int ret;
14084 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14085 hdd_context_t *pHddCtx;
14086
Nirav Shah80830bf2013-12-31 16:35:12 +053014087 ENTER();
14088
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014089 if (NULL == pAdapter)
14090 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014091 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014092 "%s: HDD adapter is Null", __func__);
14093 return ;
14094 }
14095
14096 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14097 if (NULL == pHddCtx)
14098 {
14099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14100 "%s: HDD context is Null!!!", __func__);
14101 return ;
14102 }
14103
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014104 spin_lock(&pHddCtx->schedScan_lock);
14105 if (TRUE == pHddCtx->isWiphySuspended)
14106 {
14107 pHddCtx->isSchedScanUpdatePending = TRUE;
14108 spin_unlock(&pHddCtx->schedScan_lock);
14109 hddLog(VOS_TRACE_LEVEL_INFO,
14110 "%s: Update cfg80211 scan database after it resume", __func__);
14111 return ;
14112 }
14113 spin_unlock(&pHddCtx->schedScan_lock);
14114
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014115 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14116
14117 if (0 > ret)
14118 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14119
14120 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14122 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014123}
14124
14125/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014126 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014127 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014128 */
14129static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14130{
14131 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14132 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014133 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014134 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14135 int status = 0;
14136 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14137
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014138 /* The current firmware design does not allow PNO during any
14139 * active sessions. Hence, determine the active sessions
14140 * and return a failure.
14141 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014142 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14143 {
14144 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014145 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014146
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014147 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14148 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14149 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14150 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14151 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014152 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014153 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014154 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014155 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014156 }
14157 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14158 pAdapterNode = pNext;
14159 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014160 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014161}
14162
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014163void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14164{
14165 hdd_adapter_t *pAdapter = callbackContext;
14166 hdd_context_t *pHddCtx;
14167
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014168 ENTER();
14169
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014170 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14171 {
14172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14173 FL("Invalid adapter or adapter has invalid magic"));
14174 return;
14175 }
14176
14177 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14178 if (0 != wlan_hdd_validate_context(pHddCtx))
14179 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014180 return;
14181 }
14182
c_hpothub53c45d2014-08-18 16:53:14 +053014183 if (VOS_STATUS_SUCCESS != status)
14184 {
14185 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014186 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014187 pHddCtx->isPnoEnable = FALSE;
14188 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014189
14190 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14191 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014192 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014193}
14194
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014195/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014196 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14197 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014198 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014199static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014200 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14201{
14202 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014203 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014204 hdd_context_t *pHddCtx;
14205 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014206 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014207 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14208 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014209 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14210 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014211 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014212 hdd_config_t *pConfig = NULL;
14213 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014214
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014215 ENTER();
14216
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014217 if (NULL == pAdapter)
14218 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014220 "%s: HDD adapter is Null", __func__);
14221 return -ENODEV;
14222 }
14223
14224 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014225 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014226
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014227 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014228 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014229 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014230 }
14231
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014232 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014233 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14234 if (NULL == hHal)
14235 {
14236 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14237 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014238 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014239 }
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014240 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014241 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014242 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014243 {
14244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14245 "%s: aborting the existing scan is unsuccessfull", __func__);
14246 return -EBUSY;
14247 }
14248
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014249 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014250 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014251 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014252 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014253 return -EBUSY;
14254 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014255
c_hpothu37f21312014-04-09 21:49:54 +053014256 if (TRUE == pHddCtx->isPnoEnable)
14257 {
14258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14259 FL("already PNO is enabled"));
14260 return -EBUSY;
14261 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014262
14263 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14264 {
14265 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14266 "%s: abort ROC failed ", __func__);
14267 return -EBUSY;
14268 }
14269
c_hpothu37f21312014-04-09 21:49:54 +053014270 pHddCtx->isPnoEnable = TRUE;
14271
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014272 pnoRequest.enable = 1; /*Enable PNO */
14273 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014274
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014275 if (( !pnoRequest.ucNetworksCount ) ||
14276 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014277 {
14278 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014279 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014280 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014281 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014282 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014283 goto error;
14284 }
14285
14286 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14287 {
14288 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014289 "%s: Incorrect number of channels %d",
14290 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014291 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014292 goto error;
14293 }
14294
14295 /* Framework provides one set of channels(all)
14296 * common for all saved profile */
14297 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14298 channels_allowed, &num_channels_allowed))
14299 {
14300 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14301 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014302 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014303 goto error;
14304 }
14305 /* Checking each channel against allowed channel list */
14306 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014307 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014308 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014309 char chList [(request->n_channels*5)+1];
14310 int len;
14311 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014312 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014313 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014314 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014315 if (request->channels[i]->hw_value == channels_allowed[indx])
14316 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014317 if ((!pConfig->enableDFSPnoChnlScan) &&
14318 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14319 {
14320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14321 "%s : Dropping DFS channel : %d",
14322 __func__,channels_allowed[indx]);
14323 num_ignore_dfs_ch++;
14324 break;
14325 }
14326
Nirav Shah80830bf2013-12-31 16:35:12 +053014327 valid_ch[num_ch++] = request->channels[i]->hw_value;
14328 len += snprintf(chList+len, 5, "%d ",
14329 request->channels[i]->hw_value);
14330 break ;
14331 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014332 }
14333 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014334 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014335
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014336 /*If all channels are DFS and dropped, then ignore the PNO request*/
14337 if (num_ignore_dfs_ch == request->n_channels)
14338 {
14339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14340 "%s : All requested channels are DFS channels", __func__);
14341 ret = -EINVAL;
14342 goto error;
14343 }
14344 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014345
14346 pnoRequest.aNetworks =
14347 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14348 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014349 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014350 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14351 FL("failed to allocate memory aNetworks %u"),
14352 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14353 goto error;
14354 }
14355 vos_mem_zero(pnoRequest.aNetworks,
14356 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14357
14358 /* Filling per profile params */
14359 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14360 {
14361 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014362 request->match_sets[i].ssid.ssid_len;
14363
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014364 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14365 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014366 {
14367 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014368 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014369 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014370 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014371 goto error;
14372 }
14373
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014374 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014375 request->match_sets[i].ssid.ssid,
14376 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014377 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14378 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014379 i, pnoRequest.aNetworks[i].ssId.ssId);
14380 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14381 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14382 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014383
14384 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014385 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14386 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014387
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014388 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014389 }
14390
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014391 for (i = 0; i < request->n_ssids; i++)
14392 {
14393 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014394 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014395 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014396 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014397 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014398 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014399 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014400 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014401 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014402 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014403 break;
14404 }
14405 j++;
14406 }
14407 }
14408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14409 "Number of hidden networks being Configured = %d",
14410 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014411 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014412 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014413
14414 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14415 if (pnoRequest.p24GProbeTemplate == NULL)
14416 {
14417 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14418 FL("failed to allocate memory p24GProbeTemplate %u"),
14419 SIR_PNO_MAX_PB_REQ_SIZE);
14420 goto error;
14421 }
14422
14423 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14424 if (pnoRequest.p5GProbeTemplate == NULL)
14425 {
14426 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14427 FL("failed to allocate memory p5GProbeTemplate %u"),
14428 SIR_PNO_MAX_PB_REQ_SIZE);
14429 goto error;
14430 }
14431
14432 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14433 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14434
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014435 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14436 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014437 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014438 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14439 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14440 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014441
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014442 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14443 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14444 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014445 }
14446
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014447 /* Driver gets only one time interval which is hardcoded in
14448 * supplicant for 10000ms. Taking power consumption into account 6 timers
14449 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14450 * 80,160,320 secs. And number of scan cycle for each timer
14451 * is configurable through INI param gPNOScanTimerRepeatValue.
14452 * If it is set to 0 only one timer will be used and PNO scan cycle
14453 * will be repeated after each interval specified by supplicant
14454 * till PNO is disabled.
14455 */
14456 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014457 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014458 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014459 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014460 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14461
14462 tempInterval = (request->interval)/1000;
14463 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14464 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14465 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014466 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014467 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014468 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014469 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014470 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014471 tempInterval *= 2;
14472 }
14473 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014474 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014475
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014476 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014477
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014478 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014479 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14480 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014481 pAdapter->pno_req_status = 0;
14482
Nirav Shah80830bf2013-12-31 16:35:12 +053014483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14484 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014485 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14486 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014487
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014488 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014489 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014490 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14491 if (eHAL_STATUS_SUCCESS != status)
14492 {
14493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014494 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014495 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014496 goto error;
14497 }
14498
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014499 ret = wait_for_completion_timeout(
14500 &pAdapter->pno_comp_var,
14501 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14502 if (0 >= ret)
14503 {
14504 // Did not receive the response for PNO enable in time.
14505 // Assuming the PNO enable was success.
14506 // Returning error from here, because we timeout, results
14507 // in side effect of Wifi (Wifi Setting) not to work.
14508 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14509 FL("Timed out waiting for PNO to be Enabled"));
14510 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014511 }
14512
14513 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014514 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014515
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014516error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14518 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014519 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014520 if (pnoRequest.aNetworks)
14521 vos_mem_free(pnoRequest.aNetworks);
14522 if (pnoRequest.p24GProbeTemplate)
14523 vos_mem_free(pnoRequest.p24GProbeTemplate);
14524 if (pnoRequest.p5GProbeTemplate)
14525 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014526
14527 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014528 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014529}
14530
14531/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014532 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14533 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014534 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014535static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14536 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14537{
14538 int ret;
14539
14540 vos_ssr_protect(__func__);
14541 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14542 vos_ssr_unprotect(__func__);
14543
14544 return ret;
14545}
14546
14547/*
14548 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14549 * Function to disable PNO
14550 */
14551static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014552 struct net_device *dev)
14553{
14554 eHalStatus status = eHAL_STATUS_FAILURE;
14555 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14556 hdd_context_t *pHddCtx;
14557 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014558 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014559 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014560
14561 ENTER();
14562
14563 if (NULL == pAdapter)
14564 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014565 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014566 "%s: HDD adapter is Null", __func__);
14567 return -ENODEV;
14568 }
14569
14570 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014571
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014572 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014573 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014574 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014575 "%s: HDD context is Null", __func__);
14576 return -ENODEV;
14577 }
14578
14579 /* The return 0 is intentional when isLogpInProgress and
14580 * isLoadUnloadInProgress. We did observe a crash due to a return of
14581 * failure in sched_scan_stop , especially for a case where the unload
14582 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14583 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14584 * success. If it returns a failure , then its next invocation due to the
14585 * clean up of the second interface will have the dev pointer corresponding
14586 * to the first one leading to a crash.
14587 */
14588 if (pHddCtx->isLogpInProgress)
14589 {
14590 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14591 "%s: LOGP in Progress. Ignore!!!", __func__);
14592 return ret;
14593 }
14594
Mihir Shete18156292014-03-11 15:38:30 +053014595 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014596 {
14597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14598 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14599 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014600 }
14601
14602 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14603 if (NULL == hHal)
14604 {
14605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14606 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014607 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014608 }
14609
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014610 pnoRequest.enable = 0; /* Disable PNO */
14611 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014612
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014613 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014614 pAdapter->sessionId,
14615 NULL, pAdapter);
14616 if (eHAL_STATUS_SUCCESS != status)
14617 {
14618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14619 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014620 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014621 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014622 }
c_hpothu37f21312014-04-09 21:49:54 +053014623 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014624
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014625error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014626 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014627 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014628
14629 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014630 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014631}
14632
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014633/*
14634 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
14635 * NL interface to disable PNO
14636 */
14637static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
14638 struct net_device *dev)
14639{
14640 int ret;
14641
14642 vos_ssr_protect(__func__);
14643 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
14644 vos_ssr_unprotect(__func__);
14645
14646 return ret;
14647}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014648#endif /*FEATURE_WLAN_SCAN_PNO*/
14649
14650
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014651#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014652#if TDLS_MGMT_VERSION2
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014653static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014654 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014655 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
14656#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014657static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014658 u8 *peer, u8 action_code, u8 dialog_token,
14659 u16 status_code, const u8 *buf, size_t len)
14660#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014661{
14662
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014663 hdd_adapter_t *pAdapter;
14664 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014665 u8 peerMac[6];
14666 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070014667 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080014668 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070014669 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014670 int ret;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014671#if !(TDLS_MGMT_VERSION2)
14672 u32 peer_capability = 0;
14673#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014674 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014675
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014676 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14677 if (NULL == pAdapter)
14678 {
14679 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14680 "%s: Adapter is NULL",__func__);
14681 return -EINVAL;
14682 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014683 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14684 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
14685 pAdapter->sessionId, action_code));
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014686 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014687 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014688 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014689 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014690 "Invalid arguments");
14691 return -EINVAL;
14692 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014693 if (pHddCtx->isLogpInProgress)
14694 {
14695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14696 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053014697 wlan_hdd_tdls_set_link_status(pAdapter,
14698 peer,
14699 eTDLS_LINK_IDLE,
14700 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014701 return -EBUSY;
14702 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014703 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
14704 {
14705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14706 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14707 return -EAGAIN;
14708 }
Hoonki Lee27511902013-03-14 18:19:06 -070014709 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014710 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014711 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014712 "%s: TDLS mode is disabled OR not enabled in FW."
14713 MAC_ADDRESS_STR " action %d declined.",
14714 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014715 return -ENOTSUPP;
14716 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014717
Hoonki Lee27511902013-03-14 18:19:06 -070014718 /* other than teardown frame, other mgmt frames are not sent if disabled */
14719 if (SIR_MAC_TDLS_TEARDOWN != action_code)
14720 {
14721 /* if tdls_mode is disabled to respond to peer's request */
14722 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
14723 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014724 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014725 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014726 " TDLS mode is disabled. action %d declined.",
14727 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070014728
14729 return -ENOTSUPP;
14730 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053014731
14732 if (vos_max_concurrent_connections_reached())
14733 {
14734 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14735 return -EINVAL;
14736 }
Hoonki Lee27511902013-03-14 18:19:06 -070014737 }
14738
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014739 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
14740 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053014741 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014742 {
14743 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014744 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014745 " TDLS setup is ongoing. action %d declined.",
14746 __func__, MAC_ADDR_ARRAY(peer), action_code);
14747 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014748 }
14749 }
14750
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014751 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
14752 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080014753 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014754 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
14755 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014756 {
14757 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
14758 we return error code at 'add_station()'. Hence we have this
14759 check again in addtion to add_station().
14760 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014761 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014762 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014763 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14764 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014765 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
14766 __func__, MAC_ADDR_ARRAY(peer), action_code,
14767 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053014768 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080014769 }
14770 else
14771 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014772 /* maximum reached. tweak to send error code to peer and return
14773 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014774 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14776 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014777 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
14778 __func__, MAC_ADDR_ARRAY(peer), status_code,
14779 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070014780 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014781 /* fall through to send setup resp with failure status
14782 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014783 }
14784 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014785 else
14786 {
14787 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014788 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014789 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014790 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014791 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014792 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
14793 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014794 return -EPERM;
14795 }
14796 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014797 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014798 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014799
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014800 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014801 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014802 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
14803 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014804
Hoonki Leea34dd892013-02-05 22:56:02 -080014805 /*Except teardown responder will not be used so just make 0*/
14806 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014807 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080014808 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014809
14810 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014811 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014812
14813 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
14814 responder = pTdlsPeer->is_responder;
14815 else
Hoonki Leea34dd892013-02-05 22:56:02 -080014816 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014817 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014818 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %zu",
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014819 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
14820 dialog_token, status_code, len);
14821 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080014822 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014823 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014824
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014825 /* For explicit trigger of DIS_REQ come out of BMPS for
14826 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070014827 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014828 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
14829 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070014830 {
14831 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
14832 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014833 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014834 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014835 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
14836 if (status != VOS_STATUS_SUCCESS) {
14837 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
14838 }
Hoonki Lee14621352013-04-16 17:51:19 -070014839 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014840 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
14841 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED)) {
14842 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
14843 }
14844 }
Hoonki Lee14621352013-04-16 17:51:19 -070014845 }
14846
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014847 /* make sure doesn't call send_mgmt() while it is pending */
14848 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
14849 {
14850 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014851 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014852 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014853 ret = -EBUSY;
14854 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014855 }
14856
14857 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014858 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
14859
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014860 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053014861 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014862
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014863 if (VOS_STATUS_SUCCESS != status)
14864 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14866 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014867 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014868 ret = -EINVAL;
14869 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014870 }
14871
Hoonki Leed37cbb32013-04-20 00:31:14 -070014872 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
14873 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
14874
14875 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014876 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070014877 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014878 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070014879 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014880 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080014881
14882 if (pHddCtx->isLogpInProgress)
14883 {
14884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14885 "%s: LOGP in Progress. Ignore!!!", __func__);
14886 return -EAGAIN;
14887 }
14888
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014889 ret = -EINVAL;
14890 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014891 }
14892
Gopichand Nakkala05922802013-03-14 12:23:19 -070014893 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070014894 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014895 ret = max_sta_failed;
14896 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070014897 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014898
Hoonki Leea34dd892013-02-05 22:56:02 -080014899 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
14900 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014901 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE)) {
14902 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
14903 }
Hoonki Leea34dd892013-02-05 22:56:02 -080014904 }
14905 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
14906 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014907 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE)) {
14908 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
14909 }
Hoonki Leea34dd892013-02-05 22:56:02 -080014910 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014911
14912 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014913
14914tx_failed:
14915 /* add_station will be called before sending TDLS_SETUP_REQ and
14916 * TDLS_SETUP_RSP and as part of add_station driver will enable
14917 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
14918 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
14919 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
14920 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
14921 */
14922
14923 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
14924 (SIR_MAC_TDLS_SETUP_RSP == action_code))
14925 wlan_hdd_tdls_check_bmps(pAdapter);
14926 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014927}
14928
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014929#if TDLS_MGMT_VERSION2
14930static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
14931 u8 *peer, u8 action_code, u8 dialog_token,
14932 u16 status_code, u32 peer_capability,
14933 const u8 *buf, size_t len)
14934#else
14935static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
14936 u8 *peer, u8 action_code, u8 dialog_token,
14937 u16 status_code, const u8 *buf, size_t len)
14938#endif
14939{
14940 int ret;
14941
14942 vos_ssr_protect(__func__);
14943#if TDLS_MGMT_VERSION2
14944 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
14945 status_code, peer_capability, buf, len);
14946#else
14947 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
14948 status_code, buf, len);
14949#endif
14950 vos_ssr_unprotect(__func__);
14951
14952 return ret;
14953}
Atul Mittal115287b2014-07-08 13:26:33 +053014954
14955int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
14956 u8 *peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053014957 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053014958 cfg80211_exttdls_callback callback)
14959{
14960
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053014961 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053014962 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053014963 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053014964 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14965 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
14966 __func__, MAC_ADDR_ARRAY(peer));
14967
14968 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
14969 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
14970
14971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014972 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
14973 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
14974 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053014975 return -ENOTSUPP;
14976 }
14977
14978 /* To cater the requirement of establishing the TDLS link
14979 * irrespective of the data traffic , get an entry of TDLS peer.
14980 */
14981 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
14982 if (pTdlsPeer == NULL) {
14983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14984 "%s: peer " MAC_ADDRESS_STR " not existing",
14985 __func__, MAC_ADDR_ARRAY(peer));
14986 return -EINVAL;
14987 }
14988
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053014989 /* check FW TDLS Off Channel capability */
14990 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
14991 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053014992 {
14993 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
14994 pTdlsPeer->peerParams.global_operating_class =
14995 tdls_peer_params->global_operating_class;
14996 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
14997 pTdlsPeer->peerParams.min_bandwidth_kbps =
14998 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053014999 /* check configured channel is valid, non dfs and
15000 * not current operating channel */
15001 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15002 tdls_peer_params->channel)) &&
15003 (pHddStaCtx) &&
15004 (tdls_peer_params->channel !=
15005 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015006 {
15007 pTdlsPeer->isOffChannelConfigured = TRUE;
15008 }
15009 else
15010 {
15011 pTdlsPeer->isOffChannelConfigured = FALSE;
15012 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15013 "%s: Configured Tdls Off Channel is not valid", __func__);
15014
15015 }
15016 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015017 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15018 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015019 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015020 pTdlsPeer->isOffChannelConfigured,
15021 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015022 }
15023 else
15024 {
15025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015026 "%s: TDLS off channel FW capability %d or "
15027 "Invalid TDLS Peer Params", __func__,
15028 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015029 }
15030
Atul Mittal115287b2014-07-08 13:26:33 +053015031 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15032
15033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15034 " %s TDLS Add Force Peer Failed",
15035 __func__);
15036 return -EINVAL;
15037 }
15038 /*EXT TDLS*/
15039
15040 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15041 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15042 " %s TDLS set callback Failed",
15043 __func__);
15044 return -EINVAL;
15045 }
15046
15047 return(0);
15048
15049}
15050
15051int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer)
15052{
15053
15054 hddTdlsPeer_t *pTdlsPeer;
15055 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15057 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15058 __func__, MAC_ADDR_ARRAY(peer));
15059
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015060 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15061 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15062 return -EINVAL;
15063 }
15064
Atul Mittal115287b2014-07-08 13:26:33 +053015065 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15066 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15067
15068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015069 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15070 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15071 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015072 return -ENOTSUPP;
15073 }
15074
15075
15076 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15077
15078 if ( NULL == pTdlsPeer ) {
15079 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
15080 " peer not exsting",
15081 __func__, MAC_ADDR_ARRAY(peer));
15082 return -EINVAL;
15083 }
15084 else {
15085 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15086 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015087 /* if channel switch is configured, reset
15088 the channel for this peer */
15089 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15090 {
15091 pTdlsPeer->peerParams.channel = 0;
15092 pTdlsPeer->isOffChannelConfigured = FALSE;
15093 }
Atul Mittal115287b2014-07-08 13:26:33 +053015094 }
15095
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015096 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15097 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015098 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015099 }
Atul Mittal115287b2014-07-08 13:26:33 +053015100
15101 /*EXT TDLS*/
15102
15103 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15104
15105 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15106 " %s TDLS set callback Failed",
15107 __func__);
15108 return -EINVAL;
15109 }
15110 return(0);
15111
15112}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015113static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015114 u8 *peer, enum nl80211_tdls_operation oper)
15115{
15116 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15117 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015118 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015119 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015120
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015121 ENTER();
15122
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015123 if (!pAdapter) {
15124 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15125 return -EINVAL;
15126 }
15127
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015128 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15129 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15130 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015131 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015132 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015133 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015134 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015135 return -EINVAL;
15136 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015137
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015138 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015139 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015140 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015141 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015142 }
15143
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015144
15145 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015146 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015147 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015148 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015149 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15150 "Cannot process TDLS commands",
15151 pHddCtx->cfg_ini->fEnableTDLSSupport,
15152 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015153 return -ENOTSUPP;
15154 }
15155
15156 switch (oper) {
15157 case NL80211_TDLS_ENABLE_LINK:
15158 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015159 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015160 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015161 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015162 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015163 tANI_U16 numCurrTdlsPeers = 0;
15164 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015165 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015166
Sunil Dutt41de4e22013-11-14 18:09:02 +053015167 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015168 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015169 if ( NULL == pTdlsPeer ) {
15170 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15171 " (oper %d) not exsting. ignored",
15172 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15173 return -EINVAL;
15174 }
15175
15176 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15177 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15178 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15179 "NL80211_TDLS_ENABLE_LINK");
15180
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015181 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15182 {
15183 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15184 MAC_ADDRESS_STR " failed",
15185 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15186 return -EINVAL;
15187 }
15188
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015189 /* before starting tdls connection, set tdls
15190 * off channel established status to default value */
15191 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015192 /* TDLS Off Channel, Disable tdls channel switch,
15193 when there are more than one tdls link */
15194 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015195 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015196 {
15197 /* get connected peer and send disable tdls off chan */
15198 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15199 if (connPeer && (connPeer->isOffChannelConfigured == TRUE))
15200 {
15201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15202 "%s: More then one peer connected, Disable "
15203 "TDLS channel switch", __func__);
15204
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015205 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015206 ret = sme_SendTdlsChanSwitchReq(
15207 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015208 pAdapter->sessionId,
15209 connPeer->peerMac,
15210 connPeer->peerParams.channel,
15211 TDLS_OFF_CHANNEL_BW_OFFSET,
15212 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015213 if (ret != VOS_STATUS_SUCCESS) {
15214 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel request"));
15215 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015216 }
15217 else
15218 {
15219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15220 "%s: No TDLS Connected Peer or "
15221 "isOffChannelConfigured %d",
15222 __func__,
15223 (connPeer ? connPeer->isOffChannelConfigured : -1));
15224 }
15225 }
15226
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015227 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015228 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015229 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015230
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015231 if (0 != wlan_hdd_tdls_get_link_establish_params(
15232 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015233 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015234 return -EINVAL;
15235 }
15236 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015237
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015238 ret = sme_SendTdlsLinkEstablishParams(
15239 WLAN_HDD_GET_HAL_CTX(pAdapter),
15240 pAdapter->sessionId, peer,
15241 &tdlsLinkEstablishParams);
15242 if (ret != VOS_STATUS_SUCCESS) {
15243 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15244 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015245 /* Send TDLS peer UAPSD capabilities to the firmware and
15246 * register with the TL on after the response for this operation
15247 * is received .
15248 */
15249 ret = wait_for_completion_interruptible_timeout(
15250 &pAdapter->tdls_link_establish_req_comp,
15251 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15252 if (ret <= 0)
15253 {
15254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15255 "%s: Link Establish Request Faled Status %ld",
15256 __func__, ret);
15257 return -EINVAL;
15258 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015259 }
Atul Mittal115287b2014-07-08 13:26:33 +053015260 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15261 eTDLS_LINK_CONNECTED,
15262 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015263 staDesc.ucSTAId = pTdlsPeer->staId;
15264 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015265 ret = WLANTL_UpdateTdlsSTAClient(
15266 pHddCtx->pvosContext,
15267 &staDesc);
15268 if (ret != VOS_STATUS_SUCCESS) {
15269 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15270 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015271
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015272 /* Mark TDLS client Authenticated .*/
15273 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15274 pTdlsPeer->staId,
15275 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015276 if (VOS_STATUS_SUCCESS == status)
15277 {
Hoonki Lee14621352013-04-16 17:51:19 -070015278 if (pTdlsPeer->is_responder == 0)
15279 {
15280 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15281
15282 wlan_hdd_tdls_timer_restart(pAdapter,
15283 &pTdlsPeer->initiatorWaitTimeoutTimer,
15284 WAIT_TIME_TDLS_INITIATOR);
15285 /* suspend initiator TX until it receives direct packet from the
15286 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015287 ret = WLANTL_SuspendDataTx(
15288 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15289 &staId, NULL);
15290 if (ret != VOS_STATUS_SUCCESS) {
15291 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15292 }
Hoonki Lee14621352013-04-16 17:51:19 -070015293 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015294
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015295 suppChannelLen =
15296 tdlsLinkEstablishParams.supportedChannelsLen;
15297 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
15298 (TRUE == pTdlsPeer->isOffChannelConfigured) &&
15299 (suppChannelLen > 0) &&
15300 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15301 {
15302 int offChan = pTdlsPeer->peerParams.channel;
15303 int i = 0;
15304 for (i = 0U; i < suppChannelLen; i++)
15305 {
15306 pTdlsPeer->isOffChannelConfigured = FALSE;
15307 if (
15308 (tdlsLinkEstablishParams.supportedChannels[i]
15309 <= offChan) &&
15310 (tdlsLinkEstablishParams.supportedChannels[i]
15311 == offChan))
15312 {
15313 pTdlsPeer->isOffChannelConfigured = TRUE;
15314 break;
15315 }
15316 }
15317 }
15318 else
15319 {
15320 pTdlsPeer->isOffChannelConfigured = FALSE;
15321 }
15322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15323 "%s: TDLS channel switch request for channel "
15324 "%d isOffChannelConfigured %d suppChannelLen "
15325 "%d", __func__, pTdlsPeer->peerParams.channel,
15326 pTdlsPeer->isOffChannelConfigured,
15327 suppChannelLen);
15328
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015329 /* TDLS Off Channel, Enable tdls channel switch,
15330 when their is only one tdls link and it supports */
15331 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15332 if ((numCurrTdlsPeers == 1) &&
15333 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15334 (TRUE == pTdlsPeer->isOffChannelConfigured))
15335 {
15336 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15337 "%s: Send TDLS channel switch request for channel %d",
15338 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015339
15340 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015341 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15342 pAdapter->sessionId,
15343 pTdlsPeer->peerMac,
15344 pTdlsPeer->peerParams.channel,
15345 TDLS_OFF_CHANNEL_BW_OFFSET,
15346 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015347 if (ret != VOS_STATUS_SUCCESS) {
15348 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15349 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015350 }
15351 else
15352 {
15353 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15354 "%s: TDLS channel switch request not sent"
15355 " numCurrTdlsPeers %d "
15356 "isOffChannelSupported %d "
15357 "isOffChannelConfigured %d",
15358 __func__, numCurrTdlsPeers,
15359 pTdlsPeer->isOffChannelSupported,
15360 pTdlsPeer->isOffChannelConfigured);
15361 }
15362
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015363 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015364 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015365
15366 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015367 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15368 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015369 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015370 int ac;
15371 uint8 ucAc[4] = { WLANTL_AC_VO,
15372 WLANTL_AC_VI,
15373 WLANTL_AC_BK,
15374 WLANTL_AC_BE };
15375 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15376 for(ac=0; ac < 4; ac++)
15377 {
15378 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15379 pTdlsPeer->staId, ucAc[ac],
15380 tlTid[ac], tlTid[ac], 0, 0,
15381 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015382 if (status != VOS_STATUS_SUCCESS) {
15383 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15384 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015385 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015386 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015387 }
15388
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015389 }
15390 break;
15391 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015392 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015393 tANI_U16 numCurrTdlsPeers = 0;
15394 hddTdlsPeer_t *connPeer = NULL;
15395
Sunil Dutt41de4e22013-11-14 18:09:02 +053015396 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15397
15398 if ( NULL == pTdlsPeer ) {
15399 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15400 " (oper %d) not exsting. ignored",
15401 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15402 return -EINVAL;
15403 }
15404
15405 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15406 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15407 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15408 "NL80211_TDLS_DISABLE_LINK");
15409
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015410 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015411 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015412 long status;
15413
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015414 /* set tdls off channel status to false for this peer */
15415 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015416 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15417 eTDLS_LINK_TEARING,
15418 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15419 eTDLS_LINK_UNSPECIFIED:
15420 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015421 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15422
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015423 status = sme_DeleteTdlsPeerSta(
15424 WLAN_HDD_GET_HAL_CTX(pAdapter),
15425 pAdapter->sessionId, peer );
15426 if (status != VOS_STATUS_SUCCESS) {
15427 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15428 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015429
15430 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15431 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015432 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015433 eTDLS_LINK_IDLE,
15434 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015435 if (status <= 0)
15436 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015437 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15438 "%s: Del station failed status %ld",
15439 __func__, status);
15440 return -EPERM;
15441 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015442
15443 /* TDLS Off Channel, Enable tdls channel switch,
15444 when their is only one tdls link and it supports */
15445 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15446 if (numCurrTdlsPeers == 1)
15447 {
15448 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15449 if ((connPeer) &&
15450 (connPeer->isOffChannelSupported == TRUE) &&
15451 (connPeer->isOffChannelConfigured == TRUE))
15452 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015453 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015454 status = sme_SendTdlsChanSwitchReq(
15455 WLAN_HDD_GET_HAL_CTX(pAdapter),
15456 pAdapter->sessionId,
15457 connPeer->peerMac,
15458 connPeer->peerParams.channel,
15459 TDLS_OFF_CHANNEL_BW_OFFSET,
15460 TDLS_CHANNEL_SWITCH_ENABLE);
15461 if (status != VOS_STATUS_SUCCESS) {
15462 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15463 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015464 }
15465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15466 "%s: TDLS channel switch "
15467 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015468 "isOffChannelConfigured %d "
15469 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015470 __func__,
15471 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015472 (connPeer ? connPeer->isOffChannelConfigured : -1),
15473 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015474 }
15475 else
15476 {
15477 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15478 "%s: TDLS channel switch request not sent "
15479 "numCurrTdlsPeers %d ",
15480 __func__, numCurrTdlsPeers);
15481 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015482 }
15483 else
15484 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15486 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080015487 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015488 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015489 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015490 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015491 {
Atul Mittal115287b2014-07-08 13:26:33 +053015492 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015493
Atul Mittal115287b2014-07-08 13:26:33 +053015494 if (0 != status)
15495 {
15496 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15497 "%s: Error in TDLS Teardown", __func__);
15498 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015499 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053015500 break;
15501 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015502 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015503 {
Atul Mittal115287b2014-07-08 13:26:33 +053015504 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
15505 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015506 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053015507 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015508
Atul Mittal115287b2014-07-08 13:26:33 +053015509 if (0 != status)
15510 {
15511 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15512 "%s: Error in TDLS Setup", __func__);
15513 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053015514 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053015515 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015516 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015517 case NL80211_TDLS_DISCOVERY_REQ:
15518 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
15520 "%s: We don't support in-driver setup/teardown/discovery "
15521 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015522 return -ENOTSUPP;
15523 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15525 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015526 return -ENOTSUPP;
15527 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015528
15529 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015530 return 0;
15531}
Chilam NG571c65a2013-01-19 12:27:36 +053015532
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015533static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
15534 u8 *peer, enum nl80211_tdls_operation oper)
15535{
15536 int ret;
15537
15538 vos_ssr_protect(__func__);
15539 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
15540 vos_ssr_unprotect(__func__);
15541
15542 return ret;
15543}
15544
Chilam NG571c65a2013-01-19 12:27:36 +053015545int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
15546 struct net_device *dev, u8 *peer)
15547{
Arif Hussaina7c8e412013-11-20 11:06:42 -080015548 hddLog(VOS_TRACE_LEVEL_INFO,
15549 "tdls send discover req: "MAC_ADDRESS_STR,
15550 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053015551
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015552#if TDLS_MGMT_VERSION2
15553 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15554 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15555#else
Chilam NG571c65a2013-01-19 12:27:36 +053015556 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15557 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015558#endif
Chilam NG571c65a2013-01-19 12:27:36 +053015559}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015560#endif
15561
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015562#ifdef WLAN_FEATURE_GTK_OFFLOAD
15563/*
15564 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
15565 * Callback rountine called upon receiving response for
15566 * get offload info
15567 */
15568void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
15569 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
15570{
15571
15572 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015573 tANI_U8 tempReplayCounter[8];
15574 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015575
15576 ENTER();
15577
15578 if (NULL == pAdapter)
15579 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053015580 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015581 "%s: HDD adapter is Null", __func__);
15582 return ;
15583 }
15584
15585 if (NULL == pGtkOffloadGetInfoRsp)
15586 {
15587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15588 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
15589 return ;
15590 }
15591
15592 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
15593 {
15594 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15595 "%s: wlan Failed to get replay counter value",
15596 __func__);
15597 return ;
15598 }
15599
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015600 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15601 /* Update replay counter */
15602 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
15603 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15604
15605 {
15606 /* changing from little to big endian since supplicant
15607 * works on big endian format
15608 */
15609 int i;
15610 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15611
15612 for (i = 0; i < 8; i++)
15613 {
15614 tempReplayCounter[7-i] = (tANI_U8)p[i];
15615 }
15616 }
15617
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015618 /* Update replay counter to NL */
15619 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015620 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015621}
15622
15623/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015624 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015625 * This function is used to offload GTK rekeying job to the firmware.
15626 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015627int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015628 struct cfg80211_gtk_rekey_data *data)
15629{
15630 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15631 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15632 hdd_station_ctx_t *pHddStaCtx;
15633 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015634 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015635 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015636 eHalStatus status = eHAL_STATUS_FAILURE;
15637
15638 ENTER();
15639
15640 if (NULL == pAdapter)
15641 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015642 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015643 "%s: HDD adapter is Null", __func__);
15644 return -ENODEV;
15645 }
15646
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015647 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15648 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
15649 pAdapter->sessionId, pAdapter->device_mode));
15650
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015651 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015652 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015653 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015654 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015655 }
15656
15657 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15658 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15659 if (NULL == hHal)
15660 {
15661 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15662 "%s: HAL context is Null!!!", __func__);
15663 return -EAGAIN;
15664 }
15665
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015666 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
15667 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
15668 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
15669 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015670 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015671 {
15672 /* changing from big to little endian since driver
15673 * works on little endian format
15674 */
15675 tANI_U8 *p =
15676 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
15677 int i;
15678
15679 for (i = 0; i < 8; i++)
15680 {
15681 p[7-i] = data->replay_ctr[i];
15682 }
15683 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015684
15685 if (TRUE == pHddCtx->hdd_wlan_suspended)
15686 {
15687 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015688 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
15689 sizeof (tSirGtkOffloadParams));
15690 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015691 pAdapter->sessionId);
15692
15693 if (eHAL_STATUS_SUCCESS != status)
15694 {
15695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15696 "%s: sme_SetGTKOffload failed, returned %d",
15697 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015698
15699 /* Need to clear any trace of key value in the memory.
15700 * Thus zero out the memory even though it is local
15701 * variable.
15702 */
15703 vos_mem_zero(&hddGtkOffloadReqParams,
15704 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015705 return status;
15706 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15708 "%s: sme_SetGTKOffload successfull", __func__);
15709 }
15710 else
15711 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15713 "%s: wlan not suspended GTKOffload request is stored",
15714 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015715 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015716
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015717 /* Need to clear any trace of key value in the memory.
15718 * Thus zero out the memory even though it is local
15719 * variable.
15720 */
15721 vos_mem_zero(&hddGtkOffloadReqParams,
15722 sizeof(hddGtkOffloadReqParams));
15723
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015724 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015725 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015726}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015727
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015728int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
15729 struct cfg80211_gtk_rekey_data *data)
15730{
15731 int ret;
15732
15733 vos_ssr_protect(__func__);
15734 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
15735 vos_ssr_unprotect(__func__);
15736
15737 return ret;
15738}
15739#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015740/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015741 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015742 * This function is used to set access control policy
15743 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015744static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15745 struct net_device *dev,
15746 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015747{
15748 int i;
15749 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15750 hdd_hostapd_state_t *pHostapdState;
15751 tsap_Config_t *pConfig;
15752 v_CONTEXT_t pVosContext = NULL;
15753 hdd_context_t *pHddCtx;
15754 int status;
15755
15756 ENTER();
15757
15758 if (NULL == pAdapter)
15759 {
15760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15761 "%s: HDD adapter is Null", __func__);
15762 return -ENODEV;
15763 }
15764
15765 if (NULL == params)
15766 {
15767 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15768 "%s: params is Null", __func__);
15769 return -EINVAL;
15770 }
15771
15772 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15773 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015774 if (0 != status)
15775 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015776 return status;
15777 }
15778
15779 pVosContext = pHddCtx->pvosContext;
15780 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
15781
15782 if (NULL == pHostapdState)
15783 {
15784 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15785 "%s: pHostapdState is Null", __func__);
15786 return -EINVAL;
15787 }
15788
15789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
15790 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
15791
15792 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
15793 {
15794 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
15795
15796 /* default value */
15797 pConfig->num_accept_mac = 0;
15798 pConfig->num_deny_mac = 0;
15799
15800 /**
15801 * access control policy
15802 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
15803 * listed in hostapd.deny file.
15804 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
15805 * listed in hostapd.accept file.
15806 */
15807 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
15808 {
15809 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
15810 }
15811 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
15812 {
15813 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
15814 }
15815 else
15816 {
15817 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15818 "%s:Acl Policy : %d is not supported",
15819 __func__, params->acl_policy);
15820 return -ENOTSUPP;
15821 }
15822
15823 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
15824 {
15825 pConfig->num_accept_mac = params->n_acl_entries;
15826 for (i = 0; i < params->n_acl_entries; i++)
15827 {
15828 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15829 "** Add ACL MAC entry %i in WhiletList :"
15830 MAC_ADDRESS_STR, i,
15831 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
15832
15833 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
15834 sizeof(qcmacaddr));
15835 }
15836 }
15837 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
15838 {
15839 pConfig->num_deny_mac = params->n_acl_entries;
15840 for (i = 0; i < params->n_acl_entries; i++)
15841 {
15842 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15843 "** Add ACL MAC entry %i in BlackList :"
15844 MAC_ADDRESS_STR, i,
15845 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
15846
15847 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
15848 sizeof(qcmacaddr));
15849 }
15850 }
15851
15852 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
15853 {
15854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15855 "%s: SAP Set Mac Acl fail", __func__);
15856 return -EINVAL;
15857 }
15858 }
15859 else
15860 {
15861 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015862 "%s: Invalid device_mode = %s (%d)",
15863 __func__, hdd_device_modetoString(pAdapter->device_mode),
15864 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015865 return -EINVAL;
15866 }
15867
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015868 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015869 return 0;
15870}
15871
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015872static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15873 struct net_device *dev,
15874 const struct cfg80211_acl_data *params)
15875{
15876 int ret;
15877 vos_ssr_protect(__func__);
15878 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
15879 vos_ssr_unprotect(__func__);
15880
15881 return ret;
15882}
15883
Leo Chang9056f462013-08-01 19:21:11 -070015884#ifdef WLAN_NL80211_TESTMODE
15885#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070015886void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070015887(
15888 void *pAdapter,
15889 void *indCont
15890)
15891{
Leo Changd9df8aa2013-09-26 13:32:26 -070015892 tSirLPHBInd *lphbInd;
15893 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053015894 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070015895
15896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070015897 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070015898
c_hpothu73f35e62014-04-18 13:40:08 +053015899 if (pAdapter == NULL)
15900 {
15901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15902 "%s: pAdapter is NULL\n",__func__);
15903 return;
15904 }
15905
Leo Chang9056f462013-08-01 19:21:11 -070015906 if (NULL == indCont)
15907 {
15908 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070015909 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070015910 return;
15911 }
15912
c_hpothu73f35e62014-04-18 13:40:08 +053015913 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070015914 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070015915 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053015916 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070015917 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070015918 GFP_ATOMIC);
15919 if (!skb)
15920 {
15921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15922 "LPHB timeout, NL buffer alloc fail");
15923 return;
15924 }
15925
Leo Changac3ba772013-10-07 09:47:04 -070015926 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070015927 {
15928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15929 "WLAN_HDD_TM_ATTR_CMD put fail");
15930 goto nla_put_failure;
15931 }
Leo Changac3ba772013-10-07 09:47:04 -070015932 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070015933 {
15934 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15935 "WLAN_HDD_TM_ATTR_TYPE put fail");
15936 goto nla_put_failure;
15937 }
Leo Changac3ba772013-10-07 09:47:04 -070015938 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070015939 sizeof(tSirLPHBInd), lphbInd))
15940 {
15941 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15942 "WLAN_HDD_TM_ATTR_DATA put fail");
15943 goto nla_put_failure;
15944 }
Leo Chang9056f462013-08-01 19:21:11 -070015945 cfg80211_testmode_event(skb, GFP_ATOMIC);
15946 return;
15947
15948nla_put_failure:
15949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15950 "NLA Put fail");
15951 kfree_skb(skb);
15952
15953 return;
15954}
15955#endif /* FEATURE_WLAN_LPHB */
15956
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015957static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070015958{
15959 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
15960 int err = 0;
15961#ifdef FEATURE_WLAN_LPHB
15962 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070015963 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015964
15965 ENTER();
15966
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053015967 err = wlan_hdd_validate_context(pHddCtx);
15968 if (0 != err)
15969 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053015970 return err;
15971 }
Leo Chang9056f462013-08-01 19:21:11 -070015972#endif /* FEATURE_WLAN_LPHB */
15973
15974 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
15975 if (err)
15976 {
15977 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15978 "%s Testmode INV ATTR", __func__);
15979 return err;
15980 }
15981
15982 if (!tb[WLAN_HDD_TM_ATTR_CMD])
15983 {
15984 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15985 "%s Testmode INV CMD", __func__);
15986 return -EINVAL;
15987 }
15988
15989 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
15990 {
15991#ifdef FEATURE_WLAN_LPHB
15992 /* Low Power Heartbeat configuration request */
15993 case WLAN_HDD_TM_CMD_WLAN_HB:
15994 {
15995 int buf_len;
15996 void *buf;
15997 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080015998 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070015999
16000 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16001 {
16002 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16003 "%s Testmode INV DATA", __func__);
16004 return -EINVAL;
16005 }
16006
16007 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16008 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016009
16010 hb_params_temp =(tSirLPHBReq *)buf;
16011 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16012 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16013 return -EINVAL;
16014
Leo Chang9056f462013-08-01 19:21:11 -070016015 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16016 if (NULL == hb_params)
16017 {
16018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16019 "%s Request Buffer Alloc Fail", __func__);
16020 return -EINVAL;
16021 }
16022
16023 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016024 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16025 hb_params,
16026 wlan_hdd_cfg80211_lphb_ind_handler);
16027 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016028 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16030 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016031 vos_mem_free(hb_params);
16032 }
Leo Chang9056f462013-08-01 19:21:11 -070016033 return 0;
16034 }
16035#endif /* FEATURE_WLAN_LPHB */
16036 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016037 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16038 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016039 return -EOPNOTSUPP;
16040 }
16041
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016042 EXIT();
16043 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016044}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016045
16046static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
16047{
16048 int ret;
16049
16050 vos_ssr_protect(__func__);
16051 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16052 vos_ssr_unprotect(__func__);
16053
16054 return ret;
16055}
Leo Chang9056f462013-08-01 19:21:11 -070016056#endif /* CONFIG_NL80211_TESTMODE */
16057
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016058static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016059 struct net_device *dev,
16060 int idx, struct survey_info *survey)
16061{
16062 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16063 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016064 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016065 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016066 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016067 v_S7_t snr,rssi;
16068 int status, i, j, filled = 0;
16069
16070 ENTER();
16071
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016072 if (NULL == pAdapter)
16073 {
16074 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16075 "%s: HDD adapter is Null", __func__);
16076 return -ENODEV;
16077 }
16078
16079 if (NULL == wiphy)
16080 {
16081 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16082 "%s: wiphy is Null", __func__);
16083 return -ENODEV;
16084 }
16085
16086 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16087 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016088 if (0 != status)
16089 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016090 return status;
16091 }
16092
Mihir Sheted9072e02013-08-21 17:02:29 +053016093 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16094
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016095 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016096 0 != pAdapter->survey_idx ||
16097 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016098 {
16099 /* The survey dump ops when implemented completely is expected to
16100 * return a survey of all channels and the ops is called by the
16101 * kernel with incremental values of the argument 'idx' till it
16102 * returns -ENONET. But we can only support the survey for the
16103 * operating channel for now. survey_idx is used to track
16104 * that the ops is called only once and then return -ENONET for
16105 * the next iteration
16106 */
16107 pAdapter->survey_idx = 0;
16108 return -ENONET;
16109 }
16110
16111 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16112
16113 wlan_hdd_get_snr(pAdapter, &snr);
16114 wlan_hdd_get_rssi(pAdapter, &rssi);
16115
16116 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16117 hdd_wlan_get_freq(channel, &freq);
16118
16119
16120 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16121 {
16122 if (NULL == wiphy->bands[i])
16123 {
16124 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16125 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16126 continue;
16127 }
16128
16129 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16130 {
16131 struct ieee80211_supported_band *band = wiphy->bands[i];
16132
16133 if (band->channels[j].center_freq == (v_U16_t)freq)
16134 {
16135 survey->channel = &band->channels[j];
16136 /* The Rx BDs contain SNR values in dB for the received frames
16137 * while the supplicant expects noise. So we calculate and
16138 * return the value of noise (dBm)
16139 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16140 */
16141 survey->noise = rssi - snr;
16142 survey->filled = SURVEY_INFO_NOISE_DBM;
16143 filled = 1;
16144 }
16145 }
16146 }
16147
16148 if (filled)
16149 pAdapter->survey_idx = 1;
16150 else
16151 {
16152 pAdapter->survey_idx = 0;
16153 return -ENONET;
16154 }
16155
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016156 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016157 return 0;
16158}
16159
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016160static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16161 struct net_device *dev,
16162 int idx, struct survey_info *survey)
16163{
16164 int ret;
16165
16166 vos_ssr_protect(__func__);
16167 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16168 vos_ssr_unprotect(__func__);
16169
16170 return ret;
16171}
16172
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016173/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016174 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016175 * this is called when cfg80211 driver resume
16176 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16177 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016178int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016179{
16180 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16181 hdd_adapter_t *pAdapter;
16182 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16183 VOS_STATUS status = VOS_STATUS_SUCCESS;
16184
16185 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016186
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016187 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016188 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016189 return 0;
16190 }
16191
16192 spin_lock(&pHddCtx->schedScan_lock);
16193 pHddCtx->isWiphySuspended = FALSE;
16194 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16195 {
16196 spin_unlock(&pHddCtx->schedScan_lock);
16197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16198 "%s: Return resume is not due to PNO indication", __func__);
16199 return 0;
16200 }
16201 // Reset flag to avoid updatating cfg80211 data old results again
16202 pHddCtx->isSchedScanUpdatePending = FALSE;
16203 spin_unlock(&pHddCtx->schedScan_lock);
16204
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016205
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016206 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16207
16208 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16209 {
16210 pAdapter = pAdapterNode->pAdapter;
16211 if ( (NULL != pAdapter) &&
16212 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16213 {
16214 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016215 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016216 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16217 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016218 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016219 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016220 {
16221 /* Acquire wakelock to handle the case where APP's tries to
16222 * suspend immediately after updating the scan results. Whis
16223 * results in app's is in suspended state and not able to
16224 * process the connect request to AP
16225 */
16226 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016227 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016228 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016229
16230 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16231 "%s : cfg80211 scan result database updated", __func__);
16232
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016233 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016234 return 0;
16235
16236 }
16237 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16238 pAdapterNode = pNext;
16239 }
16240
16241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16242 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016243 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016244 return 0;
16245}
16246
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016247int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16248{
16249 int ret;
16250
16251 vos_ssr_protect(__func__);
16252 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16253 vos_ssr_unprotect(__func__);
16254
16255 return ret;
16256}
16257
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016258/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016259 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016260 * this is called when cfg80211 driver suspends
16261 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016262int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016263 struct cfg80211_wowlan *wow)
16264{
16265 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016266 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016267
16268 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016269
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016270 ret = wlan_hdd_validate_context(pHddCtx);
16271 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016272 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016273 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016274 }
16275
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016276
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016277 pHddCtx->isWiphySuspended = TRUE;
16278
16279 EXIT();
16280
16281 return 0;
16282}
16283
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016284int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16285 struct cfg80211_wowlan *wow)
16286{
16287 int ret;
16288
16289 vos_ssr_protect(__func__);
16290 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16291 vos_ssr_unprotect(__func__);
16292
16293 return ret;
16294}
Jeff Johnson295189b2012-06-20 16:38:30 -070016295/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016296static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016297{
16298 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16299 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16300 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16301 .change_station = wlan_hdd_change_station,
16302#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16303 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16304 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16305 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016306#else
16307 .start_ap = wlan_hdd_cfg80211_start_ap,
16308 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16309 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016310#endif
16311 .change_bss = wlan_hdd_cfg80211_change_bss,
16312 .add_key = wlan_hdd_cfg80211_add_key,
16313 .get_key = wlan_hdd_cfg80211_get_key,
16314 .del_key = wlan_hdd_cfg80211_del_key,
16315 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016316#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016317 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016318#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016319 .scan = wlan_hdd_cfg80211_scan,
16320 .connect = wlan_hdd_cfg80211_connect,
16321 .disconnect = wlan_hdd_cfg80211_disconnect,
16322 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16323 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16324 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16325 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16326 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016327 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16328 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016329 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016330#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16331 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16332 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16333 .set_txq_params = wlan_hdd_set_txq_params,
16334#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016335 .get_station = wlan_hdd_cfg80211_get_station,
16336 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16337 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016338 .add_station = wlan_hdd_cfg80211_add_station,
16339#ifdef FEATURE_WLAN_LFR
16340 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16341 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16342 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16343#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016344#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16345 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16346#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016347#ifdef FEATURE_WLAN_TDLS
16348 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16349 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16350#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016351#ifdef WLAN_FEATURE_GTK_OFFLOAD
16352 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16353#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016354#ifdef FEATURE_WLAN_SCAN_PNO
16355 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16356 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16357#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016358 .resume = wlan_hdd_cfg80211_resume_wlan,
16359 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016360 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016361#ifdef WLAN_NL80211_TESTMODE
16362 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16363#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016364 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016365};
16366