blob: 5c26a34d606a6f4d6462aeb43fca7ba3c3be89e7 [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#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053094#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053095#include "wlan_qct_wda.h"
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053096#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070097#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070098
99#define g_mode_rates_size (12)
100#define a_mode_rates_size (8)
101#define FREQ_BASE_80211G (2407)
102#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700103#define MAX_SCAN_SSID 9
Kiet Lamac06e2c2013-10-23 16:25:07 +0530104#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
krunal soni2a6a9062014-02-11 14:14:23 -0800106 ((uintptr_t)OFFSET_OF( tSirBssDescription, ieFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700107
108#define HDD2GHZCHAN(freq, chan, flag) { \
109 .band = IEEE80211_BAND_2GHZ, \
110 .center_freq = (freq), \
111 .hw_value = (chan),\
112 .flags = (flag), \
113 .max_antenna_gain = 0 ,\
114 .max_power = 30, \
115}
116
117#define HDD5GHZCHAN(freq, chan, flag) { \
118 .band = IEEE80211_BAND_5GHZ, \
119 .center_freq = (freq), \
120 .hw_value = (chan),\
121 .flags = (flag), \
122 .max_antenna_gain = 0 ,\
123 .max_power = 30, \
124}
125
126#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
127{\
128 .bitrate = rate, \
129 .hw_value = rate_id, \
130 .flags = flag, \
131}
132
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530133#ifdef WLAN_FEATURE_VOWIFI_11R
134#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
135#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
136#endif
137
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530138#define HDD_CHANNEL_14 14
Dasari Srinivase18b2cf2014-10-28 17:09:42 +0530139#define WLAN_HDD_MAX_FEATURE_SET 8
Naresh Jayaram3180aa42014-02-12 21:47:26 +0530140
Sunil Duttc69bccb2014-05-26 21:30:20 +0530141#ifdef WLAN_FEATURE_LINK_LAYER_STATS
142/*
143 * Used to allocate the size of 4096 for the link layer stats.
144 * The size of 4096 is considered assuming that all data per
145 * respective event fit with in the limit.Please take a call
146 * on the limit based on the data requirements on link layer
147 * statistics.
148 */
149#define LL_STATS_EVENT_BUF_SIZE 4096
150#endif
Dino Mycle6fb96c12014-06-10 11:52:40 +0530151#ifdef WLAN_FEATURE_EXTSCAN
152/*
153 * Used to allocate the size of 4096 for the EXTScan NL data.
154 * The size of 4096 is considered assuming that all data per
155 * respective event fit with in the limit.Please take a call
156 * on the limit based on the data requirements.
157 */
158
159#define EXTSCAN_EVENT_BUF_SIZE 4096
160#define EXTSCAN_MAX_CACHED_RESULTS_PER_IND 32
161#endif
Sunil Duttc69bccb2014-05-26 21:30:20 +0530162
Atul Mittal115287b2014-07-08 13:26:33 +0530163/*EXT TDLS*/
164/*
165 * Used to allocate the size of 4096 for the TDLS.
166 * The size of 4096 is considered assuming that all data per
167 * respective event fit with in the limit.Please take a call
168 * on the limit based on the data requirements on link layer
169 * statistics.
170 */
171#define EXTTDLS_EVENT_BUF_SIZE 4096
172
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530173static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700174{
175 WLAN_CIPHER_SUITE_WEP40,
176 WLAN_CIPHER_SUITE_WEP104,
177 WLAN_CIPHER_SUITE_TKIP,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800178#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
180 WLAN_CIPHER_SUITE_KRK,
181 WLAN_CIPHER_SUITE_CCMP,
182#else
183 WLAN_CIPHER_SUITE_CCMP,
184#endif
185#ifdef FEATURE_WLAN_WAPI
186 WLAN_CIPHER_SUITE_SMS4,
187#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700188#ifdef WLAN_FEATURE_11W
189 WLAN_CIPHER_SUITE_AES_CMAC,
190#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700191};
192
193static inline int is_broadcast_ether_addr(const u8 *addr)
194{
195 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
196 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
197}
198
199static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530200{
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 HDD2GHZCHAN(2412, 1, 0) ,
202 HDD2GHZCHAN(2417, 2, 0) ,
203 HDD2GHZCHAN(2422, 3, 0) ,
204 HDD2GHZCHAN(2427, 4, 0) ,
205 HDD2GHZCHAN(2432, 5, 0) ,
206 HDD2GHZCHAN(2437, 6, 0) ,
207 HDD2GHZCHAN(2442, 7, 0) ,
208 HDD2GHZCHAN(2447, 8, 0) ,
209 HDD2GHZCHAN(2452, 9, 0) ,
210 HDD2GHZCHAN(2457, 10, 0) ,
211 HDD2GHZCHAN(2462, 11, 0) ,
212 HDD2GHZCHAN(2467, 12, 0) ,
213 HDD2GHZCHAN(2472, 13, 0) ,
214 HDD2GHZCHAN(2484, 14, 0) ,
215};
216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
218{
219 HDD2GHZCHAN(2412, 1, 0) ,
220 HDD2GHZCHAN(2437, 6, 0) ,
221 HDD2GHZCHAN(2462, 11, 0) ,
222};
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224static struct ieee80211_channel hdd_channels_5_GHZ[] =
225{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700226 HDD5GHZCHAN(4920, 240, 0) ,
227 HDD5GHZCHAN(4940, 244, 0) ,
228 HDD5GHZCHAN(4960, 248, 0) ,
229 HDD5GHZCHAN(4980, 252, 0) ,
230 HDD5GHZCHAN(5040, 208, 0) ,
231 HDD5GHZCHAN(5060, 212, 0) ,
232 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 HDD5GHZCHAN(5180, 36, 0) ,
234 HDD5GHZCHAN(5200, 40, 0) ,
235 HDD5GHZCHAN(5220, 44, 0) ,
236 HDD5GHZCHAN(5240, 48, 0) ,
237 HDD5GHZCHAN(5260, 52, 0) ,
238 HDD5GHZCHAN(5280, 56, 0) ,
239 HDD5GHZCHAN(5300, 60, 0) ,
240 HDD5GHZCHAN(5320, 64, 0) ,
241 HDD5GHZCHAN(5500,100, 0) ,
242 HDD5GHZCHAN(5520,104, 0) ,
243 HDD5GHZCHAN(5540,108, 0) ,
244 HDD5GHZCHAN(5560,112, 0) ,
245 HDD5GHZCHAN(5580,116, 0) ,
246 HDD5GHZCHAN(5600,120, 0) ,
247 HDD5GHZCHAN(5620,124, 0) ,
248 HDD5GHZCHAN(5640,128, 0) ,
249 HDD5GHZCHAN(5660,132, 0) ,
250 HDD5GHZCHAN(5680,136, 0) ,
251 HDD5GHZCHAN(5700,140, 0) ,
Leo Chang80de3c22013-11-26 10:52:12 -0800252#ifdef FEATURE_WLAN_CH144
253 HDD5GHZCHAN(5720,144, 0) ,
254#endif /* FEATURE_WLAN_CH144 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 HDD5GHZCHAN(5745,149, 0) ,
256 HDD5GHZCHAN(5765,153, 0) ,
257 HDD5GHZCHAN(5785,157, 0) ,
258 HDD5GHZCHAN(5805,161, 0) ,
259 HDD5GHZCHAN(5825,165, 0) ,
260};
261
262static struct ieee80211_rate g_mode_rates[] =
263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530264 HDD_G_MODE_RATETAB(10, 0x1, 0),
265 HDD_G_MODE_RATETAB(20, 0x2, 0),
266 HDD_G_MODE_RATETAB(55, 0x4, 0),
267 HDD_G_MODE_RATETAB(110, 0x8, 0),
268 HDD_G_MODE_RATETAB(60, 0x10, 0),
269 HDD_G_MODE_RATETAB(90, 0x20, 0),
270 HDD_G_MODE_RATETAB(120, 0x40, 0),
271 HDD_G_MODE_RATETAB(180, 0x80, 0),
272 HDD_G_MODE_RATETAB(240, 0x100, 0),
273 HDD_G_MODE_RATETAB(360, 0x200, 0),
274 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530276};
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278static struct ieee80211_rate a_mode_rates[] =
279{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530280 HDD_G_MODE_RATETAB(60, 0x10, 0),
281 HDD_G_MODE_RATETAB(90, 0x20, 0),
282 HDD_G_MODE_RATETAB(120, 0x40, 0),
283 HDD_G_MODE_RATETAB(180, 0x80, 0),
284 HDD_G_MODE_RATETAB(240, 0x100, 0),
285 HDD_G_MODE_RATETAB(360, 0x200, 0),
286 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 HDD_G_MODE_RATETAB(540, 0x800, 0),
288};
289
290static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
291{
292 .channels = hdd_channels_2_4_GHZ,
293 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
294 .band = IEEE80211_BAND_2GHZ,
295 .bitrates = g_mode_rates,
296 .n_bitrates = g_mode_rates_size,
297 .ht_cap.ht_supported = 1,
298 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
299 | IEEE80211_HT_CAP_GRN_FLD
300 | IEEE80211_HT_CAP_DSSSCCK40
301 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
302 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
303 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
304 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
305 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
306 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
307};
308
Jeff Johnson295189b2012-06-20 16:38:30 -0700309static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
310{
311 .channels = hdd_social_channels_2_4_GHZ,
312 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
313 .band = IEEE80211_BAND_2GHZ,
314 .bitrates = g_mode_rates,
315 .n_bitrates = g_mode_rates_size,
316 .ht_cap.ht_supported = 1,
317 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
318 | IEEE80211_HT_CAP_GRN_FLD
319 | IEEE80211_HT_CAP_DSSSCCK40
320 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
321 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
322 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
323 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
324 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
325 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
326};
Jeff Johnson295189b2012-06-20 16:38:30 -0700327
328static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
329{
330 .channels = hdd_channels_5_GHZ,
331 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
332 .band = IEEE80211_BAND_5GHZ,
333 .bitrates = a_mode_rates,
334 .n_bitrates = a_mode_rates_size,
335 .ht_cap.ht_supported = 1,
336 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
337 | IEEE80211_HT_CAP_GRN_FLD
338 | IEEE80211_HT_CAP_DSSSCCK40
339 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
340 | IEEE80211_HT_CAP_SGI_40
341 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
342 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
343 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
344 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
345 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
346 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
347};
348
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530349/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 TX/RX direction for each kind of interface */
351static const struct ieee80211_txrx_stypes
352wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
353 [NL80211_IFTYPE_STATION] = {
354 .tx = 0xffff,
355 .rx = BIT(SIR_MAC_MGMT_ACTION) |
356 BIT(SIR_MAC_MGMT_PROBE_REQ),
357 },
358 [NL80211_IFTYPE_AP] = {
359 .tx = 0xffff,
360 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
361 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
362 BIT(SIR_MAC_MGMT_PROBE_REQ) |
363 BIT(SIR_MAC_MGMT_DISASSOC) |
364 BIT(SIR_MAC_MGMT_AUTH) |
365 BIT(SIR_MAC_MGMT_DEAUTH) |
366 BIT(SIR_MAC_MGMT_ACTION),
367 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700368 [NL80211_IFTYPE_ADHOC] = {
369 .tx = 0xffff,
370 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
371 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
372 BIT(SIR_MAC_MGMT_PROBE_REQ) |
373 BIT(SIR_MAC_MGMT_DISASSOC) |
374 BIT(SIR_MAC_MGMT_AUTH) |
375 BIT(SIR_MAC_MGMT_DEAUTH) |
376 BIT(SIR_MAC_MGMT_ACTION),
377 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700378 [NL80211_IFTYPE_P2P_CLIENT] = {
379 .tx = 0xffff,
380 .rx = BIT(SIR_MAC_MGMT_ACTION) |
381 BIT(SIR_MAC_MGMT_PROBE_REQ),
382 },
383 [NL80211_IFTYPE_P2P_GO] = {
384 /* This is also same as for SoftAP */
385 .tx = 0xffff,
386 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
387 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
388 BIT(SIR_MAC_MGMT_PROBE_REQ) |
389 BIT(SIR_MAC_MGMT_DISASSOC) |
390 BIT(SIR_MAC_MGMT_AUTH) |
391 BIT(SIR_MAC_MGMT_DEAUTH) |
392 BIT(SIR_MAC_MGMT_ACTION),
393 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700394};
395
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800396#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800397static const struct ieee80211_iface_limit
398wlan_hdd_iface_limit[] = {
399 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800400 /* max = 3 ; Our driver create two interfaces during driver init
401 * wlan0 and p2p0 interfaces. p2p0 is considered as station
402 * interface until a group is formed. In JB architecture, once the
403 * group is formed, interface type of p2p0 is changed to P2P GO or
404 * Client.
405 * When supplicant remove the group, it first issue a set interface
406 * cmd to change the mode back to Station. In JB this works fine as
407 * we advertize two station type interface during driver init.
408 * Some vendors create separate interface for P2P GO/Client,
409 * after group formation(Third one). But while group remove
410 * supplicant first tries to change the mode(3rd interface) to STATION
411 * But as we advertized only two sta type interfaces nl80211 was
412 * returning error for the third one which was leading to failure in
413 * delete interface. Ideally while removing the group, supplicant
414 * should not try to change the 3rd interface mode to Station type.
415 * Till we get a fix in wpa_supplicant, we advertize max STA
416 * interface type to 3
417 */
418 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800419 .types = BIT(NL80211_IFTYPE_STATION),
420 },
421 {
422 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700423 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800424 },
425 {
426 .max = 1,
427 .types = BIT(NL80211_IFTYPE_P2P_GO) |
428 BIT(NL80211_IFTYPE_P2P_CLIENT),
429 },
430};
431
432/* By default, only single channel concurrency is allowed */
433static struct ieee80211_iface_combination
434wlan_hdd_iface_combination = {
435 .limits = wlan_hdd_iface_limit,
436 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800437 /*
438 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
439 * and p2p0 interfaces during driver init
440 * Some vendors create separate interface for P2P operations.
441 * wlan0: STA interface
442 * p2p0: P2P Device interface, action frames goes
443 * through this interface.
444 * p2p-xx: P2P interface, After GO negotiation this interface is
445 * created for p2p operations(GO/CLIENT interface).
446 */
447 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800448 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
449 .beacon_int_infra_match = false,
450};
451#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800452
Jeff Johnson295189b2012-06-20 16:38:30 -0700453static struct cfg80211_ops wlan_hdd_cfg80211_ops;
454
455/* Data rate 100KBPS based on IE Index */
456struct index_data_rate_type
457{
458 v_U8_t beacon_rate_index;
459 v_U16_t supported_rate[4];
460};
461
462/* 11B, 11G Rate table include Basic rate and Extended rate
463 The IDX field is the rate index
464 The HI field is the rate when RSSI is strong or being ignored
465 (in this case we report actual rate)
466 The MID field is the rate when RSSI is moderate
467 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
468 The LO field is the rate when RSSI is low
469 (in this case we don't report rates, actual current rate used)
470 */
471static const struct
472{
473 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700474 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700475} supported_data_rate[] =
476{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700477/* IDX HI HM LM LO (RSSI-based index */
478 {2, { 10, 10, 10, 0}},
479 {4, { 20, 20, 10, 0}},
480 {11, { 55, 20, 10, 0}},
481 {12, { 60, 55, 20, 0}},
482 {18, { 90, 55, 20, 0}},
483 {22, {110, 55, 20, 0}},
484 {24, {120, 90, 60, 0}},
485 {36, {180, 120, 60, 0}},
486 {44, {220, 180, 60, 0}},
487 {48, {240, 180, 90, 0}},
488 {66, {330, 180, 90, 0}},
489 {72, {360, 240, 90, 0}},
490 {96, {480, 240, 120, 0}},
491 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700492};
493
494/* MCS Based rate table */
495static struct index_data_rate_type supported_mcs_rate[] =
496{
497/* MCS L20 L40 S20 S40 */
498 {0, {65, 135, 72, 150}},
499 {1, {130, 270, 144, 300}},
500 {2, {195, 405, 217, 450}},
501 {3, {260, 540, 289, 600}},
502 {4, {390, 810, 433, 900}},
503 {5, {520, 1080, 578, 1200}},
504 {6, {585, 1215, 650, 1350}},
505 {7, {650, 1350, 722, 1500}}
506};
507
Leo Chang6f8870f2013-03-26 18:11:36 -0700508#ifdef WLAN_FEATURE_11AC
509
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530510#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700511
512struct index_vht_data_rate_type
513{
514 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530515 v_U16_t supported_VHT80_rate[2];
516 v_U16_t supported_VHT40_rate[2];
517 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700518};
519
520typedef enum
521{
522 DATA_RATE_11AC_MAX_MCS_7,
523 DATA_RATE_11AC_MAX_MCS_8,
524 DATA_RATE_11AC_MAX_MCS_9,
525 DATA_RATE_11AC_MAX_MCS_NA
526} eDataRate11ACMaxMcs;
527
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +0530528/* SSID broadcast type */
529typedef enum eSSIDBcastType
530{
531 eBCAST_UNKNOWN = 0,
532 eBCAST_NORMAL = 1,
533 eBCAST_HIDDEN = 2,
534} tSSIDBcastType;
535
Leo Chang6f8870f2013-03-26 18:11:36 -0700536/* MCS Based VHT rate table */
537static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
538{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530539/* MCS L80 S80 L40 S40 L20 S40*/
540 {0, {293, 325}, {135, 150}, {65, 72}},
541 {1, {585, 650}, {270, 300}, {130, 144}},
542 {2, {878, 975}, {405, 450}, {195, 217}},
543 {3, {1170, 1300}, {540, 600}, {260, 289}},
544 {4, {1755, 1950}, {810, 900}, {390, 433}},
545 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
546 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
547 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
548 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
549 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700550};
551#endif /* WLAN_FEATURE_11AC */
552
c_hpothu79aab322014-07-14 21:11:01 +0530553/*array index points to MCS and array value points respective rssi*/
554static int rssiMcsTbl[][10] =
555{
556/*MCS 0 1 2 3 4 5 6 7 8 9*/
557 {-82, -79, -77, -74, -70, -66, -65, -64, -59, -57}, //20
558 {-79, -76, -74, -71, -67, -63, -62, -61, -56, -54}, //40
559 {-76, -73, -71, -68, -64, -60, -59, -58, -53, -51} //80
560};
561
Jeff Johnson295189b2012-06-20 16:38:30 -0700562extern struct net_device_ops net_ops_struct;
Dasari Srinivas7875a302014-09-26 17:50:57 +0530563#ifdef FEATURE_WLAN_SCAN_PNO
564static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter);
565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700566
Leo Chang9056f462013-08-01 19:21:11 -0700567#ifdef WLAN_NL80211_TESTMODE
568enum wlan_hdd_tm_attr
569{
570 WLAN_HDD_TM_ATTR_INVALID = 0,
571 WLAN_HDD_TM_ATTR_CMD = 1,
572 WLAN_HDD_TM_ATTR_DATA = 2,
573 WLAN_HDD_TM_ATTR_TYPE = 3,
574 /* keep last */
575 WLAN_HDD_TM_ATTR_AFTER_LAST,
576 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
577};
578
579enum wlan_hdd_tm_cmd
580{
581 WLAN_HDD_TM_CMD_WLAN_HB = 1,
582};
583
584#define WLAN_HDD_TM_DATA_MAX_LEN 5000
585
586static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
587{
588 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
589 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
590 .len = WLAN_HDD_TM_DATA_MAX_LEN },
591};
592#endif /* WLAN_NL80211_TESTMODE */
593
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800594#ifdef FEATURE_WLAN_CH_AVOID
595/*
596 * FUNCTION: wlan_hdd_send_avoid_freq_event
597 * This is called when wlan driver needs to send vendor specific
598 * avoid frequency range event to userspace
599 */
600int wlan_hdd_send_avoid_freq_event(hdd_context_t *pHddCtx,
601 tHddAvoidFreqList *pAvoidFreqList)
602{
603 struct sk_buff *vendor_event;
604
605 ENTER();
606
607 if (!pHddCtx)
608 {
609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
610 "%s: HDD context is null", __func__);
611 return -1;
612 }
613
614 if (!pAvoidFreqList)
615 {
616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
617 "%s: pAvoidFreqList is null", __func__);
618 return -1;
619 }
620
621 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
622 sizeof(tHddAvoidFreqList),
Sunil Duttc69bccb2014-05-26 21:30:20 +0530623 QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY_INDEX,
Rajesh Chauhan98a31f82014-01-06 20:15:25 -0800624 GFP_KERNEL);
625 if (!vendor_event)
626 {
627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
628 "%s: cfg80211_vendor_event_alloc failed", __func__);
629 return -1;
630 }
631
632 memcpy(skb_put(vendor_event, sizeof(tHddAvoidFreqList)),
633 (void *)pAvoidFreqList, sizeof(tHddAvoidFreqList));
634
635 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
636
637 EXIT();
638 return 0;
639}
640#endif /* FEATURE_WLAN_CH_AVOID */
641
Srinivas Dasari030bad32015-02-18 23:23:54 +0530642/*
643 * FUNCTION: __wlan_hdd_cfg80211_nan_request
644 * This is called when wlan driver needs to send vendor specific
645 * nan request event.
646 */
647static int __wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
648 struct wireless_dev *wdev,
649 const void *data, int data_len)
650{
651 tNanRequestReq nan_req;
652 VOS_STATUS status;
653 int ret_val = -1;
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530654 struct net_device *dev = wdev->netdev;
655 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
656 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530657 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
658
659 if (0 == data_len)
660 {
661 hddLog(VOS_TRACE_LEVEL_ERROR,
662 FL("NAN - Invalid Request, length = 0"));
663 return ret_val;
664 }
665
666 if (NULL == data)
667 {
668 hddLog(VOS_TRACE_LEVEL_ERROR,
669 FL("NAN - Invalid Request, data is NULL"));
670 return ret_val;
671 }
672
673 status = wlan_hdd_validate_context(pHddCtx);
674 if (0 != status)
675 {
676 hddLog(VOS_TRACE_LEVEL_ERROR,
677 FL("HDD context is not valid"));
678 return -EINVAL;
679 }
680
681 hddLog(LOG1, FL("Received NAN command"));
682 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
683 (tANI_U8 *)data, data_len);
684
685 /* check the NAN Capability */
686 if (TRUE != sme_IsFeatureSupportedByFW(NAN))
687 {
688 hddLog(VOS_TRACE_LEVEL_ERROR,
689 FL("NAN is not supported by Firmware"));
690 return -EINVAL;
691 }
692
693 nan_req.request_data_len = data_len;
694 nan_req.request_data = data;
695
Srinivas Dasaria3f11c02015-03-20 13:15:20 +0530696 status = sme_NanRequest(hHal, &nan_req, pAdapter->sessionId);
Srinivas Dasari030bad32015-02-18 23:23:54 +0530697 if (VOS_STATUS_SUCCESS == status)
698 {
699 ret_val = 0;
700 }
701 return ret_val;
702}
703
704/*
705 * FUNCTION: wlan_hdd_cfg80211_nan_request
706 * Wrapper to protect the nan vendor command from ssr
707 */
708static int wlan_hdd_cfg80211_nan_request(struct wiphy *wiphy,
709 struct wireless_dev *wdev,
710 const void *data, int data_len)
711{
712 int ret;
713
714 vos_ssr_protect(__func__);
715 ret = __wlan_hdd_cfg80211_nan_request(wiphy, wdev, data, data_len);
716 vos_ssr_unprotect(__func__);
717
718 return ret;
719}
720
721/*
722 * FUNCTION: wlan_hdd_cfg80211_nan_callback
723 * This is a callback function and it gets called
724 * when we need to report nan response event to
725 * upper layers.
726 */
727static void wlan_hdd_cfg80211_nan_callback(void* ctx, tSirNanEvent* msg)
728{
729 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
730 struct sk_buff *vendor_event;
731 int status;
732 tSirNanEvent *data;
733
734 ENTER();
735 if (NULL == msg)
736 {
737 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
738 FL(" msg received here is null"));
739 return;
740 }
741 data = msg;
742
743 status = wlan_hdd_validate_context(pHddCtx);
744
745 if (0 != status)
746 {
747 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
748 FL("HDD context is not valid"));
749 return;
750 }
751
752 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
753 data->event_data_len +
754 NLMSG_HDRLEN,
755 QCA_NL80211_VENDOR_SUBCMD_NAN_INDEX,
756 GFP_KERNEL);
757
758 if (!vendor_event)
759 {
760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
761 FL("cfg80211_vendor_event_alloc failed"));
762 return;
763 }
764 if (nla_put(vendor_event, QCA_WLAN_VENDOR_ATTR_NAN,
765 data->event_data_len, data->event_data))
766 {
767 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
768 FL("QCA_WLAN_VENDOR_ATTR_NAN put fail"));
769 kfree_skb(vendor_event);
770 return;
771 }
772 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
773 EXIT();
774}
775
776/*
777 * FUNCTION: wlan_hdd_cfg80211_nan_init
778 * This function is called to register the callback to sme layer
779 */
780inline void wlan_hdd_cfg80211_nan_init(hdd_context_t *pHddCtx)
781{
782 sme_NanRegisterCallback(pHddCtx->hHal, wlan_hdd_cfg80211_nan_callback);
783}
784
785
Sunil Duttc69bccb2014-05-26 21:30:20 +0530786#ifdef WLAN_FEATURE_LINK_LAYER_STATS
787
788static v_BOOL_t put_wifi_rate_stat( tpSirWifiRateStat stats,
789 struct sk_buff *vendor_event)
790{
791 if (nla_put_u8(vendor_event,
792 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_PREAMBLE,
793 stats->rate.preamble) ||
794 nla_put_u8(vendor_event,
795 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_NSS,
796 stats->rate.nss) ||
797 nla_put_u8(vendor_event,
798 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BW,
799 stats->rate.bw) ||
800 nla_put_u8(vendor_event,
801 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MCS_INDEX,
802 stats->rate.rateMcsIdx) ||
803 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_BIT_RATE,
804 stats->rate.bitrate ) ||
805 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_TX_MPDU,
806 stats->txMpdu ) ||
807 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RX_MPDU,
808 stats->rxMpdu ) ||
809 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_MPDU_LOST,
810 stats->mpduLost ) ||
811 nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES,
812 stats->retries) ||
813 nla_put_u32(vendor_event,
814 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_SHORT,
815 stats->retriesShort ) ||
816 nla_put_u32(vendor_event,
817 QCA_WLAN_VENDOR_ATTR_LL_STATS_RATE_RETRIES_LONG,
818 stats->retriesLong))
819 {
820 hddLog(VOS_TRACE_LEVEL_ERROR,
821 FL("QCA_WLAN_VENDOR_ATTR put fail"));
822 return FALSE;
823 }
824 return TRUE;
825}
826
827static v_BOOL_t put_wifi_peer_info( tpSirWifiPeerInfo stats,
828 struct sk_buff *vendor_event)
829{
830 u32 i = 0;
831 struct nlattr *rateInfo;
832 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_TYPE,
833 stats->type) ||
834 nla_put(vendor_event,
835 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_MAC_ADDRESS,
836 VOS_MAC_ADDR_SIZE, &stats->peerMacAddress[0]) ||
837 nla_put_u32(vendor_event,
838 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_CAPABILITIES,
839 stats->capabilities) ||
840 nla_put_u32(vendor_event,
841 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_NUM_RATES,
842 stats->numRate))
843 {
844 hddLog(VOS_TRACE_LEVEL_ERROR,
845 FL("QCA_WLAN_VENDOR_ATTR put fail"));
846 goto error;
847 }
848
849 rateInfo = nla_nest_start(vendor_event,
850 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO_RATE_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530851 if(!rateInfo)
852 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530853 for (i = 0; i < stats->numRate; i++)
854 {
855 struct nlattr *rates;
856 tpSirWifiRateStat pRateStats = (tpSirWifiRateStat )((uint8 *)
857 stats->rateStats +
858 (i * sizeof(tSirWifiRateStat)));
859 rates = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +0530860 if(!rates)
861 return FALSE;
Sunil Duttc69bccb2014-05-26 21:30:20 +0530862
863 if (FALSE == put_wifi_rate_stat(pRateStats, vendor_event))
864 {
865 hddLog(VOS_TRACE_LEVEL_ERROR,
866 FL("QCA_WLAN_VENDOR_ATTR put fail"));
867 return FALSE;
868 }
869 nla_nest_end(vendor_event, rates);
870 }
871 nla_nest_end(vendor_event, rateInfo);
872
873 return TRUE;
874error:
875 return FALSE;
876}
877
878static v_BOOL_t put_wifi_wmm_ac_stat( tpSirWifiWmmAcStat stats,
879 struct sk_buff *vendor_event)
880{
881 if (nla_put_u32(vendor_event, QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_AC,
882 stats->ac ) ||
883 nla_put_u32(vendor_event,
884 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MPDU,
885 stats->txMpdu ) ||
886 nla_put_u32(vendor_event,
887 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MPDU,
888 stats->rxMpdu ) ||
889 nla_put_u32(vendor_event,
890 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_MCAST,
891 stats->txMcast ) ||
892 nla_put_u32(vendor_event,
893 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_MCAST,
894 stats->rxMcast ) ||
895 nla_put_u32(vendor_event,
896 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RX_AMPDU,
897 stats->rxAmpdu ) ||
898 nla_put_u32(vendor_event,
899 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_TX_AMPDU,
900 stats->txAmpdu ) ||
901 nla_put_u32(vendor_event,
902 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_MPDU_LOST,
903 stats->mpduLost )||
904 nla_put_u32(vendor_event,
905 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES,
906 stats->retries ) ||
907 nla_put_u32(vendor_event,
908 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_SHORT,
909 stats->retriesShort ) ||
910 nla_put_u32(vendor_event,
911 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_RETRIES_LONG,
912 stats->retriesLong ) ||
913 nla_put_u32(vendor_event,
914 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MIN,
915 stats->contentionTimeMin ) ||
916 nla_put_u32(vendor_event,
917 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_MAX,
918 stats->contentionTimeMax ) ||
919 nla_put_u32(vendor_event,
920 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_TIME_AVG,
921 stats->contentionTimeAvg ) ||
922 nla_put_u32(vendor_event,
923 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_AC_CONTENTION_NUM_SAMPLES,
924 stats->contentionNumSamples ))
925 {
926 hddLog(VOS_TRACE_LEVEL_ERROR,
927 FL("QCA_WLAN_VENDOR_ATTR put fail") );
928 return FALSE;
929 }
930 return TRUE;
931}
932
933static v_BOOL_t put_wifi_interface_info(tpSirWifiInterfaceInfo stats,
934 struct sk_buff *vendor_event)
935{
Dino Myclec8f3f332014-07-21 16:48:27 +0530936 if (nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530937 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MODE, stats->mode ) ||
938 nla_put(vendor_event,
939 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_MAC_ADDR,
940 VOS_MAC_ADDR_SIZE, stats->macAddr) ||
941 nla_put_u32(vendor_event,
942 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_STATE,
943 stats->state ) ||
944 nla_put_u32(vendor_event,
945 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_ROAMING,
946 stats->roaming ) ||
947 nla_put_u32(vendor_event,
948 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_CAPABILITIES,
949 stats->capabilities ) ||
950 nla_put(vendor_event,
951 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_SSID,
952 strlen(stats->ssid), stats->ssid) ||
953 nla_put(vendor_event,
954 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_BSSID,
955 WNI_CFG_BSSID_LEN, stats->bssid) ||
956 nla_put(vendor_event,
957 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_AP_COUNTRY_STR,
958 WNI_CFG_COUNTRY_CODE_LEN, stats->apCountryStr) ||
959 nla_put(vendor_event,
960 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_INFO_COUNTRY_STR,
961 WNI_CFG_COUNTRY_CODE_LEN, stats->countryStr)
962 )
963 {
964 hddLog(VOS_TRACE_LEVEL_ERROR,
965 FL("QCA_WLAN_VENDOR_ATTR put fail") );
966 return FALSE;
967 }
968 return TRUE;
969}
970
Dino Mycle3b9536d2014-07-09 22:05:24 +0530971static v_BOOL_t put_wifi_iface_stats(hdd_adapter_t *pAdapter,
972 tpSirWifiIfaceStat pWifiIfaceStat,
Sunil Duttc69bccb2014-05-26 21:30:20 +0530973 struct sk_buff *vendor_event)
974{
975 int i = 0;
976 struct nlattr *wmmInfo;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530977 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
978 WLANTL_InterfaceStatsType *pWifiIfaceStatTL = NULL;
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530979 tSirWifiWmmAcStat accessclassStats;
Dino Mycle3b9536d2014-07-09 22:05:24 +0530980
Sunil Duttc69bccb2014-05-26 21:30:20 +0530981 if (FALSE == put_wifi_interface_info(
982 &pWifiIfaceStat->info,
983 vendor_event))
984 {
985 hddLog(VOS_TRACE_LEVEL_ERROR,
986 FL("QCA_WLAN_VENDOR_ATTR put fail") );
987 return FALSE;
988
989 }
Dino Mycle3b9536d2014-07-09 22:05:24 +0530990 pWifiIfaceStatTL = (WLANTL_InterfaceStatsType *)
991 vos_mem_malloc(sizeof(WLANTL_InterfaceStatsType));
992 if (NULL == pWifiIfaceStatTL)
993 {
994 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
995 return FALSE;
996 }
997
Srinivas Dasaria8a304f2014-11-15 16:13:37 +0530998 accessclassStats = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK];
999 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK] =
1000 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE];
1001 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE] = accessclassStats;
1002
1003 accessclassStats.ac = pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac;
1004 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].ac =
1005 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac;
1006 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].ac = accessclassStats.ac;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301007
1008 if ( pWifiIfaceStat->info.state == WIFI_ASSOCIATED)
1009 {
1010 if (VOS_STATUS_SUCCESS ==
1011 WLANTL_CollectInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1012 pHddStaCtx->conn_info.staId[0], pWifiIfaceStatTL))
1013 {
1014 /* mgmtRx, MgmtActionRx, rxMcast, rxMpdu, rxAmpdu, rssiData are
1015 * obtained from TL structure
1016 */
1017
1018 pWifiIfaceStat->mgmtRx = pWifiIfaceStat->beaconRx +
1019 pWifiIfaceStatTL->mgmtRx;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301020 pWifiIfaceStat->rssiData = pWifiIfaceStatTL->rssiData;
1021
Srinivas Dasari98947432014-11-07 19:41:24 +05301022 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMcast
1023 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMcast;
1024 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMcast
1025 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMcast;
1026 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMcast
1027 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMcast;
1028 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMcast
1029 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMcast;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301030
Srinivas Dasari98947432014-11-07 19:41:24 +05301031 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxMpdu
1032 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxMpdu;
1033 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxMpdu
1034 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxMpdu;
1035 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxMpdu
1036 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxMpdu;
1037 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxMpdu
1038 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxMpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301039
Srinivas Dasari98947432014-11-07 19:41:24 +05301040 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].rxAmpdu
1041 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VO].rxAmpdu;
1042 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].rxAmpdu
1043 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_VI].rxAmpdu;
1044 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].rxAmpdu
1045 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BE].rxAmpdu;
1046 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].rxAmpdu
1047 = pWifiIfaceStatTL->accessCategoryStats[WLANTL_AC_BK].rxAmpdu;
Dino Mycle3b9536d2014-07-09 22:05:24 +05301048 }
1049 else
1050 {
1051 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in getting stats from TL"));
1052 }
1053
Dino Mycle3b9536d2014-07-09 22:05:24 +05301054 pWifiIfaceStat->AccessclassStats[WIFI_AC_VO].txMcast =
1055 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO];
1056 pWifiIfaceStat->AccessclassStats[WIFI_AC_VI].txMcast =
1057 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI];
1058 pWifiIfaceStat->AccessclassStats[WIFI_AC_BE].txMcast =
1059 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE];
1060 pWifiIfaceStat->AccessclassStats[WIFI_AC_BK].txMcast =
1061 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK];
1062 }
1063 else
1064 {
1065 hddLog(VOS_TRACE_LEVEL_INFO, FL("Interface not Associated"));
1066 }
1067
1068
Sunil Duttc69bccb2014-05-26 21:30:20 +05301069
1070 if (nla_put_u32(vendor_event,
1071 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_BEACON_RX,
1072 pWifiIfaceStat->beaconRx) ||
1073 nla_put_u32(vendor_event,
1074 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_RX,
1075 pWifiIfaceStat->mgmtRx) ||
1076 nla_put_u32(vendor_event,
1077 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_RX,
1078 pWifiIfaceStat->mgmtActionRx) ||
1079 nla_put_u32(vendor_event,
1080 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_MGMT_ACTION_TX,
1081 pWifiIfaceStat->mgmtActionTx) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301082 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301083 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_MGMT,
1084 pWifiIfaceStat->rssiMgmt) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301085 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301086 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_DATA,
1087 pWifiIfaceStat->rssiData) ||
Dino Mycle3b9536d2014-07-09 22:05:24 +05301088 nla_put_s32(vendor_event,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301089 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_RSSI_ACK,
1090 pWifiIfaceStat->rssiAck))
1091 {
1092 hddLog(VOS_TRACE_LEVEL_ERROR,
1093 FL("QCA_WLAN_VENDOR_ATTR put fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301094 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301095 return FALSE;
1096 }
1097
1098 wmmInfo = nla_nest_start(vendor_event,
1099 QCA_WLAN_VENDOR_ATTR_LL_STATS_WMM_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301100 if(!wmmInfo)
1101 {
1102 vos_mem_free(pWifiIfaceStatTL);
1103 return FALSE;
1104 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301105 for (i = 0; i < WIFI_AC_MAX; i++)
1106 {
1107 struct nlattr *wmmStats;
1108 wmmStats = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301109 if(!wmmStats)
1110 {
1111 vos_mem_free(pWifiIfaceStatTL);
1112 return FALSE;
1113 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301114 if (FALSE == put_wifi_wmm_ac_stat(
1115 &pWifiIfaceStat->AccessclassStats[i],
1116 vendor_event))
1117 {
1118 hddLog(VOS_TRACE_LEVEL_ERROR,
1119 FL("QCA_WLAN_VENDOR_ATTR put Fail"));
Dino Mycle3b9536d2014-07-09 22:05:24 +05301120 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301121 return FALSE;
1122 }
1123
1124 nla_nest_end(vendor_event, wmmStats);
1125 }
1126 nla_nest_end(vendor_event, wmmInfo);
Dino Mycle3b9536d2014-07-09 22:05:24 +05301127 vos_mem_free(pWifiIfaceStatTL);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301128 return TRUE;
1129}
1130
1131static tSirWifiInterfaceMode
1132 hdd_map_device_to_ll_iface_mode ( int deviceMode )
1133{
1134 switch (deviceMode)
1135 {
1136 case WLAN_HDD_INFRA_STATION:
1137 return WIFI_INTERFACE_STA;
1138 case WLAN_HDD_SOFTAP:
1139 return WIFI_INTERFACE_SOFTAP;
1140 case WLAN_HDD_P2P_CLIENT:
1141 return WIFI_INTERFACE_P2P_CLIENT;
1142 case WLAN_HDD_P2P_GO:
1143 return WIFI_INTERFACE_P2P_GO;
1144 case WLAN_HDD_IBSS:
1145 return WIFI_INTERFACE_IBSS;
1146 default:
Dino Myclec8f3f332014-07-21 16:48:27 +05301147 return WIFI_INTERFACE_UNKNOWN;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301148 }
1149}
1150
1151static v_BOOL_t hdd_get_interface_info(hdd_adapter_t *pAdapter,
1152 tpSirWifiInterfaceInfo pInfo)
1153{
1154 v_U8_t *staMac = NULL;
1155 hdd_station_ctx_t *pHddStaCtx;
1156 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
1157 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1158
1159 pInfo->mode = hdd_map_device_to_ll_iface_mode(pAdapter->device_mode);
1160
1161 vos_mem_copy(pInfo->macAddr,
1162 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
1163
1164 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1165 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
1166 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)))
1167 {
1168 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1169 if (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)
1170 {
1171 pInfo->state = WIFI_DISCONNECTED;
1172 }
1173 if (eConnectionState_Connecting == pHddStaCtx->conn_info.connState)
1174 {
1175 hddLog(VOS_TRACE_LEVEL_ERROR,
1176 "%s: Session ID %d, Connection is in progress", __func__,
1177 pAdapter->sessionId);
1178 pInfo->state = WIFI_ASSOCIATING;
1179 }
1180 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
1181 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
1182 {
1183 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
1184 hddLog(VOS_TRACE_LEVEL_ERROR,
1185 "%s: client " MAC_ADDRESS_STR
1186 " is in the middle of WPS/EAPOL exchange.", __func__,
1187 MAC_ADDR_ARRAY(staMac));
1188 pInfo->state = WIFI_AUTHENTICATING;
1189 }
1190 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
1191 {
1192 pInfo->state = WIFI_ASSOCIATED;
1193 vos_mem_copy(pInfo->bssid,
1194 &pHddStaCtx->conn_info.bssId, WNI_CFG_BSSID_LEN);
1195 vos_mem_copy(pInfo->ssid,
1196 pHddStaCtx->conn_info.SSID.SSID.ssId,
1197 pHddStaCtx->conn_info.SSID.SSID.length);
1198 //NULL Terminate the string.
1199 pInfo->ssid[pHddStaCtx->conn_info.SSID.SSID.length] = 0;
1200 }
1201 }
1202 vos_mem_copy(pInfo->countryStr,
1203 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1204
1205 vos_mem_copy(pInfo->apCountryStr,
1206 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
1207
1208 return TRUE;
1209}
1210
1211/*
1212 * hdd_link_layer_process_peer_stats () - This function is called after
1213 * receiving Link Layer Peer statistics from FW.This function converts
1214 * the firmware data to the NL data and sends the same to the kernel/upper
1215 * layers.
1216 */
1217static v_VOID_t hdd_link_layer_process_peer_stats(hdd_adapter_t *pAdapter,
1218 v_VOID_t *pData)
1219{
1220 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1221 tpSirWifiRateStat pWifiRateStat;
1222 tpSirWifiPeerStat pWifiPeerStat;
1223 tpSirWifiPeerInfo pWifiPeerInfo;
1224 struct nlattr *peerInfo;
1225 struct sk_buff *vendor_event;
1226 int status, i;
1227
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301228 ENTER();
1229
Sunil Duttc69bccb2014-05-26 21:30:20 +05301230 status = wlan_hdd_validate_context(pHddCtx);
1231 if (0 != status)
1232 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301233 return;
1234 }
1235
1236 pWifiPeerStat = (tpSirWifiPeerStat) pData;
1237
1238 hddLog(VOS_TRACE_LEVEL_INFO,
1239 "LL_STATS_PEER_ALL : numPeers %u",
1240 pWifiPeerStat->numPeers);
1241 {
1242 for (i = 0; i < pWifiPeerStat->numPeers; i++)
1243 {
1244 pWifiPeerInfo = (tpSirWifiPeerInfo)
1245 ((uint8 *)pWifiPeerStat->peerInfo +
1246 ( i * sizeof(tSirWifiPeerInfo)));
1247
Dasari Srinivas1be0c4e2014-10-19 13:03:41 +05301248 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) {
1249 pWifiPeerInfo->type = WIFI_PEER_AP;
1250 }
1251 if (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) {
1252 pWifiPeerInfo->type = WIFI_PEER_P2P_GO;
1253 }
1254
Sunil Duttc69bccb2014-05-26 21:30:20 +05301255 hddLog(VOS_TRACE_LEVEL_INFO,
1256 " %d) LL_STATS Channel Stats "
1257 " Peer Type %u "
1258 " peerMacAddress %pM "
1259 " capabilities 0x%x "
1260 " numRate %u ",
1261 i,
1262 pWifiPeerInfo->type,
1263 pWifiPeerInfo->peerMacAddress,
1264 pWifiPeerInfo->capabilities,
1265 pWifiPeerInfo->numRate);
1266 {
1267 int j;
1268 for (j = 0; j < pWifiPeerInfo->numRate; j++)
1269 {
1270 pWifiRateStat = (tpSirWifiRateStat)
1271 ((tANI_U8 *) pWifiPeerInfo->rateStats +
1272 ( j * sizeof(tSirWifiRateStat)));
1273
1274 hddLog(VOS_TRACE_LEVEL_INFO,
1275 " peer Rate Stats "
1276 " preamble %u "
1277 " nss %u "
1278 " bw %u "
1279 " rateMcsIdx %u "
1280 " reserved %u "
1281 " bitrate %u "
1282 " txMpdu %u "
1283 " rxMpdu %u "
1284 " mpduLost %u "
1285 " retries %u "
1286 " retriesShort %u "
1287 " retriesLong %u",
1288 pWifiRateStat->rate.preamble,
1289 pWifiRateStat->rate.nss,
1290 pWifiRateStat->rate.bw,
1291 pWifiRateStat->rate.rateMcsIdx,
1292 pWifiRateStat->rate.reserved,
1293 pWifiRateStat->rate.bitrate,
1294 pWifiRateStat->txMpdu,
1295 pWifiRateStat->rxMpdu,
1296 pWifiRateStat->mpduLost,
1297 pWifiRateStat->retries,
1298 pWifiRateStat->retriesShort,
1299 pWifiRateStat->retriesLong);
1300 }
1301 }
1302 }
1303 }
1304
1305 /*
1306 * Allocate a size of 4096 for the peer stats comprising
1307 * each of size = sizeof (tSirWifiPeerInfo) + numRate *
1308 * sizeof (tSirWifiRateStat).Each field is put with an
1309 * NL attribute.The size of 4096 is considered assuming
1310 * that number of rates shall not exceed beyond 50 with
1311 * the sizeof (tSirWifiRateStat) being 32.
1312 */
1313 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1314 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1315 QCA_NL80211_VENDOR_SUBCMD_LL_PEER_INFO_STATS_INDEX,
1316 GFP_KERNEL);
1317 if (!vendor_event)
1318 {
1319 hddLog(VOS_TRACE_LEVEL_ERROR,
1320 "%s: cfg80211_vendor_event_alloc failed",
1321 __func__);
1322 return;
1323 }
1324 if (nla_put_u32(vendor_event,
1325 QCA_WLAN_VENDOR_ATTR_LL_STATS_IFACE_NUM_PEERS,
1326 pWifiPeerStat->numPeers))
1327 {
1328 hddLog(VOS_TRACE_LEVEL_ERROR,
1329 "%s: QCA_WLAN_VENDOR_ATTR put fail", __func__);
1330 kfree_skb(vendor_event);
1331 return;
1332 }
1333
1334 peerInfo = nla_nest_start(vendor_event,
1335 QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301336 if(!peerInfo)
1337 {
1338 hddLog(VOS_TRACE_LEVEL_ERROR,
1339 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_PEER_INFO put fail",
1340 __func__);
1341 kfree_skb(vendor_event);
1342 return;
1343 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301344
1345 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1346 pWifiPeerStat->peerInfo);
1347
1348 for (i = 1; i <= pWifiPeerStat->numPeers; i++)
1349 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301350 int numRate = pWifiPeerInfo->numRate;
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301351 struct nlattr *peers = nla_nest_start(vendor_event, i);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301352
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301353 if(!peers)
1354 {
1355 hddLog(VOS_TRACE_LEVEL_ERROR,
1356 "%s: peer stats put fail",
1357 __func__);
1358 kfree_skb(vendor_event);
1359 return;
1360 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301361 if (FALSE == put_wifi_peer_info(
1362 pWifiPeerInfo, vendor_event))
1363 {
1364 hddLog(VOS_TRACE_LEVEL_ERROR,
1365 "%s: put_wifi_peer_info put fail", __func__);
1366 kfree_skb(vendor_event);
1367 return;
1368 }
1369
1370 pWifiPeerInfo = (tpSirWifiPeerInfo) ((uint8 *)
1371 pWifiPeerStat->peerInfo +
1372 (i * sizeof(tSirWifiPeerInfo)) +
1373 (numRate * sizeof (tSirWifiRateStat)));
1374 nla_nest_end(vendor_event, peers);
1375 }
1376 nla_nest_end(vendor_event, peerInfo);
1377 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301378
1379 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301380}
1381
1382/*
1383 * hdd_link_layer_process_iface_stats () - This function is called after
1384 * receiving Link Layer Interface statistics from FW.This function converts
1385 * the firmware data to the NL data and sends the same to the kernel/upper
1386 * layers.
1387 */
1388static v_VOID_t hdd_link_layer_process_iface_stats(hdd_adapter_t *pAdapter,
1389 v_VOID_t *pData)
1390{
1391 tpSirWifiIfaceStat pWifiIfaceStat;
1392 struct sk_buff *vendor_event;
1393 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1394 int status;
1395
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301396 ENTER();
1397
Sunil Duttc69bccb2014-05-26 21:30:20 +05301398 status = wlan_hdd_validate_context(pHddCtx);
1399 if (0 != status)
1400 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301401 return;
1402 }
1403 /*
1404 * Allocate a size of 4096 for the interface stats comprising
1405 * sizeof (tpSirWifiIfaceStat).The size of 4096 is considered
1406 * assuming that all these fit with in the limit.Please take
1407 * a call on the limit based on the data requirements on
1408 * interface statistics.
1409 */
1410 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1411 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
1412 QCA_NL80211_VENDOR_SUBCMD_LL_IFACE_STATS_INDEX,
1413 GFP_KERNEL);
1414 if (!vendor_event)
1415 {
1416 hddLog(VOS_TRACE_LEVEL_ERROR,
1417 FL("cfg80211_vendor_event_alloc failed") );
1418 return;
1419 }
1420
1421 pWifiIfaceStat = (tpSirWifiIfaceStat) pData;
1422
Dino Mycle3b9536d2014-07-09 22:05:24 +05301423
1424 if (FALSE == hdd_get_interface_info( pAdapter,
1425 &pWifiIfaceStat->info))
1426 {
1427 hddLog(VOS_TRACE_LEVEL_ERROR,
1428 FL("hdd_get_interface_info get fail") );
1429 kfree_skb(vendor_event);
1430 return;
1431 }
1432
1433 if (FALSE == put_wifi_iface_stats( pAdapter, pWifiIfaceStat,
1434 vendor_event))
1435 {
1436 hddLog(VOS_TRACE_LEVEL_ERROR,
1437 FL("put_wifi_iface_stats fail") );
1438 kfree_skb(vendor_event);
1439 return;
1440 }
1441
Sunil Duttc69bccb2014-05-26 21:30:20 +05301442 hddLog(VOS_TRACE_LEVEL_INFO,
1443 "WMI_LINK_STATS_IFACE Data");
1444
1445 hddLog(VOS_TRACE_LEVEL_INFO,
1446 "LL_STATS_IFACE: "
1447 " Mode %u "
1448 " MAC %pM "
1449 " State %u "
1450 " Roaming %u "
1451 " capabilities 0x%x "
1452 " SSID %s "
1453 " BSSID %pM",
1454 pWifiIfaceStat->info.mode,
1455 pWifiIfaceStat->info.macAddr,
1456 pWifiIfaceStat->info.state,
1457 pWifiIfaceStat->info.roaming,
1458 pWifiIfaceStat->info.capabilities,
1459 pWifiIfaceStat->info.ssid,
1460 pWifiIfaceStat->info.bssid);
1461
1462 hddLog(VOS_TRACE_LEVEL_INFO,
1463 " AP country str: %c%c%c",
1464 pWifiIfaceStat->info.apCountryStr[0],
1465 pWifiIfaceStat->info.apCountryStr[1],
1466 pWifiIfaceStat->info.apCountryStr[2]);
1467
1468
1469 hddLog(VOS_TRACE_LEVEL_INFO,
1470 " Country Str Association: %c%c%c",
1471 pWifiIfaceStat->info.countryStr[0],
1472 pWifiIfaceStat->info.countryStr[1],
1473 pWifiIfaceStat->info.countryStr[2]);
1474
1475 hddLog(VOS_TRACE_LEVEL_INFO,
1476 " beaconRx %u "
1477 " mgmtRx %u "
1478 " mgmtActionRx %u "
1479 " mgmtActionTx %u "
Dino Mycle3b9536d2014-07-09 22:05:24 +05301480 " rssiMgmt %d "
1481 " rssiData %d "
1482 " rssiAck %d",
Sunil Duttc69bccb2014-05-26 21:30:20 +05301483 pWifiIfaceStat->beaconRx,
1484 pWifiIfaceStat->mgmtRx,
1485 pWifiIfaceStat->mgmtActionRx,
1486 pWifiIfaceStat->mgmtActionTx,
1487 pWifiIfaceStat->rssiMgmt,
1488 pWifiIfaceStat->rssiData,
1489 pWifiIfaceStat->rssiAck );
1490
1491
1492 {
1493 int i;
1494 for (i = 0 ; i < WIFI_AC_MAX; i ++)
1495 {
1496 hddLog(VOS_TRACE_LEVEL_INFO,
1497
1498 " %d) LL_STATS IFACE: "
1499 " ac: %u txMpdu: %u "
1500 " rxMpdu: %u txMcast: %u "
1501 " rxMcast: %u rxAmpdu: %u "
1502 " txAmpdu: %u mpduLost: %u "
1503 " retries: %u retriesShort: %u "
1504 " retriesLong: %u contentionTimeMin: %u "
1505 " contentionTimeMax: %u contentionTimeAvg: %u "
1506 " contentionNumSamples: %u",
1507 i,
1508 pWifiIfaceStat->AccessclassStats[i].ac,
1509 pWifiIfaceStat->AccessclassStats[i].txMpdu,
1510 pWifiIfaceStat->AccessclassStats[i].rxMpdu,
1511 pWifiIfaceStat->AccessclassStats[i].txMcast,
1512 pWifiIfaceStat->AccessclassStats[i].rxMcast,
1513 pWifiIfaceStat->AccessclassStats[i].rxAmpdu,
1514 pWifiIfaceStat->AccessclassStats[i].txAmpdu,
1515 pWifiIfaceStat->AccessclassStats[i].mpduLost,
1516 pWifiIfaceStat->AccessclassStats[i].retries,
1517 pWifiIfaceStat->
1518 AccessclassStats[i].retriesShort,
1519 pWifiIfaceStat->AccessclassStats[i].retriesLong,
1520 pWifiIfaceStat->
1521 AccessclassStats[i].contentionTimeMin,
1522 pWifiIfaceStat->
1523 AccessclassStats[i].contentionTimeMax,
1524 pWifiIfaceStat->
1525 AccessclassStats[i].contentionTimeAvg,
1526 pWifiIfaceStat->
1527 AccessclassStats[i].contentionNumSamples);
1528
1529 }
1530 }
1531
Sunil Duttc69bccb2014-05-26 21:30:20 +05301532 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301533
1534 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301535}
1536
1537/*
1538 * hdd_link_layer_process_radio_stats () - This function is called after
1539 * receiving Link Layer Radio statistics from FW.This function converts
1540 * the firmware data to the NL data and sends the same to the kernel/upper
1541 * layers.
1542 */
1543static v_VOID_t hdd_link_layer_process_radio_stats(hdd_adapter_t *pAdapter,
1544 v_VOID_t *pData)
1545{
1546 int status, i;
1547 tpSirWifiRadioStat pWifiRadioStat;
1548 tpSirWifiChannelStats pWifiChannelStats;
1549 struct sk_buff *vendor_event;
1550 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1551 struct nlattr *chList;
1552
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301553 ENTER();
1554
Sunil Duttc69bccb2014-05-26 21:30:20 +05301555 status = wlan_hdd_validate_context(pHddCtx);
1556 if (0 != status)
1557 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301558 return;
1559 }
1560 pWifiRadioStat = (tpSirWifiRadioStat) pData;
1561
1562 hddLog(VOS_TRACE_LEVEL_INFO,
1563 "LL_STATS_RADIO"
1564 " radio is %d onTime is %u "
1565 " txTime is %u rxTime is %u "
1566 " onTimeScan is %u onTimeNbd is %u "
Dino Mycle6fb96c12014-06-10 11:52:40 +05301567 " onTimeEXTScan is %u onTimeRoamScan is %u "
Sunil Duttc69bccb2014-05-26 21:30:20 +05301568 " onTimePnoScan is %u onTimeHs20 is %u "
1569 " numChannels is %u",
1570 pWifiRadioStat->radio, pWifiRadioStat->onTime,
1571 pWifiRadioStat->txTime, pWifiRadioStat->rxTime,
1572 pWifiRadioStat->onTimeScan, pWifiRadioStat->onTimeNbd,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301573 pWifiRadioStat->onTimeEXTScan,
Sunil Duttc69bccb2014-05-26 21:30:20 +05301574 pWifiRadioStat->onTimeRoamScan,
1575 pWifiRadioStat->onTimePnoScan,
1576 pWifiRadioStat->onTimeHs20,
1577 pWifiRadioStat->numChannels);
1578 /*
1579 * Allocate a size of 4096 for the Radio stats comprising
1580 * sizeof (tSirWifiRadioStat) + numChannels * sizeof
1581 * (tSirWifiChannelStats).Each channel data is put with an
1582 * NL attribute.The size of 4096 is considered assuming that
1583 * number of channels shall not exceed beyond 60 with the
1584 * sizeof (tSirWifiChannelStats) being 24 bytes.
1585 */
1586
1587 vendor_event = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
1588 LL_STATS_EVENT_BUF_SIZE + NLMSG_HDRLEN ,
1589 QCA_NL80211_VENDOR_SUBCMD_LL_RADIO_STATS_INDEX,
1590 GFP_KERNEL);
1591
1592 if (!vendor_event)
1593 {
1594 hddLog(VOS_TRACE_LEVEL_ERROR,
1595 FL("cfg80211_vendor_event_alloc failed") );
1596 return;
1597 }
1598
1599 if (nla_put_u32(vendor_event,
1600 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
1601 pWifiRadioStat->radio) ||
1602 nla_put_u32(vendor_event,
1603 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME,
1604 pWifiRadioStat->onTime) ||
1605 nla_put_u32(vendor_event,
1606 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_TX_TIME,
1607 pWifiRadioStat->txTime) ||
1608 nla_put_u32(vendor_event,
1609 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_RX_TIME,
1610 pWifiRadioStat->rxTime) ||
1611 nla_put_u32(vendor_event,
1612 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_SCAN,
1613 pWifiRadioStat->onTimeScan) ||
1614 nla_put_u32(vendor_event,
1615 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_NBD,
1616 pWifiRadioStat->onTimeNbd) ||
1617 nla_put_u32(vendor_event,
Dino Mycle6fb96c12014-06-10 11:52:40 +05301618 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_EXTSCAN,
1619 pWifiRadioStat->onTimeEXTScan)||
Sunil Duttc69bccb2014-05-26 21:30:20 +05301620 nla_put_u32(vendor_event,
1621 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_ROAM_SCAN,
1622 pWifiRadioStat->onTimeRoamScan) ||
1623 nla_put_u32(vendor_event,
1624 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_PNO_SCAN,
1625 pWifiRadioStat->onTimePnoScan) ||
1626 nla_put_u32(vendor_event,
1627 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ON_TIME_HS20,
1628 pWifiRadioStat->onTimeHs20) ||
1629 nla_put_u32(vendor_event,
1630 QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_NUM_CHANNELS,
1631 pWifiRadioStat->numChannels))
1632 {
1633 hddLog(VOS_TRACE_LEVEL_ERROR,
1634 FL("QCA_WLAN_VENDOR_ATTR put fail"));
1635 kfree_skb(vendor_event);
1636 return ;
1637 }
1638
1639 chList = nla_nest_start(vendor_event,
1640 QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301641 if(!chList)
1642 {
1643 hddLog(VOS_TRACE_LEVEL_ERROR,
1644 "%s: QCA_WLAN_VENDOR_ATTR_LL_STATS_CH_INFO put fail",
1645 __func__);
1646 kfree_skb(vendor_event);
1647 return;
1648 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301649 for (i = 0; i < pWifiRadioStat->numChannels; i++)
1650 {
1651 struct nlattr *chInfo;
1652
1653 pWifiChannelStats = (tpSirWifiChannelStats) ((uint8*)
1654 pWifiRadioStat->channels +
1655 (i * sizeof(tSirWifiChannelStats)));
1656
1657 hddLog(VOS_TRACE_LEVEL_INFO,
1658 " %d) Channel Info"
1659 " width is %u "
1660 " CenterFreq %u "
1661 " CenterFreq0 %u "
1662 " CenterFreq1 %u "
1663 " onTime %u "
1664 " ccaBusyTime %u",
1665 i,
1666 pWifiChannelStats->channel.width,
1667 pWifiChannelStats->channel.centerFreq,
1668 pWifiChannelStats->channel.centerFreq0,
1669 pWifiChannelStats->channel.centerFreq1,
1670 pWifiChannelStats->onTime,
1671 pWifiChannelStats->ccaBusyTime);
1672
1673
1674 chInfo = nla_nest_start(vendor_event, i);
Sushant Kaushikee1f55e2015-01-22 11:27:01 +05301675 if(!chInfo)
1676 {
1677 hddLog(VOS_TRACE_LEVEL_ERROR,
1678 "%s: failed to put chInfo",
1679 __func__);
1680 kfree_skb(vendor_event);
1681 return;
1682 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301683
1684 if (nla_put_u32(vendor_event,
1685 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_WIDTH,
1686 pWifiChannelStats->channel.width) ||
1687 nla_put_u32(vendor_event,
1688 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
1689 pWifiChannelStats->channel.centerFreq) ||
1690 nla_put_u32(vendor_event,
1691 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ0,
1692 pWifiChannelStats->channel.centerFreq0) ||
1693 nla_put_u32(vendor_event,
1694 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ1,
1695 pWifiChannelStats->channel.centerFreq1) ||
1696 nla_put_u32(vendor_event,
1697 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_ON_TIME,
1698 pWifiChannelStats->onTime) ||
1699 nla_put_u32(vendor_event,
1700 QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_CCA_BUSY_TIME,
1701 pWifiChannelStats->ccaBusyTime))
1702 {
1703 hddLog(VOS_TRACE_LEVEL_ERROR,
1704 FL("cfg80211_vendor_event_alloc failed") );
1705 kfree_skb(vendor_event);
1706 return ;
1707 }
1708 nla_nest_end(vendor_event, chInfo);
1709 }
1710 nla_nest_end(vendor_event, chList);
1711
1712 cfg80211_vendor_event(vendor_event, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301713
1714 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301715 return;
1716}
1717
1718/*
1719 * hdd_link_layer_stats_ind_callback () - This function is called after
1720 * receiving Link Layer indications from FW.This callback converts the firmware
1721 * data to the NL data and send the same to the kernel/upper layers.
1722 */
1723static void hdd_link_layer_stats_ind_callback ( void *pCtx,
1724 int indType,
Dino Mycled3d50022014-07-07 12:58:25 +05301725 void *pRsp, u8 *macAddr)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301726{
Dino Mycled3d50022014-07-07 12:58:25 +05301727 hdd_context_t *pHddCtx = (hdd_context_t *)pCtx;
1728 hdd_adapter_t *pAdapter = NULL;
1729 tpSirLLStatsResults linkLayerStatsResults = (tpSirLLStatsResults)pRsp;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301730 int status;
1731
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301732 ENTER();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301733
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301734 status = wlan_hdd_validate_context(pHddCtx);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301735 if (0 != status)
1736 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301737 return;
1738 }
1739
Dino Mycled3d50022014-07-07 12:58:25 +05301740 pAdapter = hdd_get_adapter_by_macaddr(pHddCtx, macAddr);
1741 if (NULL == pAdapter)
1742 {
1743 hddLog(VOS_TRACE_LEVEL_ERROR,
1744 FL(" MAC address %pM does not exist with host"),
1745 macAddr);
1746 return;
1747 }
1748
Sunil Duttc69bccb2014-05-26 21:30:20 +05301749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301750 "%s: Interface: %s LLStats indType: %d", __func__,
1751 pAdapter->dev->name, indType);
1752
Sunil Duttc69bccb2014-05-26 21:30:20 +05301753 switch (indType)
1754 {
1755 case SIR_HAL_LL_STATS_RESULTS_RSP:
1756 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301757 hddLog(VOS_TRACE_LEVEL_INFO,
1758 FL("RESPONSE SIR_HAL_LL_STATS_RESULTS_RSP") );
1759 hddLog(VOS_TRACE_LEVEL_INFO,
1760 "LL_STATS RESULTS RESPONSE paramID = 0x%x",
1761 linkLayerStatsResults->paramId);
1762 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301763 "LL_STATS RESULTS RESPONSE ifaceId = %u MAC: %pM",
1764 linkLayerStatsResults->ifaceId, macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301765 hddLog(VOS_TRACE_LEVEL_INFO,
1766 "LL_STATS RESULTS RESPONSE respId = %u",
1767 linkLayerStatsResults->respId);
1768 hddLog(VOS_TRACE_LEVEL_INFO,
1769 "LL_STATS RESULTS RESPONSE moreResultToFollow = %u",
1770 linkLayerStatsResults->moreResultToFollow);
1771 hddLog(VOS_TRACE_LEVEL_INFO,
1772 "LL_STATS RESULTS RESPONSE result = %p",
1773 linkLayerStatsResults->result);
1774 if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_RADIO )
1775 {
1776 hdd_link_layer_process_radio_stats(pAdapter,
1777 (v_VOID_t *)linkLayerStatsResults->result);
1778 }
1779 else if ( linkLayerStatsResults->paramId & WMI_LINK_STATS_IFACE )
1780 {
1781 hdd_link_layer_process_iface_stats(pAdapter,
1782 (v_VOID_t *)linkLayerStatsResults->result);
1783 }
1784 else if ( linkLayerStatsResults->paramId &
1785 WMI_LINK_STATS_ALL_PEER )
1786 {
1787 hdd_link_layer_process_peer_stats(pAdapter,
1788 (v_VOID_t *)linkLayerStatsResults->result);
1789 } /* WMI_LINK_STATS_ALL_PEER */
1790 else
1791 {
1792 hddLog(VOS_TRACE_LEVEL_ERROR,
1793 FL("INVALID LL_STATS_NOTIFY RESPONSE ***********"));
1794 }
1795
1796 break;
1797 }
1798 default:
1799 hddLog(VOS_TRACE_LEVEL_ERROR, "invalid event type %d", indType);
1800 break;
1801 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301802
1803 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301804 return;
1805}
1806
1807const struct
1808nla_policy
1809qca_wlan_vendor_ll_set_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX +1] =
1810{
1811 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD] =
1812 { .type = NLA_U32 },
1813 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING] =
1814 { .type = NLA_U32 },
1815};
1816
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301817static int __wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1818 struct wireless_dev *wdev,
1819 const void *data,
1820 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301821{
1822 int status;
1823 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301824 tSirLLStatsSetReq linkLayerStatsSetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301825 struct net_device *dev = wdev->netdev;
1826 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1827 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Srinivas Dasari98947432014-11-07 19:41:24 +05301828 hdd_station_ctx_t *pHddStaCtx;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301829
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301830 ENTER();
1831
Sunil Duttc69bccb2014-05-26 21:30:20 +05301832 status = wlan_hdd_validate_context(pHddCtx);
1833 if (0 != status)
1834 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301835 return -EINVAL;
1836 }
1837
1838 if (NULL == pAdapter)
1839 {
1840 hddLog(VOS_TRACE_LEVEL_ERROR,
1841 FL("HDD adapter is Null"));
1842 return -ENODEV;
1843 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301844 /* check the LLStats Capability */
1845 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1846 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1847 {
1848 hddLog(VOS_TRACE_LEVEL_ERROR,
1849 FL("Link Layer Statistics not supported by Firmware"));
1850 return -EINVAL;
1851 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301852
1853 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_MAX,
1854 (struct nlattr *)data,
1855 data_len, qca_wlan_vendor_ll_set_policy))
1856 {
1857 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
1858 return -EINVAL;
1859 }
1860 if (!tb_vendor
1861 [QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD])
1862 {
1863 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MPDU size Not present"));
1864 return -EINVAL;
1865 }
1866 if (!tb_vendor[
1867 QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING])
1868 {
1869 hddLog(VOS_TRACE_LEVEL_ERROR, FL(" Stats Gathering Not Present"));
1870 return -EINVAL;
1871 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05301872 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05301873 linkLayerStatsSetReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301874
Dino Mycledf0a5d92014-07-04 09:41:55 +05301875 linkLayerStatsSetReq.mpduSizeThreshold =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301876 nla_get_u32(
1877 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_MPDU_SIZE_THRESHOLD]);
1878
Dino Mycledf0a5d92014-07-04 09:41:55 +05301879 linkLayerStatsSetReq.aggressiveStatisticsGathering =
Sunil Duttc69bccb2014-05-26 21:30:20 +05301880 nla_get_u32(
1881 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_SET_CONFIG_AGGRESSIVE_STATS_GATHERING]);
1882
Dino Mycled3d50022014-07-07 12:58:25 +05301883 vos_mem_copy(linkLayerStatsSetReq.macAddr,
1884 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05301885
1886
1887 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301888 "LL_STATS_SET reqId = %d", linkLayerStatsSetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301889 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05301890 "LL_STATS_SET MAC = %pM", linkLayerStatsSetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301891 hddLog(VOS_TRACE_LEVEL_INFO,
1892 "LL_STATS_SET mpduSizeThreshold = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301893 linkLayerStatsSetReq.mpduSizeThreshold);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301894 hddLog(VOS_TRACE_LEVEL_INFO,
1895 "LL_STATS_SET aggressive Statistics Gathering = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05301896 linkLayerStatsSetReq.aggressiveStatisticsGathering);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301897
1898 if (eHAL_STATUS_SUCCESS != sme_SetLinkLayerStatsIndCB(
1899 pHddCtx->hHal,
Dino Mycled3d50022014-07-07 12:58:25 +05301900 hdd_link_layer_stats_ind_callback))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301901 {
1902 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1903 "sme_SetLinkLayerStatsIndCB Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301904 return -EINVAL;
1905
1906 }
Srinivas Dasari98947432014-11-07 19:41:24 +05301907
1908 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1909 if (VOS_STATUS_SUCCESS !=
1910 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1911 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE))
1912 {
1913 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1914 "WLANTL_ClearInterfaceStats Failed", __func__);
1915 return -EINVAL;
1916 }
1917
1918 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1919 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1920 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1921 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1922
Sunil Duttc69bccb2014-05-26 21:30:20 +05301923 if (eHAL_STATUS_SUCCESS != sme_LLStatsSetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05301924 &linkLayerStatsSetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05301925 {
1926 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1927 "sme_LLStatsSetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05301928 return -EINVAL;
1929 }
1930
1931 pAdapter->isLinkLayerStatsSet = 1;
1932
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301933 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05301934 return 0;
1935}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301936static int wlan_hdd_cfg80211_ll_stats_set(struct wiphy *wiphy,
1937 struct wireless_dev *wdev,
1938 const void *data,
1939 int data_len)
1940{
1941 int ret = 0;
1942
1943 vos_ssr_protect(__func__);
1944 ret = __wlan_hdd_cfg80211_ll_stats_set(wiphy, wdev, data, data_len);
1945 vos_ssr_unprotect(__func__);
1946
1947 return ret;
1948}
Sunil Duttc69bccb2014-05-26 21:30:20 +05301949
1950const struct
1951nla_policy
1952qca_wlan_vendor_ll_get_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX +1] =
1953{
1954 /* Unsigned 32bit value provided by the caller issuing the GET stats
1955 * command. When reporting
1956 * the stats results, the driver uses the same value to indicate
1957 * which GET request the results
1958 * correspond to.
1959 */
1960 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID] = { .type = NLA_U32 },
1961
1962 /* Unsigned 32bit value . bit mask to identify what statistics are
1963 requested for retrieval */
1964 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK] = { .type = NLA_U32 },
1965};
1966
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05301967static int __wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
1968 struct wireless_dev *wdev,
1969 const void *data,
1970 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05301971{
1972 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
1973 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05301974 tSirLLStatsGetReq linkLayerStatsGetReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05301975 struct net_device *dev = wdev->netdev;
1976 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1977 int status;
1978
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05301979 ENTER();
1980
Sunil Duttc69bccb2014-05-26 21:30:20 +05301981 status = wlan_hdd_validate_context(pHddCtx);
1982 if (0 != status)
1983 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05301984 return -EINVAL ;
1985 }
1986
1987 if (NULL == pAdapter)
1988 {
1989 hddLog(VOS_TRACE_LEVEL_FATAL,
1990 "%s: HDD adapter is Null", __func__);
1991 return -ENODEV;
1992 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05301993 /* check the LLStats Capability */
1994 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
1995 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
1996 {
1997 hddLog(VOS_TRACE_LEVEL_ERROR,
1998 FL("Link Layer Statistics not supported by Firmware"));
1999 return -EINVAL;
2000 }
2001
Sunil Duttc69bccb2014-05-26 21:30:20 +05302002
2003 if (!pAdapter->isLinkLayerStatsSet)
2004 {
2005 hddLog(VOS_TRACE_LEVEL_FATAL,
2006 "%s: isLinkLayerStatsSet : %d",
2007 __func__, pAdapter->isLinkLayerStatsSet);
2008 return -EINVAL;
2009 }
2010
2011 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_MAX,
2012 (struct nlattr *)data,
2013 data_len, qca_wlan_vendor_ll_get_policy))
2014 {
2015 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2016 return -EINVAL;
2017 }
2018
2019 if (!tb_vendor
2020 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID])
2021 {
2022 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Request Id Not present"));
2023 return -EINVAL;
2024 }
2025
2026 if (!tb_vendor
2027 [QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK])
2028 {
2029 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Req Mask Not present"));
2030 return -EINVAL;
2031 }
2032
Sunil Duttc69bccb2014-05-26 21:30:20 +05302033
Dino Mycledf0a5d92014-07-04 09:41:55 +05302034 linkLayerStatsGetReq.reqId =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302035 nla_get_u32( tb_vendor[
2036 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_ID]);
Dino Mycledf0a5d92014-07-04 09:41:55 +05302037 linkLayerStatsGetReq.paramIdMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302038 nla_get_u32( tb_vendor[
2039 QCA_WLAN_VENDOR_ATTR_LL_STATS_GET_CONFIG_REQ_MASK]);
2040
Dino Mycled3d50022014-07-07 12:58:25 +05302041 vos_mem_copy(linkLayerStatsGetReq.macAddr,
2042 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302043
2044 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302045 "LL_STATS_GET reqId = %d", linkLayerStatsGetReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302046 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302047 "LL_STATS_GET MAC = %pM", linkLayerStatsGetReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302048 hddLog(VOS_TRACE_LEVEL_INFO,
2049 "LL_STATS_GET paramIdMask = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302050 linkLayerStatsGetReq.paramIdMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302051
2052 if (eHAL_STATUS_SUCCESS != sme_LLStatsGetReq( pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302053 &linkLayerStatsGetReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302054 {
2055 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2056 "sme_LLStatsGetReq Failed", __func__);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302057 return -EINVAL;
2058 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302059
2060 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302061 return 0;
2062}
2063
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302064static int wlan_hdd_cfg80211_ll_stats_get(struct wiphy *wiphy,
2065 struct wireless_dev *wdev,
2066 const void *data,
2067 int data_len)
2068{
2069 int ret = 0;
2070
2071 vos_ssr_protect(__func__);
2072 ret = __wlan_hdd_cfg80211_ll_stats_get(wiphy, wdev, data, data_len);
2073 vos_ssr_unprotect(__func__);
2074
2075 return ret;
2076}
2077
Sunil Duttc69bccb2014-05-26 21:30:20 +05302078const struct
2079nla_policy
2080qca_wlan_vendor_ll_clr_policy[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX +1] =
2081{
2082 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] = {.type = NLA_U32 },
2083 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ] = {.type = NLA_U8 },
2084 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK] = {.type = NLA_U32 },
2085 [QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP] = {.type = NLA_U8 },
2086};
2087
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302088static int __wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2089 struct wireless_dev *wdev,
2090 const void *data,
2091 int data_len)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302092{
2093 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2094 struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX + 1];
Dino Mycledf0a5d92014-07-04 09:41:55 +05302095 tSirLLStatsClearReq linkLayerStatsClearReq;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302096 struct net_device *dev = wdev->netdev;
2097 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2098 u32 statsClearReqMask;
2099 u8 stopReq;
2100 int status;
2101
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302102 ENTER();
2103
Sunil Duttc69bccb2014-05-26 21:30:20 +05302104 status = wlan_hdd_validate_context(pHddCtx);
2105 if (0 != status)
2106 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05302107 return -EINVAL;
2108 }
2109
2110 if (NULL == pAdapter)
2111 {
2112 hddLog(VOS_TRACE_LEVEL_FATAL,
2113 "%s: HDD adapter is Null", __func__);
2114 return -ENODEV;
2115 }
Dino Mycledf0a5d92014-07-04 09:41:55 +05302116 /* check the LLStats Capability */
2117 if ( (TRUE != pHddCtx->cfg_ini->fEnableLLStats) ||
2118 (TRUE != sme_IsFeatureSupportedByFW(LINK_LAYER_STATS_MEAS)))
2119 {
2120 hddLog(VOS_TRACE_LEVEL_ERROR,
2121 FL("Enable LLStats Capability"));
2122 return -EINVAL;
2123 }
Sunil Duttc69bccb2014-05-26 21:30:20 +05302124
2125 if (!pAdapter->isLinkLayerStatsSet)
2126 {
2127 hddLog(VOS_TRACE_LEVEL_FATAL,
2128 "%s: isLinkLayerStatsSet : %d",
2129 __func__, pAdapter->isLinkLayerStatsSet);
2130 return -EINVAL;
2131 }
2132
2133 if (nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_MAX,
2134 (struct nlattr *)data,
2135 data_len, qca_wlan_vendor_ll_clr_policy))
2136 {
2137 hddLog(VOS_TRACE_LEVEL_ERROR, FL() );
2138 return -EINVAL;
2139 }
2140
2141 if (!tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK] ||
2142
2143 !tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ])
2144 {
2145 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Error in LL_STATS CLR CONFIG PARA") );
2146 return -EINVAL;
2147
2148 }
2149
Sunil Duttc69bccb2014-05-26 21:30:20 +05302150
Dino Mycledf0a5d92014-07-04 09:41:55 +05302151 statsClearReqMask = linkLayerStatsClearReq.statsClearReqMask =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302152 nla_get_u32(
2153 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_REQ_MASK]);
2154
Dino Mycledf0a5d92014-07-04 09:41:55 +05302155 stopReq = linkLayerStatsClearReq.stopReq =
Sunil Duttc69bccb2014-05-26 21:30:20 +05302156 nla_get_u8(
2157 tb_vendor[QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_REQ]);
2158
2159 // Shall take the request Id if the Upper layers pass. 1 For now.
Dino Mycledf0a5d92014-07-04 09:41:55 +05302160 linkLayerStatsClearReq.reqId = 1;
Sunil Duttc69bccb2014-05-26 21:30:20 +05302161
Dino Mycled3d50022014-07-07 12:58:25 +05302162 vos_mem_copy(linkLayerStatsClearReq.macAddr,
2163 pAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Sunil Duttc69bccb2014-05-26 21:30:20 +05302164
2165 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302166 "LL_STATS_CLEAR reqId = %d", linkLayerStatsClearReq.reqId);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302167 hddLog(VOS_TRACE_LEVEL_INFO,
Dino Mycled3d50022014-07-07 12:58:25 +05302168 "LL_STATS_CLEAR MAC = %pM", linkLayerStatsClearReq.macAddr);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302169 hddLog(VOS_TRACE_LEVEL_INFO,
2170 "LL_STATS_CLEAR statsClearReqMask = 0x%X",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302171 linkLayerStatsClearReq.statsClearReqMask);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302172 hddLog(VOS_TRACE_LEVEL_INFO,
2173 "LL_STATS_CLEAR stopReq = %d",
Dino Mycledf0a5d92014-07-04 09:41:55 +05302174 linkLayerStatsClearReq.stopReq);
Sunil Duttc69bccb2014-05-26 21:30:20 +05302175
2176 if (eHAL_STATUS_SUCCESS == sme_LLStatsClearReq(pHddCtx->hHal,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302177 &linkLayerStatsClearReq))
Sunil Duttc69bccb2014-05-26 21:30:20 +05302178 {
2179 struct sk_buff *temp_skbuff;
Srinivas Dasari98947432014-11-07 19:41:24 +05302180 hdd_station_ctx_t *pHddStaCtx;
2181
2182 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2183 if (VOS_STATUS_SUCCESS !=
2184 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2185 pHddStaCtx->conn_info.staId[0], statsClearReqMask))
2186 {
2187 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
2188 "WLANTL_ClearInterfaceStats Failed", __func__);
2189 return -EINVAL;
2190 }
2191 if ((statsClearReqMask & WIFI_STATS_IFACE_AC) ||
2192 (statsClearReqMask & WIFI_STATS_IFACE)) {
2193 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
2194 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
2195 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
2196 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
2197 }
2198
Sunil Duttc69bccb2014-05-26 21:30:20 +05302199 temp_skbuff = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
2200 2 * sizeof(u32) +
2201 NLMSG_HDRLEN);
2202
2203 if (temp_skbuff != NULL)
2204 {
2205
2206 if (nla_put_u32(temp_skbuff,
2207 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_RSP_MASK,
2208 statsClearReqMask) ||
2209 nla_put_u32(temp_skbuff,
2210 QCA_WLAN_VENDOR_ATTR_LL_STATS_CLR_CONFIG_STOP_RSP,
2211 stopReq))
2212 {
2213 hddLog(VOS_TRACE_LEVEL_ERROR, FL("LL_STATS_CLR put fail"));
2214 kfree_skb(temp_skbuff);
2215 return -EINVAL;
2216 }
2217 /* If the ask is to stop the stats collection as part of clear
2218 * (stopReq = 1) , ensure that no further requests of get
2219 * go to the firmware by having isLinkLayerStatsSet set to 0.
2220 * However it the stopReq as part of the clear request is 0 ,
Dino Mycledf0a5d92014-07-04 09:41:55 +05302221 * the request to get the statistics are honoured as in this
Sunil Duttc69bccb2014-05-26 21:30:20 +05302222 * case the firmware is just asked to clear the statistics.
2223 */
Dino Mycledf0a5d92014-07-04 09:41:55 +05302224 if (linkLayerStatsClearReq.stopReq == 1)
Sunil Duttc69bccb2014-05-26 21:30:20 +05302225 pAdapter->isLinkLayerStatsSet = 0;
2226 return cfg80211_vendor_cmd_reply(temp_skbuff);
2227 }
2228 return -ENOMEM;
2229 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302230
2231 EXIT();
Sunil Duttc69bccb2014-05-26 21:30:20 +05302232 return -EINVAL;
2233}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05302234static int wlan_hdd_cfg80211_ll_stats_clear(struct wiphy *wiphy,
2235 struct wireless_dev *wdev,
2236 const void *data,
2237 int data_len)
2238{
2239 int ret = 0;
2240
2241 vos_ssr_protect(__func__);
2242 ret = __wlan_hdd_cfg80211_ll_stats_clear(wiphy, wdev, data, data_len);
2243 vos_ssr_unprotect(__func__);
2244
2245 return ret;
2246
2247
2248}
Sunil Duttc69bccb2014-05-26 21:30:20 +05302249#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
2250
Dino Mycle6fb96c12014-06-10 11:52:40 +05302251#ifdef WLAN_FEATURE_EXTSCAN
2252static const struct nla_policy
2253wlan_hdd_extscan_config_policy
2254 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1] =
2255{
2256 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID] =
2257 { .type = NLA_U32 },
2258 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND] =
2259 { .type = NLA_U32 },
2260 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL] = { .type = NLA_U32 },
2261 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME] =
2262 { .type = NLA_U32 },
2263 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE] = { .type = NLA_U8 },
2264 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CLASS] = { .type = NLA_U8 },
2265
2266 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX] = { .type = NLA_U8 },
2267 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND] = { .type = NLA_U8 },
2268 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD] = { .type = NLA_U32 },
2269 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS] =
2270 { .type = NLA_U8 },
2271 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS] =
2272 { .type = NLA_U32 },
2273 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD] =
2274 { .type = NLA_U32 },
2275 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN] =
2276 { .type = NLA_U32 },
2277 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD] =
2278 { .type = NLA_U8 },
2279 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS] =
2280 { .type = NLA_U8 },
2281 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH] =
2282 { .type = NLA_U8 },
2283
2284 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_MAX] =
2285 { .type = NLA_U32 },
2286 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID] =
2287 { .type = NLA_UNSPEC },
2288 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW] =
2289 { .type = NLA_S32 },
2290 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH] =
2291 { .type = NLA_S32 },
2292 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL] =
2293 { .type = NLA_U32 },
2294 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP] =
2295 { .type = NLA_U32 },
2296 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE] =
2297 { .type = NLA_U32 },
2298 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]
2299 = { .type = NLA_U32 },
2300 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING] =
2301 { .type = NLA_U32 },
2302 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP] = { .type =
2303 NLA_U32 },
2304};
2305
2306static void wlan_hdd_cfg80211_extscan_get_capabilities_ind(void *ctx, void *pMsg)
2307{
2308 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2309 struct sk_buff *skb = NULL;
2310 tpSirEXTScanCapabilitiesEvent pData =
2311 (tpSirEXTScanCapabilitiesEvent) pMsg;
2312
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302313 ENTER();
2314
2315 if (wlan_hdd_validate_context(pHddCtx))
2316 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302317 return;
2318 }
2319
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302320 if (!pMsg)
2321 {
2322 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2323 return;
2324 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05302325 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2326 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2327 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES_INDEX,
2328 GFP_KERNEL);
2329
2330 if (!skb) {
2331 hddLog(VOS_TRACE_LEVEL_ERROR,
2332 FL("cfg80211_vendor_event_alloc failed"));
2333 return;
2334 }
2335
2336 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2337 hddLog(VOS_TRACE_LEVEL_INFO, "Scan cache size (%u)", pData->scanCacheSize);
2338 hddLog(VOS_TRACE_LEVEL_INFO, "Scan buckets (%u)", pData->scanBuckets);
2339 hddLog(VOS_TRACE_LEVEL_INFO, "Max AP per scan (%u)", pData->maxApPerScan);
2340 hddLog(VOS_TRACE_LEVEL_INFO, "maxRssiSampleSize (%u)",
2341 pData->maxRssiSampleSize);
2342 hddLog(VOS_TRACE_LEVEL_INFO, "maxScanReportingThreshold (%u)",
2343 pData->maxScanReportingThreshold);
2344 hddLog(VOS_TRACE_LEVEL_INFO, "maxHotlistAPs (%u)", pData->maxHotlistAPs);
2345 hddLog(VOS_TRACE_LEVEL_INFO, "maxSignificantWifiChangeAPs (%u)",
2346 pData->maxSignificantWifiChangeAPs);
2347 hddLog(VOS_TRACE_LEVEL_INFO, "maxBsidHistoryEntries (%u)",
2348 pData->maxBsidHistoryEntries);
2349
2350 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2351 pData->requestId) ||
2352 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status) ||
2353 nla_put_u32(skb,
2354 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_CACHE_SIZE,
2355 pData->scanCacheSize) ||
2356 nla_put_u32(skb,
2357 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_BUCKETS,
2358 pData->scanBuckets) ||
2359 nla_put_u32(skb,
2360 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_AP_CACHE_PER_SCAN,
2361 pData->maxApPerScan) ||
2362 nla_put_u32(skb,
2363 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_RSSI_SAMPLE_SIZE,
2364 pData->maxRssiSampleSize) ||
2365 nla_put_u32(skb,
2366 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SCAN_REPORTING_THRESHOLD,
2367 pData->maxScanReportingThreshold) ||
2368 nla_put_u32(skb,
2369 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_HOTLIST_APS,
2370 pData->maxHotlistAPs) ||
2371 nla_put_u32(skb,
2372 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_SIGNIFICANT_WIFI_CHANGE_APS,
2373 pData->maxSignificantWifiChangeAPs) ||
2374 nla_put_u32(skb,
2375 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CAPABILITIES_MAX_BSSID_HISTORY_ENTRIES,
2376 pData->maxBsidHistoryEntries)) {
2377 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2378 goto nla_put_failure;
2379 }
2380
2381 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302382 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302383 return;
2384
2385nla_put_failure:
2386 kfree_skb(skb);
2387 return;
2388}
2389
2390
2391static void wlan_hdd_cfg80211_extscan_start_rsp(void *ctx, void *pMsg)
2392{
2393 tpSirEXTScanStartRspParams pData = (tpSirEXTScanStartRspParams) pMsg;
2394 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2395 struct sk_buff *skb = NULL;
2396 tpAniSirGlobal pMac = PMAC_STRUCT( pHddCtx->hHal );
2397
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302398 ENTER();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302399
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302400 if (wlan_hdd_validate_context(pHddCtx)){
2401 return;
2402 }
2403 if (!pMsg)
2404 {
2405 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302406 return;
2407 }
2408
2409 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2410 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2411 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START_INDEX,
2412 GFP_KERNEL);
2413
2414 if (!skb) {
2415 hddLog(VOS_TRACE_LEVEL_ERROR,
2416 FL("cfg80211_vendor_event_alloc failed"));
2417 return;
2418 }
2419 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2420 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2421 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2422
2423 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2424 pData->requestId) ||
2425 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2426 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2427 goto nla_put_failure;
2428 }
2429
2430 /*
2431 * Store the Request ID for comparing with the requestID obtained
2432 * in other requests.HDD shall return a failure is the extscan_stop
2433 * request is issued with a different requestId as that of the
2434 * extscan_start request. Also, This requestId shall be used while
2435 * indicating the full scan results to the upper layers.
2436 * The requestId is stored with the assumption that the firmware
2437 * shall return the ext scan start request's requestId in ext scan
2438 * start response.
2439 */
2440 if (pData->status == 0)
2441 pMac->sme.extScanStartReqId = pData->requestId;
2442
2443
2444 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302445 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302446 return;
2447
2448nla_put_failure:
2449 kfree_skb(skb);
2450 return;
2451}
2452
2453
2454static void wlan_hdd_cfg80211_extscan_stop_rsp(void *ctx, void *pMsg)
2455{
2456 tpSirEXTScanStopRspParams pData = (tpSirEXTScanStopRspParams) pMsg;
2457 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2458 struct sk_buff *skb = NULL;
2459
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302460 ENTER();
2461
2462 if (wlan_hdd_validate_context(pHddCtx)){
2463 return;
2464 }
2465 if (!pMsg)
2466 {
2467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302468 return;
2469 }
2470
2471 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2472 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2473 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP_INDEX,
2474 GFP_KERNEL);
2475
2476 if (!skb) {
2477 hddLog(VOS_TRACE_LEVEL_ERROR,
2478 FL("cfg80211_vendor_event_alloc failed"));
2479 return;
2480 }
2481 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2482 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2483
2484 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2485 pData->requestId) ||
2486 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2487 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2488 goto nla_put_failure;
2489 }
2490
2491 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302492 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302493 return;
2494
2495nla_put_failure:
2496 kfree_skb(skb);
2497 return;
2498}
2499
2500
2501static void wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(void *ctx,
2502 void *pMsg)
2503{
2504 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2505 struct sk_buff *skb = NULL;
2506 tpSirEXTScanSetBssidHotListRspParams pData =
2507 (tpSirEXTScanSetBssidHotListRspParams) pMsg;
2508
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302509 ENTER();
2510
2511 if (wlan_hdd_validate_context(pHddCtx)){
Dino Mycle6fb96c12014-06-10 11:52:40 +05302512 return;
2513 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302514 if (!pMsg)
2515 {
2516 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2517 return;
2518 }
2519
Dino Mycle6fb96c12014-06-10 11:52:40 +05302520 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2521 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2522 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST_INDEX,
2523 GFP_KERNEL);
2524
2525 if (!skb) {
2526 hddLog(VOS_TRACE_LEVEL_ERROR,
2527 FL("cfg80211_vendor_event_alloc failed"));
2528 return;
2529 }
2530 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2531 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2532 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2533
2534 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2535 pData->requestId) ||
2536 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2537 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2538 goto nla_put_failure;
2539 }
2540
2541 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302542 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302543 return;
2544
2545nla_put_failure:
2546 kfree_skb(skb);
2547 return;
2548}
2549
2550static void wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(void *ctx,
2551 void *pMsg)
2552{
2553 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2554 struct sk_buff *skb = NULL;
2555 tpSirEXTScanResetBssidHotlistRspParams pData =
2556 (tpSirEXTScanResetBssidHotlistRspParams) pMsg;
2557
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302558 ENTER();
2559
2560 if (wlan_hdd_validate_context(pHddCtx)) {
2561 return;
2562 }
2563 if (!pMsg)
2564 {
2565 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302566 return;
2567 }
2568
2569 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2570 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2571 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST_INDEX,
2572 GFP_KERNEL);
2573
2574 if (!skb) {
2575 hddLog(VOS_TRACE_LEVEL_ERROR,
2576 FL("cfg80211_vendor_event_alloc failed"));
2577 return;
2578 }
2579 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2580 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2581
2582 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2583 pData->requestId) ||
2584 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2585 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2586 goto nla_put_failure;
2587 }
2588
2589 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302590 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302591 return;
2592
2593nla_put_failure:
2594 kfree_skb(skb);
2595 return;
2596}
2597
2598
2599static void wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(void *ctx,
2600 void *pMsg)
2601{
2602 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2603 struct sk_buff *skb = NULL;
2604 tpSirEXTScanSetSignificantChangeRspParams pData =
2605 (tpSirEXTScanSetSignificantChangeRspParams) pMsg;
2606
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302607 ENTER();
2608
2609 if (wlan_hdd_validate_context(pHddCtx)) {
2610 return;
2611 }
2612 if (!pMsg)
2613 {
2614 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302615 return;
2616 }
2617
2618 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2619 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2620 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE_INDEX,
2621 GFP_KERNEL);
2622
2623 if (!skb) {
2624 hddLog(VOS_TRACE_LEVEL_ERROR,
2625 FL("cfg80211_vendor_event_alloc failed"));
2626 return;
2627 }
2628 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2629 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2630 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2631
2632 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2633 pData->requestId) ||
2634 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2635 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2636 goto nla_put_failure;
2637 }
2638
2639 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302640 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302641 return;
2642
2643nla_put_failure:
2644 kfree_skb(skb);
2645 return;
2646}
2647
2648
2649static void wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(void *ctx,
2650 void *pMsg)
2651{
2652 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2653 struct sk_buff *skb = NULL;
2654 tpSirEXTScanResetSignificantChangeRspParams pData =
2655 (tpSirEXTScanResetSignificantChangeRspParams) pMsg;
2656
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302657 ENTER();
2658
2659 if (wlan_hdd_validate_context(pHddCtx)) {
2660 return;
2661 }
2662 if (!pMsg)
2663 {
2664 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302665 return;
2666 }
2667
2668 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2669 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2670 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE_INDEX,
2671 GFP_KERNEL);
2672
2673 if (!skb) {
2674 hddLog(VOS_TRACE_LEVEL_ERROR,
2675 FL("cfg80211_vendor_event_alloc failed"));
2676 return;
2677 }
2678 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2679 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2680 hddLog(VOS_TRACE_LEVEL_INFO, "Status (%u)", pData->status);
2681
2682 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2683 pData->requestId) ||
2684 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_STATUS, pData->status)) {
2685 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
2686 goto nla_put_failure;
2687 }
2688
2689 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302690 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302691 return;
2692
2693nla_put_failure:
2694 kfree_skb(skb);
2695 return;
2696}
2697
2698static void wlan_hdd_cfg80211_extscan_cached_results_ind(void *ctx,
2699 void *pMsg)
2700{
2701 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2702 struct sk_buff *skb = NULL;
2703 tANI_U32 i = 0, j, resultsPerEvent;
2704 tANI_S32 totalResults;
2705 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2706 tpSirWifiScanResult pSirWifiScanResult;
2707
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302708 ENTER();
2709
2710 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302711 return;
2712 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302713 if (!pMsg)
2714 {
2715 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
2716 return;
2717 }
2718
Dino Mycle6fb96c12014-06-10 11:52:40 +05302719 totalResults = pData->numOfAps;
2720 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2721 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2722 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2723
2724 do{
2725 resultsPerEvent = ((totalResults >= EXTSCAN_MAX_CACHED_RESULTS_PER_IND) ?
2726 EXTSCAN_MAX_CACHED_RESULTS_PER_IND : totalResults);
2727 totalResults -= EXTSCAN_MAX_CACHED_RESULTS_PER_IND;
2728
2729 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2730 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2731 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS_INDEX,
2732 GFP_KERNEL);
2733
2734 if (!skb) {
2735 hddLog(VOS_TRACE_LEVEL_ERROR,
2736 FL("cfg80211_vendor_event_alloc failed"));
2737 return;
2738 }
2739
2740 hddLog(VOS_TRACE_LEVEL_INFO, "resultsPerEvent (%u)", resultsPerEvent);
2741
2742 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2743 pData->requestId) ||
2744 nla_put_u32(skb,
2745 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2746 resultsPerEvent)) {
2747 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2748 goto fail;
2749 }
2750 if (nla_put_u8(skb,
2751 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2752 pData->moreData ? 1 : (totalResults > 0 ? 1 : 0 )))
2753 {
2754 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2755 goto fail;
2756 }
2757
2758 if (resultsPerEvent) {
2759 struct nlattr *aps;
2760
2761 aps = nla_nest_start(skb,
2762 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2763 if (!aps)
2764 {
2765 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2766 goto fail;
2767 }
2768
2769 for (j = 0; j < resultsPerEvent; j++, i++) {
2770 struct nlattr *ap;
2771 pSirWifiScanResult = (tpSirWifiScanResult) ((tANI_U8 *)
2772 pData->ap + ( i* sizeof(tSirWifiScanResult)));
2773
2774 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(%llu) "
2775 "Ssid (%s)"
2776 "Bssid: %pM "
2777 "Channel (%u)"
2778 "Rssi (%d)"
2779 "RTT (%u)"
2780 "RTT_SD (%u)",
2781 i,
2782 pSirWifiScanResult->ts,
2783 pSirWifiScanResult->ssid,
2784 pSirWifiScanResult->bssid,
2785 pSirWifiScanResult->channel,
2786 pSirWifiScanResult->rssi,
2787 pSirWifiScanResult->rtt,
2788 pSirWifiScanResult->rtt_sd);
2789
2790 ap = nla_nest_start(skb, j + 1);
2791 if (!ap)
2792 {
2793 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2794 goto fail;
2795 }
2796
2797 if (nla_put_u64(skb,
2798 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2799 pSirWifiScanResult->ts) )
2800 {
2801 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2802 goto fail;
2803 }
2804 if (nla_put(skb,
2805 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2806 sizeof(pSirWifiScanResult->ssid),
2807 pSirWifiScanResult->ssid) )
2808 {
2809 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2810 goto fail;
2811 }
2812 if (nla_put(skb,
2813 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2814 sizeof(pSirWifiScanResult->bssid),
2815 pSirWifiScanResult->bssid) )
2816 {
2817 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2818 goto fail;
2819 }
2820 if (nla_put_u32(skb,
2821 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2822 pSirWifiScanResult->channel) )
2823 {
2824 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2825 goto fail;
2826 }
Dasari Srinivas90747d72014-10-08 12:16:15 +05302827 if (nla_put_s32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05302828 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2829 pSirWifiScanResult->rssi) )
2830 {
2831 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2832 goto fail;
2833 }
2834 if (nla_put_u32(skb,
2835 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2836 pSirWifiScanResult->rtt) )
2837 {
2838 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2839 goto fail;
2840 }
2841 if (nla_put_u32(skb,
2842 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2843 pSirWifiScanResult->rtt_sd))
2844 {
2845 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2846 goto fail;
2847 }
2848
2849 nla_nest_end(skb, ap);
2850 }
2851 nla_nest_end(skb, aps);
2852
2853 }
2854 cfg80211_vendor_event(skb, GFP_KERNEL);
2855 } while (totalResults > 0);
2856
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302857 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302858 return;
2859fail:
2860 kfree_skb(skb);
2861 return;
2862}
2863
2864static void wlan_hdd_cfg80211_extscan_hotlist_match_ind(void *ctx,
2865 void *pMsg)
2866{
2867 tpSirWifiScanResultEvent pData = (tpSirWifiScanResultEvent) pMsg;
2868 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2869 struct sk_buff *skb = NULL;
2870 tANI_U32 i;
2871
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302872 ENTER();
2873
2874 if (wlan_hdd_validate_context(pHddCtx)) {
2875 return;
2876 }
2877 if (!pMsg)
2878 {
2879 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05302880 return;
2881 }
2882
2883 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
2884 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
2885 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND_INDEX,
2886 GFP_KERNEL);
2887
2888 if (!skb) {
2889 hddLog(VOS_TRACE_LEVEL_ERROR,
2890 FL("cfg80211_vendor_event_alloc failed"));
2891 return;
2892 }
2893 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
2894 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
2895 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)", pData->numOfAps);
2896 hddLog(VOS_TRACE_LEVEL_INFO, "More Data (%u)", pData->moreData);
2897
2898 for (i = 0; i < pData->numOfAps; i++) {
2899 hddLog(VOS_TRACE_LEVEL_INFO, "[index=%u] Timestamp(0x%lld) "
2900 "Ssid (%s) "
2901 "Bssid (" MAC_ADDRESS_STR ") "
2902 "Channel (%u) "
2903 "Rssi (%d) "
2904 "RTT (%u) "
2905 "RTT_SD (%u) ",
2906 i,
2907 pData->ap[i].ts,
2908 pData->ap[i].ssid,
2909 MAC_ADDR_ARRAY(pData->ap[i].bssid),
2910 pData->ap[i].channel,
2911 pData->ap[i].rssi,
2912 pData->ap[i].rtt,
2913 pData->ap[i].rtt_sd);
2914 }
2915
2916 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
2917 pData->requestId) ||
2918 nla_put_u32(skb,
2919 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
2920 pData->numOfAps)) {
2921 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
2922 goto fail;
2923 }
2924 if (pData->numOfAps) {
2925 struct nlattr *aps;
2926
2927 aps = nla_nest_start(skb,
2928 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
2929 if (!aps)
2930 goto fail;
2931
2932 for (i = 0; i < pData->numOfAps; i++) {
2933 struct nlattr *ap;
2934
2935 ap = nla_nest_start(skb, i + 1);
2936 if (!ap)
2937 goto fail;
2938
2939 if (nla_put_u64(skb,
2940 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
2941 pData->ap[i].ts) ||
2942 nla_put(skb,
2943 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
2944 sizeof(pData->ap[i].ssid),
2945 pData->ap[i].ssid) ||
2946 nla_put(skb,
2947 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
2948 sizeof(pData->ap[i].bssid),
2949 pData->ap[i].bssid) ||
2950 nla_put_u32(skb,
2951 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
2952 pData->ap[i].channel) ||
2953 nla_put_s32(skb,
2954 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
2955 pData->ap[i].rssi) ||
2956 nla_put_u32(skb,
2957 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
2958 pData->ap[i].rtt) ||
2959 nla_put_u32(skb,
2960 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
2961 pData->ap[i].rtt_sd))
2962 goto fail;
2963
2964 nla_nest_end(skb, ap);
2965 }
2966 nla_nest_end(skb, aps);
2967
2968 if (nla_put_u8(skb,
2969 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
2970 pData->moreData))
2971 goto fail;
2972 }
2973
2974 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302975 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05302976 return;
2977
2978fail:
2979 kfree_skb(skb);
2980 return;
2981
2982}
2983static void wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(void *ctx,
2984 void *pMsg)
2985{
2986 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
2987 struct sk_buff *skb = NULL;
2988 tANI_U32 i, j;
2989 tpSirWifiSignificantChangeEvent pData =
2990 (tpSirWifiSignificantChangeEvent) pMsg;
2991
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302992 ENTER();
2993
2994 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05302995 return;
2996 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05302997 if (!pMsg)
2998 {
2999 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
3000 return;
3001 }
3002
Dino Mycle6fb96c12014-06-10 11:52:40 +05303003 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3004 EXTSCAN_EVENT_BUF_SIZE,
3005 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE_INDEX,
3006 GFP_KERNEL);
3007
3008 if (!skb) {
3009 hddLog(VOS_TRACE_LEVEL_ERROR,
3010 FL("cfg80211_vendor_event_alloc failed"));
3011 return;
3012 }
3013 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3014 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3015 hddLog(VOS_TRACE_LEVEL_INFO, "total List Size %u ", pData->numSigRssiBss);
3016 hddLog(VOS_TRACE_LEVEL_INFO, " CUrrent List size (%u)",
3017 pData->numSigRssiBss);
3018 hddLog(VOS_TRACE_LEVEL_INFO, "moreData (%u)", pData->moreData);
3019
3020 for (i = 0; i < pData->numSigRssiBss; i++) {
3021 hddLog(VOS_TRACE_LEVEL_INFO , "Rssi List [%d] BSSID: (%pM) Channel %u "
3022 " num RSSI %u ",
3023 i, pData->sigRssiResult[i].bssid,
3024 pData->sigRssiResult[i].channel,
3025 pData->sigRssiResult[i].numRssi);
3026
3027 for (j = 0; j < pData->sigRssiResult[i].numRssi; j++){
3028
3029 hddLog(VOS_TRACE_LEVEL_INFO,
3030 " [%d]",
Dino Myclec8f3f332014-07-21 16:48:27 +05303031 pData->sigRssiResult[i].rssi[j]);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303032
3033 }
3034 }
3035
3036
3037 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3038 pData->requestId) ||
3039 nla_put_u32(skb,
3040 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3041 pData->numSigRssiBss)) {
3042 hddLog(VOS_TRACE_LEVEL_ERROR, FL("put fail"));
3043 goto fail;
3044 }
3045
3046 if (pData->numSigRssiBss) {
3047 struct nlattr *aps;
3048 aps = nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_LIST);
3049 if (!aps)
3050 goto fail;
3051 for (i = 0; i < pData->numSigRssiBss; i++) {
3052 struct nlattr *ap;
3053
3054 ap = nla_nest_start(skb, i);
3055 if (!ap)
3056 goto fail;
3057 if (nla_put(skb,
3058 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_BSSID,
3059 sizeof(tSirMacAddr), pData->sigRssiResult[i].bssid) ||
3060 nla_put_u32(skb,
3061 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_CHANNEL,
3062 pData->sigRssiResult[i].channel) ||
3063 nla_put_u32(skb,
3064 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_NUM_RSSI,
3065 pData->sigRssiResult[i].numRssi) ||
3066 nla_put(skb,
3067 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SIGNIFICANT_CHANGE_RESULT_RSSI_LIST,
3068 sizeof(s32) * pData->sigRssiResult[i].numRssi,
3069 pData->sigRssiResult[i].rssi))
3070 goto fail;
3071 nla_nest_end(skb, ap);
3072 }
3073 nla_nest_end(skb, aps);
3074 if (nla_put_u8(skb,
3075 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_MORE_DATA,
3076 pData->moreData))
3077 goto fail;
3078 }
3079 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303080 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303081 return;
3082fail:
3083 kfree_skb(skb);
3084 return;
3085}
3086
3087static void wlan_hdd_cfg80211_extscan_full_scan_result_event(void *ctx,
3088 void *pMsg)
3089{
3090 struct sk_buff *skb;
3091 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3092 tpSirWifiFullScanResultEvent pData =
3093 (tpSirWifiFullScanResultEvent) (pMsg);
3094
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303095 ENTER();
3096
3097 if (wlan_hdd_validate_context(pHddCtx)) {
3098 return;
3099 }
3100 if (!pMsg)
3101 {
3102 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303103 return;
3104 }
3105
3106 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3107 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3108 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT_INDEX,
3109 GFP_KERNEL);
3110
3111 if (!skb) {
3112 hddLog(VOS_TRACE_LEVEL_ERROR,
3113 FL("cfg80211_vendor_event_alloc failed"));
3114 return;
3115 }
3116
3117 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3118 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%u)"), pData->requestId);
3119 hddLog(VOS_TRACE_LEVEL_INFO, FL("More Data (%u)"), pData->moreData);
3120 hddLog(VOS_TRACE_LEVEL_INFO, FL("AP Info: Timestamp(0x%llX) "
3121 "Ssid (%s)"
3122 "Bssid (" MAC_ADDRESS_STR ")"
3123 "Channel (%u)"
3124 "Rssi (%d)"
3125 "RTT (%u)"
3126 "RTT_SD (%u)"),
3127 pData->ap.ts,
3128 pData->ap.ssid,
3129 MAC_ADDR_ARRAY(pData->ap.bssid),
3130 pData->ap.channel,
3131 pData->ap.rssi,
3132 pData->ap.rtt,
3133 pData->ap.rtt_sd);
3134 hddLog(VOS_TRACE_LEVEL_INFO, "IE Length (%u)", pData->ieLength);
3135 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3136 pData->requestId) ||
3137 nla_put_u64(skb,
3138 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_TIME_STAMP,
3139 pData->ap.ts) ||
3140 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_SSID,
3141 sizeof(pData->ap.ssid),
3142 pData->ap.ssid) ||
3143 nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BSSID,
3144 WNI_CFG_BSSID_LEN,
3145 pData->ap.bssid) ||
3146 nla_put_u32(skb,
3147 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CHANNEL,
3148 pData->ap.channel) ||
Dasari Srinivas90747d72014-10-08 12:16:15 +05303149 nla_put_s32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RSSI,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303150 pData->ap.rssi) ||
3151 nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT,
3152 pData->ap.rtt) ||
3153 nla_put_u32(skb,
3154 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_RTT_SD,
3155 pData->ap.rtt_sd) ||
3156 nla_put_u16(skb,
3157 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_BEACON_PERIOD,
3158 pData->ap.beaconPeriod) ||
3159 nla_put_u16(skb,
3160 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_CAPABILITY,
3161 pData->ap.capability) ||
3162 nla_put_u32(skb,
3163 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_LENGTH,
3164 pData->ieLength))
3165 {
3166 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3167 goto nla_put_failure;
3168 }
3169 if (nla_put(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_RESULT_IE_DATA,
3170 pData->ieLength,
3171 pData->ie))
3172 {
3173 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3174 goto nla_put_failure;
3175 }
3176
3177 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303178 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303179 return;
3180
3181nla_put_failure:
3182 kfree_skb(skb);
3183 return;
3184}
3185
3186static void wlan_hdd_cfg80211_extscan_scan_res_available_event(void *ctx,
3187 void *pMsg)
3188{
3189 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3190 struct sk_buff *skb = NULL;
3191 tpSirEXTScanResultsAvailableIndParams pData =
3192 (tpSirEXTScanResultsAvailableIndParams) pMsg;
3193
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303194 ENTER();
3195
3196 if (wlan_hdd_validate_context(pHddCtx)){
3197 return;
3198 }
3199 if (!pMsg)
3200 {
3201 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303202 return;
3203 }
3204
3205 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3206 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3207 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE_INDEX,
3208 GFP_KERNEL);
3209
3210 if (!skb) {
3211 hddLog(VOS_TRACE_LEVEL_ERROR,
3212 FL("cfg80211_vendor_event_alloc failed"));
3213 return;
3214 }
3215
3216 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3217 hddLog(VOS_TRACE_LEVEL_INFO, "Req Id (%u)", pData->requestId);
3218 hddLog(VOS_TRACE_LEVEL_INFO, "Num results (%u)",
3219 pData->numResultsAvailable);
3220 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3221 pData->requestId) ||
3222 nla_put_u32(skb,
3223 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_RESULTS_AVAILABLE,
3224 pData->numResultsAvailable)) {
3225 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3226 goto nla_put_failure;
3227 }
3228
3229 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303230 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303231 return;
3232
3233nla_put_failure:
3234 kfree_skb(skb);
3235 return;
3236}
3237
3238static void wlan_hdd_cfg80211_extscan_scan_progress_event(void *ctx, void *pMsg)
3239{
3240 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3241 struct sk_buff *skb = NULL;
3242 tpSirEXTScanProgressIndParams pData =
3243 (tpSirEXTScanProgressIndParams) pMsg;
3244
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303245 ENTER();
3246
3247 if (wlan_hdd_validate_context(pHddCtx)){
3248 return;
3249 }
3250 if (!pMsg)
3251 {
3252 hddLog(VOS_TRACE_LEVEL_ERROR, FL("pMsg is null"));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303253 return;
3254 }
3255
3256 skb = cfg80211_vendor_event_alloc(pHddCtx->wiphy,
3257 EXTSCAN_EVENT_BUF_SIZE + NLMSG_HDRLEN,
3258 QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT_INDEX,
3259 GFP_KERNEL);
3260
3261 if (!skb) {
3262 hddLog(VOS_TRACE_LEVEL_ERROR,
3263 FL("cfg80211_vendor_event_alloc failed"));
3264 return;
3265 }
3266 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
3267 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event type (%u)",
3268 pData->extScanEventType);
3269 hddLog(VOS_TRACE_LEVEL_INFO, "Scan event status (%u)",
3270 pData->status);
3271
3272 if (nla_put_u8(skb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_TYPE,
3273 pData->extScanEventType) ||
3274 nla_put_u32(skb,
Dasari Srinivas5a288652014-06-30 17:13:22 +05303275 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_REQUEST_ID,
3276 pData->requestId) ||
3277 nla_put_u32(skb,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303278 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_SCAN_EVENT_STATUS,
3279 pData->status)) {
3280 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3281 goto nla_put_failure;
3282 }
3283
3284 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303285 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303286 return;
3287
3288nla_put_failure:
3289 kfree_skb(skb);
3290 return;
3291}
3292
3293void wlan_hdd_cfg80211_extscan_callback(void *ctx, const tANI_U16 evType,
3294 void *pMsg)
3295{
3296 hdd_context_t *pHddCtx = (hdd_context_t *)ctx;
3297
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303298 ENTER();
3299
Dino Mycle6fb96c12014-06-10 11:52:40 +05303300 if (wlan_hdd_validate_context(pHddCtx)) {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303301 return;
3302 }
3303
3304 hddLog(VOS_TRACE_LEVEL_INFO, FL("Rcvd Event (%d)"), evType);
3305
3306
3307 switch(evType) {
3308 case SIR_HAL_EXTSCAN_START_RSP:
3309 wlan_hdd_cfg80211_extscan_start_rsp(ctx, pMsg);
3310 break;
3311
3312 case SIR_HAL_EXTSCAN_STOP_RSP:
3313 wlan_hdd_cfg80211_extscan_stop_rsp(ctx, pMsg);
3314 break;
3315 case SIR_HAL_EXTSCAN_GET_CACHED_RESULTS_RSP:
3316 /* There is no need to send this response to upper layer
3317 Just log the message */
3318 hddLog(VOS_TRACE_LEVEL_INFO,
3319 FL("Rcvd SIR_HAL_EXTSCAN_CACHED_RESULTS_RSP"));
3320 break;
3321 case SIR_HAL_EXTSCAN_SET_BSS_HOTLIST_RSP:
3322 wlan_hdd_cfg80211_extscan_set_bss_hotlist_rsp(ctx, pMsg);
3323 break;
3324
3325 case SIR_HAL_EXTSCAN_RESET_BSS_HOTLIST_RSP:
3326 wlan_hdd_cfg80211_extscan_reset_bss_hotlist_rsp(ctx, pMsg);
3327 break;
3328
3329 case SIR_HAL_EXTSCAN_SET_SIGNF_RSSI_CHANGE_RSP:
3330 wlan_hdd_cfg80211_extscan_set_signf_wifi_change_rsp(ctx, pMsg);
3331 break;
3332
3333 case SIR_HAL_EXTSCAN_RESET_SIGNF_RSSI_CHANGE_RSP:
3334 wlan_hdd_cfg80211_extscan_reset_signf_wifi_change_rsp(ctx, pMsg);
3335 break;
3336 case SIR_HAL_EXTSCAN_GET_CAPABILITIES_RSP:
3337 wlan_hdd_cfg80211_extscan_get_capabilities_ind(ctx, pMsg);
3338 break;
3339 case SIR_HAL_EXTSCAN_PROGRESS_IND:
3340 wlan_hdd_cfg80211_extscan_scan_progress_event(ctx, pMsg);
3341 break;
3342 case SIR_HAL_EXTSCAN_SCAN_AVAILABLE_IND:
3343 wlan_hdd_cfg80211_extscan_scan_res_available_event(ctx, pMsg);
3344 break;
3345 case SIR_HAL_EXTSCAN_SCAN_RESULT_IND:
3346 wlan_hdd_cfg80211_extscan_cached_results_ind(ctx, pMsg);
3347 break;
3348 case SIR_HAL_EXTSCAN_HOTLIST_MATCH_IND:
3349 wlan_hdd_cfg80211_extscan_hotlist_match_ind(ctx, pMsg);
3350 break;
3351 case SIR_HAL_EXTSCAN_SIGNF_WIFI_CHANGE_IND:
3352 wlan_hdd_cfg80211_extscan_signif_wifi_change_results_ind(ctx, pMsg);
3353 break;
3354 case SIR_HAL_EXTSCAN_FULL_SCAN_RESULT_IND:
3355 wlan_hdd_cfg80211_extscan_full_scan_result_event(ctx, pMsg);
3356 break;
3357 default:
3358 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid event type %d "), evType);
3359 break;
3360 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303361 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303362}
3363
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303364static int __wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3365 struct wireless_dev *wdev,
3366 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303367{
Dino Myclee8843b32014-07-04 14:21:45 +05303368 tSirGetEXTScanCapabilitiesReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303369 struct net_device *dev = wdev->netdev;
3370 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3371 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3372 struct nlattr
3373 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3374 eHalStatus status;
3375
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303376 ENTER();
3377
Dino Mycle6fb96c12014-06-10 11:52:40 +05303378 status = wlan_hdd_validate_context(pHddCtx);
3379 if (0 != status)
3380 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303381 return -EINVAL;
3382 }
Dino Myclee8843b32014-07-04 14:21:45 +05303383 /* check the EXTScan Capability */
3384 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3385 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3386 {
3387 hddLog(VOS_TRACE_LEVEL_ERROR,
3388 FL("EXTScan not enabled/supported by Firmware"));
3389 return -EINVAL;
3390 }
3391
Dino Mycle6fb96c12014-06-10 11:52:40 +05303392 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3393 data, dataLen,
3394 wlan_hdd_extscan_config_policy)) {
3395 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3396 return -EINVAL;
3397 }
3398
3399 /* Parse and fetch request Id */
3400 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3401 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3402 return -EINVAL;
3403 }
3404
Dino Mycle6fb96c12014-06-10 11:52:40 +05303405
Dino Myclee8843b32014-07-04 14:21:45 +05303406 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303407 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05303408 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303409
Dino Myclee8843b32014-07-04 14:21:45 +05303410 reqMsg.sessionId = pAdapter->sessionId;
3411 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303412
Dino Myclee8843b32014-07-04 14:21:45 +05303413 status = sme_EXTScanGetCapabilities(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303414 if (!HAL_STATUS_SUCCESS(status)) {
3415 hddLog(VOS_TRACE_LEVEL_ERROR,
3416 FL("sme_EXTScanGetCapabilities failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303417 return -EINVAL;
3418 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303419 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303420 return 0;
3421}
3422
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303423static int wlan_hdd_cfg80211_extscan_get_capabilities(struct wiphy *wiphy,
3424 struct wireless_dev *wdev,
3425 const void *data, int dataLen)
3426{
3427 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303428
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303429 vos_ssr_protect(__func__);
3430 ret = __wlan_hdd_cfg80211_extscan_get_capabilities(wiphy, wdev, data, dataLen);
3431 vos_ssr_unprotect(__func__);
3432
3433 return ret;
3434}
3435
3436static int __wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3437 struct wireless_dev *wdev,
3438 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303439{
Dino Myclee8843b32014-07-04 14:21:45 +05303440 tSirEXTScanGetCachedResultsReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303441 struct net_device *dev = wdev->netdev;
3442 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3443 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3444 struct nlattr
3445 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3446 eHalStatus status;
3447
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303448 ENTER();
3449
Dino Mycle6fb96c12014-06-10 11:52:40 +05303450 status = wlan_hdd_validate_context(pHddCtx);
3451 if (0 != status)
3452 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303453 return -EINVAL;
3454 }
Dino Myclee8843b32014-07-04 14:21:45 +05303455 /* check the EXTScan Capability */
3456 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3457 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3458 {
3459 hddLog(VOS_TRACE_LEVEL_ERROR,
3460 FL("EXTScan not enabled/supported by Firmware"));
3461 return -EINVAL;
3462 }
3463
Dino Mycle6fb96c12014-06-10 11:52:40 +05303464 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3465 data, dataLen,
3466 wlan_hdd_extscan_config_policy)) {
3467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3468 return -EINVAL;
3469 }
3470 /* Parse and fetch request Id */
3471 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3472 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3473 return -EINVAL;
3474 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303475
Dino Myclee8843b32014-07-04 14:21:45 +05303476 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303477 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3478
Dino Myclee8843b32014-07-04 14:21:45 +05303479 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303480
Dino Myclee8843b32014-07-04 14:21:45 +05303481 reqMsg.sessionId = pAdapter->sessionId;
3482 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303483
3484 /* Parse and fetch flush parameter */
3485 if (!tb
3486 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH])
3487 {
3488 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr flush failed"));
3489 goto failed;
3490 }
Dino Myclee8843b32014-07-04 14:21:45 +05303491 reqMsg.flush = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05303492 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_CACHED_SCAN_RESULTS_CONFIG_PARAM_FLUSH]);
3493
Dino Myclee8843b32014-07-04 14:21:45 +05303494 hddLog(VOS_TRACE_LEVEL_INFO, FL("Flush (%d)"), reqMsg.flush);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303495
Dino Myclee8843b32014-07-04 14:21:45 +05303496 status = sme_getCachedResults(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303497 if (!HAL_STATUS_SUCCESS(status)) {
3498 hddLog(VOS_TRACE_LEVEL_ERROR,
3499 FL("sme_getCachedResults failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05303500 return -EINVAL;
3501 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303502 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303503 return 0;
3504
3505failed:
Dino Mycle6fb96c12014-06-10 11:52:40 +05303506 return -EINVAL;
3507}
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303508static int wlan_hdd_cfg80211_extscan_get_cached_results(struct wiphy *wiphy,
3509 struct wireless_dev *wdev,
3510 const void *data, int dataLen)
3511{
3512 int ret = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303513
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303514 vos_ssr_protect(__func__);
3515 ret = __wlan_hdd_cfg80211_extscan_get_cached_results(wiphy, wdev, data, dataLen);
3516 vos_ssr_unprotect(__func__);
3517
3518 return ret;
3519}
3520
3521static int __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303522 struct wireless_dev *wdev,
Edhar, Mahesh Kumared8631f2015-01-20 14:31:47 +05303523 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303524{
3525 tpSirEXTScanSetBssidHotListReqParams pReqMsg = NULL;
3526 struct net_device *dev = wdev->netdev;
3527 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3528 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3529 struct nlattr
3530 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3531 struct nlattr
3532 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3533 struct nlattr *apTh;
3534 eHalStatus status;
3535 tANI_U8 i = 0;
3536 int rem;
3537
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303538 ENTER();
3539
Dino Mycle6fb96c12014-06-10 11:52:40 +05303540 status = wlan_hdd_validate_context(pHddCtx);
3541 if (0 != status)
3542 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303543 return -EINVAL;
3544 }
Dino Myclee8843b32014-07-04 14:21:45 +05303545 /* check the EXTScan Capability */
3546 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3547 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3548 {
3549 hddLog(VOS_TRACE_LEVEL_ERROR,
3550 FL("EXTScan not enabled/supported by Firmware"));
3551 return -EINVAL;
3552 }
3553
Dino Mycle6fb96c12014-06-10 11:52:40 +05303554 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3555 data, dataLen,
3556 wlan_hdd_extscan_config_policy)) {
3557 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3558 return -EINVAL;
3559 }
3560
3561 /* Parse and fetch request Id */
3562 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3563 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3564 return -EINVAL;
3565 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303566 pReqMsg = (tpSirEXTScanSetBssidHotListReqParams)
3567 vos_mem_malloc(sizeof(*pReqMsg));
3568 if (!pReqMsg) {
3569 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3570 return -ENOMEM;
3571 }
3572
Dino Myclee8843b32014-07-04 14:21:45 +05303573
Dino Mycle6fb96c12014-06-10 11:52:40 +05303574 pReqMsg->requestId = nla_get_u32(
3575 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3576 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3577
3578 /* Parse and fetch number of APs */
3579 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]) {
3580 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3581 goto fail;
3582 }
3583
3584 pReqMsg->sessionId = pAdapter->sessionId;
3585 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3586
3587 pReqMsg->numAp = nla_get_u32(
3588 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BSSID_HOTLIST_PARAMS_NUM_AP]);
3589 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3590
3591 nla_for_each_nested(apTh,
3592 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3593 if(nla_parse(tb2, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3594 nla_data(apTh), nla_len(apTh),
3595 NULL)) {
3596 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3597 goto fail;
3598 }
3599
3600 /* Parse and fetch MAC address */
3601 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3602 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3603 goto fail;
3604 }
3605 memcpy(pReqMsg->ap[i].bssid, nla_data(
3606 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3607 sizeof(tSirMacAddr));
3608 hddLog(VOS_TRACE_LEVEL_INFO, FL("BSSID: %pM "), pReqMsg->ap[i].bssid);
3609
3610 /* Parse and fetch low RSSI */
3611 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3612 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3613 goto fail;
3614 }
3615 pReqMsg->ap[i].low = nla_get_s32(
3616 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3617 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3618
3619 /* Parse and fetch high RSSI */
3620 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3621 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3622 goto fail;
3623 }
3624 pReqMsg->ap[i].high = nla_get_s32(
3625 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3626 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI High (%d)"),
3627 pReqMsg->ap[i].high);
3628
3629 /* Parse and fetch channel */
3630 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3631 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3632 goto fail;
3633 }
3634 pReqMsg->ap[i].channel = nla_get_u32(
3635 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3636 hddLog(VOS_TRACE_LEVEL_INFO,
3637 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3638 i++;
3639 }
3640 status = sme_SetBssHotlist(pHddCtx->hHal, pReqMsg);
3641 if (!HAL_STATUS_SUCCESS(status)) {
3642 hddLog(VOS_TRACE_LEVEL_ERROR,
3643 FL("sme_SetBssHotlist failed(err=%d)"), status);
3644 vos_mem_free(pReqMsg);
3645 return -EINVAL;
3646 }
3647
Dino Myclee8843b32014-07-04 14:21:45 +05303648 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303649 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303650 return 0;
3651
3652fail:
3653 vos_mem_free(pReqMsg);
3654 return -EINVAL;
3655}
3656
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303657static int wlan_hdd_cfg80211_extscan_set_bssid_hotlist(struct wiphy *wiphy,
3658 struct wireless_dev *wdev,
3659 const void *data, int dataLen)
3660{
3661 int ret = 0;
3662
3663 vos_ssr_protect(__func__);
3664 ret = __wlan_hdd_cfg80211_extscan_set_bssid_hotlist(wiphy, wdev, data,
3665 dataLen);
3666 vos_ssr_unprotect(__func__);
3667
3668 return ret;
3669}
3670
3671static int __wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303672 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303673 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303674{
3675 tpSirEXTScanSetSignificantChangeReqParams pReqMsg = NULL;
3676 struct net_device *dev = wdev->netdev;
3677 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3678 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3679 struct nlattr
3680 *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3681 struct nlattr
3682 *tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3683 struct nlattr *apTh;
3684 eHalStatus status;
3685 int i = 0;
3686 int rem;
3687
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303688 ENTER();
3689
Dino Mycle6fb96c12014-06-10 11:52:40 +05303690 status = wlan_hdd_validate_context(pHddCtx);
3691 if (0 != status)
3692 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303693 return -EINVAL;
3694 }
Dino Myclee8843b32014-07-04 14:21:45 +05303695 /* check the EXTScan Capability */
3696 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3697 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3698 {
3699 hddLog(VOS_TRACE_LEVEL_ERROR,
3700 FL("EXTScan not enabled/supported by Firmware"));
3701 return -EINVAL;
3702 }
3703
Dino Mycle6fb96c12014-06-10 11:52:40 +05303704 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3705 data, dataLen,
3706 wlan_hdd_extscan_config_policy)) {
3707 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3708 return -EINVAL;
3709 }
3710
3711 /* Parse and fetch request Id */
3712 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3713 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3714 return -EINVAL;
3715 }
Dino Mycle6fb96c12014-06-10 11:52:40 +05303716 pReqMsg = (tpSirEXTScanSetSignificantChangeReqParams)
Dino Myclee8843b32014-07-04 14:21:45 +05303717 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05303718 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05303719 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
3720 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303721 }
3722
Dino Myclee8843b32014-07-04 14:21:45 +05303723
3724
Dino Mycle6fb96c12014-06-10 11:52:40 +05303725 pReqMsg->requestId = nla_get_u32(
3726 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3727 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
3728
3729 /* Parse and fetch RSSI sample size */
3730 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE])
3731 {
3732 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr RSSI sample size failed"));
3733 goto fail;
3734 }
3735 pReqMsg->rssiSampleSize = nla_get_u32(
3736 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_RSSI_SAMPLE_SIZE]);
3737 hddLog(VOS_TRACE_LEVEL_INFO,
3738 FL("RSSI sample size (%u)"), pReqMsg->rssiSampleSize);
3739
3740 /* Parse and fetch lost AP sample size */
3741 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE])
3742 {
3743 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr lost AP sample size failed"));
3744 goto fail;
3745 }
3746 pReqMsg->lostApSampleSize = nla_get_u32(
3747 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_LOST_AP_SAMPLE_SIZE]);
3748 hddLog(VOS_TRACE_LEVEL_INFO,
3749 FL("Lost AP sample size (%u)"), pReqMsg->lostApSampleSize);
3750 /* Parse and fetch minimum Breaching */
3751 if (!tb
3752 [QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]) {
3753 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr minBreaching failed"));
3754 goto fail;
3755 }
3756 pReqMsg->minBreaching = nla_get_u32(
3757 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_MIN_BREACHING]);
3758 hddLog(VOS_TRACE_LEVEL_INFO, FL(" Breaching (%d)"), pReqMsg->minBreaching);
3759
3760 /* Parse and fetch number of APs */
3761 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]) {
3762 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of AP failed"));
3763 goto fail;
3764 }
3765 pReqMsg->numAp = nla_get_u32(
3766 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SIGNIFICANT_CHANGE_PARAMS_NUM_AP]);
3767 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of AP (%d)"), pReqMsg->numAp);
3768
3769 pReqMsg->sessionId = pAdapter->sessionId;
3770 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
3771
3772 nla_for_each_nested(apTh,
3773 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM], rem) {
3774 if(nla_parse(tb2,
3775 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3776 nla_data(apTh), nla_len(apTh),
3777 NULL)) {
3778 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
3779 goto fail;
3780 }
3781
3782 /* Parse and fetch MAC address */
3783 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]) {
3784 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac address failed"));
3785 goto fail;
3786 }
3787 memcpy(pReqMsg->ap[i].bssid, nla_data(
3788 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_BSSID]),
3789 sizeof(tSirMacAddr));
3790
3791 /* Parse and fetch low RSSI */
3792 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]) {
3793 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr low RSSI failed"));
3794 goto fail;
3795 }
3796 pReqMsg->ap[i].low = nla_get_s32(
3797 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_LOW]);
3798 hddLog(VOS_TRACE_LEVEL_INFO, FL("RSSI low (%d)"), pReqMsg->ap[i].low);
3799
3800 /* Parse and fetch high RSSI */
3801 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]) {
3802 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr high RSSI failed"));
3803 goto fail;
3804 }
3805 pReqMsg->ap[i].high = nla_get_s32(
3806 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_RSSI_HIGH]);
3807 hddLog(VOS_TRACE_LEVEL_INFO,
3808 FL("RSSI High (%d)"), pReqMsg->ap[i].high);
3809
3810 /* Parse and fetch channel */
3811 if (!tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]) {
3812 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
3813 goto fail;
3814 }
3815 pReqMsg->ap[i].channel = nla_get_u32(
3816 tb2[QCA_WLAN_VENDOR_ATTR_EXTSCAN_AP_THRESHOLD_PARAM_CHANNEL]);
3817 hddLog(VOS_TRACE_LEVEL_INFO,
3818 FL("Channel (%u)"), pReqMsg->ap[i].channel);
3819 i++;
3820 }
3821
3822 status = sme_SetSignificantChange(pHddCtx->hHal, pReqMsg);
3823 if (!HAL_STATUS_SUCCESS(status)) {
3824 hddLog(VOS_TRACE_LEVEL_ERROR,
3825 FL("sme_SetSignificantChange failed(err=%d)"), status);
3826 vos_mem_free(pReqMsg);
3827 return -EINVAL;
3828 }
Dino Myclee8843b32014-07-04 14:21:45 +05303829 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303830 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05303831 return 0;
3832
3833fail:
3834 vos_mem_free(pReqMsg);
3835 return -EINVAL;
3836}
3837
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303838static int wlan_hdd_cfg80211_extscan_set_significant_change(struct wiphy *wiphy,
3839 struct wireless_dev *wdev,
3840 const void *data, int dataLen)
3841{
3842 int ret = 0;
3843
3844 vos_ssr_protect(__func__);
3845 ret = __wlan_hdd_cfg80211_extscan_set_significant_change(wiphy, wdev, data,
3846 dataLen);
3847 vos_ssr_unprotect(__func__);
3848
3849 return ret;
3850}
3851
3852static int __wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303853 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303854 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303855{
3856 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3857 tANI_U32 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
3858 tANI_U8 numChannels = 0;
3859 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3860 tANI_U32 requestId;
3861 tWifiBand wifiBand;
3862 eHalStatus status;
3863 struct sk_buff *replySkb;
3864 tANI_U8 i;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303865 int ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303866
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303867 ENTER();
3868
Dino Mycle6fb96c12014-06-10 11:52:40 +05303869 status = wlan_hdd_validate_context(pHddCtx);
3870 if (0 != status)
3871 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303872 return -EINVAL;
3873 }
Dino Myclee8843b32014-07-04 14:21:45 +05303874 /* check the EXTScan Capability */
3875 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3876 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3877 {
3878 hddLog(VOS_TRACE_LEVEL_ERROR,
3879 FL("EXTScan not enabled/supported by Firmware"));
3880 return -EINVAL;
3881 }
3882
Dino Mycle6fb96c12014-06-10 11:52:40 +05303883 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3884 data, dataLen,
3885 wlan_hdd_extscan_config_policy)) {
3886 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3887 return -EINVAL;
3888 }
3889
3890 /* Parse and fetch request Id */
3891 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
3892 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
3893 return -EINVAL;
3894 }
3895 requestId = nla_get_u32(
3896 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
3897 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), requestId);
3898
3899 /* Parse and fetch wifi band */
3900 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND])
3901 {
3902 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
3903 return -EINVAL;
3904 }
3905 wifiBand = nla_get_u32(
3906 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_GET_VALID_CHANNELS_CONFIG_PARAM_WIFI_BAND]);
3907 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"), wifiBand);
3908
3909 status = sme_GetValidChannelsByBand((tHalHandle)(pHddCtx->hHal),
3910 wifiBand, ChannelList,
3911 &numChannels);
3912 if (eHAL_STATUS_SUCCESS != status) {
3913 hddLog(VOS_TRACE_LEVEL_ERROR,
3914 FL("sme_GetValidChannelsByBand failed (err=%d)"), status);
3915 return -EINVAL;
3916 }
3917 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of channels (%d)"), numChannels);
3918 for (i = 0; i < numChannels; i++)
3919 hddLog(VOS_TRACE_LEVEL_INFO, "Channel: %u ", ChannelList[i]);
3920
3921 replySkb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
3922 sizeof(u32) * numChannels +
3923 NLMSG_HDRLEN);
3924
3925 if (!replySkb) {
3926 hddLog(VOS_TRACE_LEVEL_ERROR,
3927 FL("valid channels: buffer alloc fail"));
3928 return -EINVAL;
3929 }
3930 if (nla_put_u32(replySkb,
3931 QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_NUM_CHANNELS,
3932 numChannels) ||
3933 nla_put(replySkb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_RESULTS_CHANNELS,
3934 sizeof(u32) * numChannels, ChannelList)) {
3935
3936 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
3937 kfree_skb(replySkb);
3938 return -EINVAL;
3939 }
3940
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303941 ret = cfg80211_vendor_cmd_reply(replySkb);
3942
3943 EXIT();
3944 return ret;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303945}
3946
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05303947static int wlan_hdd_cfg80211_extscan_get_valid_channels(struct wiphy *wiphy,
3948 struct wireless_dev *wdev,
3949 const void *data, int dataLen)
3950{
3951 int ret = 0;
3952
3953 vos_ssr_protect(__func__);
3954 ret = __wlan_hdd_cfg80211_extscan_get_valid_channels(wiphy, wdev, data,
3955 dataLen);
3956 vos_ssr_unprotect(__func__);
3957
3958 return ret;
3959}
3960
3961static int __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05303962 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05303963 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05303964{
Dino Myclee8843b32014-07-04 14:21:45 +05303965 tpSirEXTScanStartReqParams pReqMsg = NULL;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303966 struct net_device *dev = wdev->netdev;
3967 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3968 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
3969 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3970 struct nlattr *bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3971 struct nlattr *channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
3972 struct nlattr *buckets;
3973 struct nlattr *channels;
3974 int rem1;
3975 int rem2;
3976 eHalStatus status;
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05303977 tANI_U32 j = 0, index = 0;
Dino Mycle6fb96c12014-06-10 11:52:40 +05303978
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303979 ENTER();
3980
Dino Mycle6fb96c12014-06-10 11:52:40 +05303981 status = wlan_hdd_validate_context(pHddCtx);
3982 if (0 != status)
3983 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05303984 return -EINVAL;
3985 }
Dino Myclee8843b32014-07-04 14:21:45 +05303986 /* check the EXTScan Capability */
3987 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
3988 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
3989 {
3990 hddLog(VOS_TRACE_LEVEL_ERROR,
3991 FL("EXTScan not enabled/supported by Firmware"));
3992 return -EINVAL;
3993 }
3994
Dino Mycle6fb96c12014-06-10 11:52:40 +05303995 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
3996 data, dataLen,
3997 wlan_hdd_extscan_config_policy)) {
3998 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
3999 return -EINVAL;
4000 }
4001
4002 /* Parse and fetch request Id */
4003 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4004 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4005 return -EINVAL;
4006 }
4007
Dino Myclee8843b32014-07-04 14:21:45 +05304008 pReqMsg = (tpSirEXTScanStartReqParams)
4009 vos_mem_malloc(sizeof(*pReqMsg));
Dino Mycle6fb96c12014-06-10 11:52:40 +05304010 if (!pReqMsg) {
Dino Myclee8843b32014-07-04 14:21:45 +05304011 hddLog(VOS_TRACE_LEVEL_ERROR, FL("vos_mem_malloc failed"));
4012 return -ENOMEM;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304013 }
4014
4015 pReqMsg->requestId = nla_get_u32(
4016 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
4017 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), pReqMsg->requestId);
4018
4019 pReqMsg->sessionId = pAdapter->sessionId;
4020 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), pReqMsg->sessionId);
4021
4022 /* Parse and fetch base period */
4023 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]) {
4024 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr base period failed"));
4025 goto fail;
4026 }
4027 pReqMsg->basePeriod = nla_get_u32(
4028 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_BASE_PERIOD]);
4029 hddLog(VOS_TRACE_LEVEL_INFO, FL("Base Period (%d)"),
4030 pReqMsg->basePeriod);
4031
4032 /* Parse and fetch max AP per scan */
4033 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]) {
4034 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr max_ap_per_scan failed"));
4035 goto fail;
4036 }
4037 pReqMsg->maxAPperScan = nla_get_u32(
4038 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_MAX_AP_PER_SCAN]);
4039 hddLog(VOS_TRACE_LEVEL_INFO, FL("Max AP per Scan (%d)"),
4040 pReqMsg->maxAPperScan);
4041
4042 /* Parse and fetch report threshold */
4043 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]) {
4044 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report_threshold failed"));
4045 goto fail;
4046 }
4047 pReqMsg->reportThreshold = nla_get_u8(
4048 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_REPORT_THRESHOLD]);
4049 hddLog(VOS_TRACE_LEVEL_INFO, FL("Report Threshold (%d)"),
4050 pReqMsg->reportThreshold);
4051
4052 /* Parse and fetch number of buckets */
4053 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]) {
4054 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr number of buckets failed"));
4055 goto fail;
4056 }
4057 pReqMsg->numBuckets = nla_get_u8(
4058 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SCAN_CMD_PARAMS_NUM_BUCKETS]);
4059 if (pReqMsg->numBuckets > WLAN_EXTSCAN_MAX_BUCKETS) {
4060 hddLog(VOS_TRACE_LEVEL_WARN, FL("Exceeded MAX number of buckets "
4061 "Setting numBuckets to %u"), WLAN_EXTSCAN_MAX_BUCKETS);
4062 pReqMsg->numBuckets = WLAN_EXTSCAN_MAX_BUCKETS;
4063 }
4064 hddLog(VOS_TRACE_LEVEL_INFO, FL("Number of Buckets (%d)"),
4065 pReqMsg->numBuckets);
4066 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC]) {
4067 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket spec failed"));
4068 goto fail;
4069 }
4070
4071 nla_for_each_nested(buckets,
4072 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
4073 if(nla_parse(bucket,
4074 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4075 nla_data(buckets), nla_len(buckets), NULL)) { //policy
4076 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4077 goto fail;
4078 }
4079
4080 /* Parse and fetch bucket spec */
4081 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]) {
4082 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bucket index failed"));
4083 goto fail;
4084 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304085
4086 pReqMsg->buckets[index].bucket = nla_get_u8(
4087 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_INDEX]);
4088
4089 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bucket spec Index (%d)"),
4090 pReqMsg->buckets[index].bucket);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304091
4092 /* Parse and fetch wifi band */
4093 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]) {
4094 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr wifi band failed"));
4095 goto fail;
4096 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304097 pReqMsg->buckets[index].band = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304098 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_BAND]);
4099 hddLog(VOS_TRACE_LEVEL_INFO, FL("Wifi band (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304100 pReqMsg->buckets[index].band);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304101
4102 /* Parse and fetch period */
4103 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]) {
4104 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr period failed"));
4105 goto fail;
4106 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304107 pReqMsg->buckets[index].period = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304108 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_PERIOD]);
4109 hddLog(VOS_TRACE_LEVEL_INFO, FL("period (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304110 pReqMsg->buckets[index].period);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304111
4112 /* Parse and fetch report events */
4113 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]) {
4114 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr report events failed"));
4115 goto fail;
4116 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304117 pReqMsg->buckets[index].reportEvents = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304118 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_REPORT_EVENTS]);
4119 hddLog(VOS_TRACE_LEVEL_INFO, FL("report events (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304120 pReqMsg->buckets[index].reportEvents);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304121
4122 /* Parse and fetch number of channels */
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304123 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS])
4124 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304125 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr num channels failed"));
4126 goto fail;
4127 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304128 pReqMsg->buckets[index].numChannels = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304129 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC_NUM_CHANNEL_SPECS]);
4130 hddLog(VOS_TRACE_LEVEL_INFO, FL("num channels (%d)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304131 pReqMsg->buckets[index].numChannels);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304132
4133 if (!bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC]) {
4134 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel spec failed"));
4135 goto fail;
4136 }
4137
4138 j = 0;
4139 nla_for_each_nested(channels,
4140 bucket[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC], rem2) {
4141 if(nla_parse(channel,
4142 QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4143 nla_data(channels), nla_len(channels),
4144 NULL)) { //wlan_hdd_extscan_config_policy here
4145 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla_parse failed"));
4146 goto fail;
4147 }
4148
4149 /* Parse and fetch channel */
4150 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]) {
4151 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4152 goto fail;
4153 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304154 pReqMsg->buckets[index].channels[j].channel = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304155 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_CHANNEL]);
4156 hddLog(VOS_TRACE_LEVEL_INFO, FL("channel (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304157 pReqMsg->buckets[index].channels[j].channel);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304158
4159 /* Parse and fetch dwell time */
4160 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]) {
4161 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dwelltime failed"));
4162 goto fail;
4163 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304164 pReqMsg->buckets[index].channels[j].dwellTimeMs = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304165 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_DWELL_TIME]);
4166 hddLog(VOS_TRACE_LEVEL_INFO, FL("Dwell time (%u ms)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304167 pReqMsg->buckets[index].channels[j].dwellTimeMs);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304168
4169 /* Parse and fetch channel spec passive */
4170 if (!channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]) {
4171 hddLog(VOS_TRACE_LEVEL_ERROR,
4172 FL("attr channel spec passive failed"));
4173 goto fail;
4174 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304175 pReqMsg->buckets[index].channels[j].passive = nla_get_u8(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304176 channel[QCA_WLAN_VENDOR_ATTR_EXTSCAN_CHANNEL_SPEC_PASSIVE]);
4177 hddLog(VOS_TRACE_LEVEL_INFO, FL("Chnl spec passive (%u)"),
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304178 pReqMsg->buckets[index].channels[j].passive);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304179 j++;
4180 }
Dasari Srinivas8b2ce272014-09-16 16:57:30 +05304181 index++;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304182 }
4183 status = sme_EXTScanStart(pHddCtx->hHal, pReqMsg);
4184 if (!HAL_STATUS_SUCCESS(status)) {
4185 hddLog(VOS_TRACE_LEVEL_ERROR,
4186 FL("sme_EXTScanStart failed(err=%d)"), status);
4187 vos_mem_free(pReqMsg);
4188 return -EINVAL;
4189 }
4190
Dino Myclee8843b32014-07-04 14:21:45 +05304191 vos_mem_free(pReqMsg);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304192 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304193 return 0;
4194
4195fail:
4196 vos_mem_free(pReqMsg);
4197 return -EINVAL;
4198}
4199
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304200static int wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
4201 struct wireless_dev *wdev,
4202 const void *data, int dataLen)
4203{
4204 int ret = 0;
4205
4206 vos_ssr_protect(__func__);
4207 ret = __wlan_hdd_cfg80211_extscan_start(wiphy, wdev, data, dataLen);
4208 vos_ssr_unprotect(__func__);
4209
4210 return ret;
4211}
4212
4213static int __wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304214 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304215 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304216{
Dino Myclee8843b32014-07-04 14:21:45 +05304217 tSirEXTScanStopReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304218 struct net_device *dev = wdev->netdev;
4219 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4220 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4221 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4222 eHalStatus status;
4223
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304224 ENTER();
4225
Dino Mycle6fb96c12014-06-10 11:52:40 +05304226 status = wlan_hdd_validate_context(pHddCtx);
4227 if (0 != status)
4228 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304229 return -EINVAL;
4230 }
Dino Myclee8843b32014-07-04 14:21:45 +05304231 /* check the EXTScan Capability */
4232 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4233 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4234 {
4235 hddLog(VOS_TRACE_LEVEL_ERROR,
4236 FL("EXTScan not enabled/supported by Firmware"));
4237 return -EINVAL;
4238 }
4239
Dino Mycle6fb96c12014-06-10 11:52:40 +05304240 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4241 data, dataLen,
4242 wlan_hdd_extscan_config_policy)) {
4243 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4244 return -EINVAL;
4245 }
4246
4247 /* Parse and fetch request Id */
4248 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4249 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4250 return -EINVAL;
4251 }
4252
Dino Myclee8843b32014-07-04 14:21:45 +05304253 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304254 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304255 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304256
Dino Myclee8843b32014-07-04 14:21:45 +05304257 reqMsg.sessionId = pAdapter->sessionId;
4258 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304259
Dino Myclee8843b32014-07-04 14:21:45 +05304260 status = sme_EXTScanStop(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304261 if (!HAL_STATUS_SUCCESS(status)) {
4262 hddLog(VOS_TRACE_LEVEL_ERROR,
4263 FL("sme_EXTScanStop failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304264 return -EINVAL;
4265 }
4266
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304267 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304268 return 0;
4269}
4270
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304271static int wlan_hdd_cfg80211_extscan_stop(struct wiphy *wiphy,
4272 struct wireless_dev *wdev,
4273 const void *data, int dataLen)
4274{
4275 int ret = 0;
4276
4277 vos_ssr_protect(__func__);
4278 ret = __wlan_hdd_cfg80211_extscan_stop(wiphy, wdev, data, dataLen);
4279 vos_ssr_unprotect(__func__);
4280
4281 return ret;
4282}
4283
4284static int __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
Dino Mycle6fb96c12014-06-10 11:52:40 +05304285 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304286 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304287{
Dino Myclee8843b32014-07-04 14:21:45 +05304288 tSirEXTScanResetBssidHotlistReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304289 struct net_device *dev = wdev->netdev;
4290 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4291 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4292 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4293 eHalStatus status;
4294
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304295 ENTER();
4296
Dino Mycle6fb96c12014-06-10 11:52:40 +05304297 status = wlan_hdd_validate_context(pHddCtx);
4298 if (0 != status)
4299 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304300 return -EINVAL;
4301 }
Dino Myclee8843b32014-07-04 14:21:45 +05304302 /* check the EXTScan Capability */
4303 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4304 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4305 {
4306 hddLog(VOS_TRACE_LEVEL_ERROR,
4307 FL("EXTScan not enabled/supported by Firmware"));
4308 return -EINVAL;
4309 }
4310
Dino Mycle6fb96c12014-06-10 11:52:40 +05304311 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4312 data, dataLen,
4313 wlan_hdd_extscan_config_policy)) {
4314 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4315 return -EINVAL;
4316 }
4317
4318 /* Parse and fetch request Id */
4319 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4320 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4321 return -EINVAL;
4322 }
4323
Dino Myclee8843b32014-07-04 14:21:45 +05304324 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304325 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304326 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304327
Dino Myclee8843b32014-07-04 14:21:45 +05304328 reqMsg.sessionId = pAdapter->sessionId;
4329 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304330
Dino Myclee8843b32014-07-04 14:21:45 +05304331 status = sme_ResetBssHotlist(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304332 if (!HAL_STATUS_SUCCESS(status)) {
4333 hddLog(VOS_TRACE_LEVEL_ERROR,
4334 FL("sme_ResetBssHotlist failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304335 return -EINVAL;
4336 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304337 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304338 return 0;
4339}
4340
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304341static int wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(struct wiphy *wiphy,
4342 struct wireless_dev *wdev,
4343 const void *data, int dataLen)
4344{
4345 int ret = 0;
4346
4347 vos_ssr_protect(__func__);
4348 ret = __wlan_hdd_cfg80211_extscan_reset_bssid_hotlist(wiphy, wdev, data, dataLen);
4349 vos_ssr_unprotect(__func__);
4350
4351 return ret;
4352}
4353
4354static int __wlan_hdd_cfg80211_extscan_reset_significant_change(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304355 struct wiphy *wiphy,
4356 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304357 const void *data, int dataLen)
Dino Mycle6fb96c12014-06-10 11:52:40 +05304358{
Dino Myclee8843b32014-07-04 14:21:45 +05304359 tSirEXTScanResetSignificantChangeReqParams reqMsg;
Dino Mycle6fb96c12014-06-10 11:52:40 +05304360 struct net_device *dev = wdev->netdev;
4361 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4362 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4363 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX + 1];
4364 eHalStatus status;
4365
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304366 ENTER();
4367
Dino Mycle6fb96c12014-06-10 11:52:40 +05304368 status = wlan_hdd_validate_context(pHddCtx);
4369 if (0 != status)
4370 {
Dino Mycle6fb96c12014-06-10 11:52:40 +05304371 return -EINVAL;
4372 }
Dino Myclee8843b32014-07-04 14:21:45 +05304373 /* check the EXTScan Capability */
4374 if ( (TRUE != pHddCtx->cfg_ini->fEnableEXTScan) ||
4375 (TRUE != sme_IsFeatureSupportedByFW(EXTENDED_SCAN)))
4376 {
4377 hddLog(VOS_TRACE_LEVEL_ERROR,
4378 FL("EXTScan not enabled/supported by Firmware"));
4379 return -EINVAL;
4380 }
4381
Dino Mycle6fb96c12014-06-10 11:52:40 +05304382 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
4383 data, dataLen,
4384 wlan_hdd_extscan_config_policy)) {
4385 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4386 return -EINVAL;
4387 }
4388
4389 /* Parse and fetch request Id */
4390 if (!tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]) {
4391 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr request id failed"));
4392 return -EINVAL;
4393 }
4394
Dino Mycle6fb96c12014-06-10 11:52:40 +05304395
Dino Myclee8843b32014-07-04 14:21:45 +05304396 reqMsg.requestId = nla_get_u32(
Dino Mycle6fb96c12014-06-10 11:52:40 +05304397 tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_REQUEST_ID]);
Dino Myclee8843b32014-07-04 14:21:45 +05304398 hddLog(VOS_TRACE_LEVEL_INFO, FL("Req Id (%d)"), reqMsg.requestId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304399
Dino Myclee8843b32014-07-04 14:21:45 +05304400 reqMsg.sessionId = pAdapter->sessionId;
4401 hddLog(VOS_TRACE_LEVEL_INFO, FL("Session Id (%d)"), reqMsg.sessionId);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304402
Dino Myclee8843b32014-07-04 14:21:45 +05304403 status = sme_ResetSignificantChange(pHddCtx->hHal, &reqMsg);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304404 if (!HAL_STATUS_SUCCESS(status)) {
4405 hddLog(VOS_TRACE_LEVEL_ERROR,
4406 FL("sme_ResetSignificantChange failed(err=%d)"), status);
Dino Mycle6fb96c12014-06-10 11:52:40 +05304407 return -EINVAL;
4408 }
4409
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304410 EXIT();
Dino Mycle6fb96c12014-06-10 11:52:40 +05304411 return 0;
4412}
4413
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304414static int wlan_hdd_cfg80211_extscan_reset_significant_change(
4415 struct wiphy *wiphy,
4416 struct wireless_dev *wdev,
4417 const void *data, int dataLen)
4418{
4419 int ret = 0;
4420
4421 vos_ssr_protect(__func__);
4422 ret = __wlan_hdd_cfg80211_extscan_reset_significant_change(wiphy,
4423 wdev, data,
4424 dataLen);
4425 vos_ssr_unprotect(__func__);
4426
4427 return ret;
4428}
Dino Mycle6fb96c12014-06-10 11:52:40 +05304429#endif /* WLAN_FEATURE_EXTSCAN */
4430
Atul Mittal115287b2014-07-08 13:26:33 +05304431/*EXT TDLS*/
4432static const struct nla_policy
4433wlan_hdd_tdls_config_enable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX +1] =
4434{
4435 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4436 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL] = {.type = NLA_S32 },
4437 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS] =
4438 {.type = NLA_S32 },
4439 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS] = {.type = NLA_S32 },
4440 [QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS] = {.type = NLA_S32 },
4441
4442};
4443
4444static const struct nla_policy
4445wlan_hdd_tdls_config_disable_policy[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX +1] =
4446{
4447 [QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR] = {.type = NLA_UNSPEC },
4448
4449};
4450
4451static const struct nla_policy
4452wlan_hdd_tdls_config_state_change_policy[
4453 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAX +1] =
4454{
4455 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR] = {.type = NLA_UNSPEC },
4456 [QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE] = {.type = NLA_S32 },
4457 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304458 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL] = {.type = NLA_S32 },
4459 [QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS] =
4460 {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304461
4462};
4463
4464static const struct nla_policy
4465wlan_hdd_tdls_config_get_status_policy[
4466 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX +1] =
4467{
4468 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR] = {.type = NLA_UNSPEC },
4469 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE] = {.type = NLA_S32 },
4470 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON] = {.type = NLA_S32 },
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304471 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL] = {.type = NLA_S32 },
4472 [QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS]
4473 = {.type = NLA_S32 },
Atul Mittal115287b2014-07-08 13:26:33 +05304474
4475};
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304476
4477static const struct nla_policy
4478wlan_hdd_mac_config[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX+1] =
4479{
4480 [QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI] = {.type = NLA_UNSPEC },
4481};
4482
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304483static int __wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304484 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304485 const void *data,
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304486 int data_len)
4487{
4488
4489 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4490 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
4491
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304492 ENTER();
4493
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304494 if (0 != wlan_hdd_validate_context(pHddCtx)){
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304495 return -EINVAL;
4496 }
4497 if (FALSE == pHddCtx->cfg_ini->enableMacSpoofing) {
4498 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN disabled in ini"));
4499 return -ENOTSUPP;
Siddharth Bhal76972212014-10-15 16:22:51 +05304500 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304501 if (TRUE != sme_IsFeatureSupportedByFW(MAC_SPOOFED_SCAN)){
4502 hddLog(VOS_TRACE_LEVEL_ERROR, FL("MAC_SPOOFED_SCAN not supported by FW"));
4503 return -ENOTSUPP;
4504 }
4505
4506 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX,
4507 data, data_len, wlan_hdd_mac_config)) {
4508 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4509 return -EINVAL;
4510 }
4511
4512 /* Parse and fetch mac address */
4513 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
4514 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4515 return -EINVAL;
4516 }
4517
4518 memcpy(pHddCtx->spoofMacAddr.randomMacAddr.bytes, nla_data(
4519 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4520 VOS_MAC_ADDR_LAST_3_BYTES);
4521
Siddharth Bhal76972212014-10-15 16:22:51 +05304522 pHddCtx->spoofMacAddr.isEnabled = TRUE;
4523
4524 vos_trace_hex_dump( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, nla_data(
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304525 tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]),
4526 VOS_MAC_ADDR_FIRST_3_BYTES);
Siddharth Bhal76972212014-10-15 16:22:51 +05304527 if ((pHddCtx->spoofMacAddr.randomMacAddr.bytes[0] == 0) &&
4528 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[1] == 0) &&
4529 (pHddCtx->spoofMacAddr.randomMacAddr.bytes[2] == 0))
4530 {
4531 hddLog(LOG1, FL("ZERO MAC OUI Recieved. Disabling Spoofing"));
4532 vos_mem_zero(pHddCtx->spoofMacAddr.randomMacAddr.bytes,
4533 VOS_MAC_ADDRESS_LEN);
4534 pHddCtx->spoofMacAddr.isEnabled = FALSE;
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304535 }
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304536
Siddharth Bhal76972212014-10-15 16:22:51 +05304537 if (VOS_STATUS_SUCCESS != hdd_processSpoofMacAddrRequest(pHddCtx))
4538 {
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304539 hddLog(LOGE, FL("Failed to send Spoof Mac Addr to FW"));
4540 }
4541
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304542 EXIT();
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05304543 return 0;
4544}
4545
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304546static int wlan_hdd_cfg80211_set_spoofed_mac_oui(struct wiphy *wiphy,
4547 struct wireless_dev *wdev,
4548 const void *data,
4549 int data_len)
4550{
4551 int ret = 0;
4552
4553 vos_ssr_protect(__func__);
4554 ret = __wlan_hdd_cfg80211_set_spoofed_mac_oui(wiphy, wdev, data, data_len);
4555 vos_ssr_unprotect(__func__);
4556
4557 return ret;
4558}
4559
4560static int __wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304561 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304562 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304563 int data_len)
4564{
4565 u8 peer[6] = {0};
4566 struct net_device *dev = wdev->netdev;
4567 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4568 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4569 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX + 1];
4570 eHalStatus ret;
4571 tANI_S32 state;
4572 tANI_S32 reason;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304573 tANI_S32 global_operating_class = 0;
4574 tANI_S32 channel = 0;
Atul Mittal115287b2014-07-08 13:26:33 +05304575 struct sk_buff *skb = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304576 int retVal;
4577
4578 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304579
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304580 if (!pAdapter) {
4581 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4582 return -EINVAL;
4583 }
4584
Atul Mittal115287b2014-07-08 13:26:33 +05304585 ret = wlan_hdd_validate_context(pHddCtx);
4586 if (0 != ret) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304587 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304588 return -EINVAL;
4589 }
4590 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304591 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304592 return -ENOTSUPP;
4593 }
4594 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAX,
4595 data, data_len,
4596 wlan_hdd_tdls_config_get_status_policy)) {
4597 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4598 return -EINVAL;
4599 }
4600
4601 /* Parse and fetch mac address */
4602 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]) {
4603 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4604 return -EINVAL;
4605 }
4606
4607 memcpy(peer, nla_data(
4608 tb[QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_MAC_ADDR]),
4609 sizeof(peer));
4610 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4611
4612 ret = wlan_hdd_tdls_get_status(pAdapter, peer, &state, &reason);
4613
4614 if (0 != ret) {
4615 hddLog(VOS_TRACE_LEVEL_ERROR,
4616 FL("get status Failed"));
4617 return -EINVAL;
4618 }
4619 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304620 4 * sizeof(s32) +
Atul Mittal115287b2014-07-08 13:26:33 +05304621 NLMSG_HDRLEN);
4622
4623 if (!skb) {
4624 hddLog(VOS_TRACE_LEVEL_ERROR,
4625 FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
4626 return -EINVAL;
4627 }
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304628 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 +05304629 reason,
4630 state,
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304631 global_operating_class,
4632 channel,
Atul Mittal115287b2014-07-08 13:26:33 +05304633 MAC_ADDR_ARRAY(peer));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304634 if (nla_put_s32(skb,
4635 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_STATE,
4636 state) ||
4637 nla_put_s32(skb,
4638 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_REASON,
4639 reason) ||
4640 nla_put_s32(skb,
4641 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_GLOBAL_OPERATING_CLASS,
4642 global_operating_class) ||
4643 nla_put_s32(skb,
4644 QCA_WLAN_VENDOR_ATTR_TDLS_GET_STATUS_CHANNEL,
4645 channel)) {
Atul Mittal115287b2014-07-08 13:26:33 +05304646
4647 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4648 goto nla_put_failure;
4649 }
4650
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304651 retVal = cfg80211_vendor_cmd_reply(skb);
4652 EXIT();
4653 return retVal;
Atul Mittal115287b2014-07-08 13:26:33 +05304654
4655nla_put_failure:
4656 kfree_skb(skb);
4657 return -EINVAL;
4658}
4659
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304660static int wlan_hdd_cfg80211_exttdls_get_status(struct wiphy *wiphy,
4661 struct wireless_dev *wdev,
4662 const void *data,
4663 int data_len)
4664{
4665 int ret = 0;
4666
4667 vos_ssr_protect(__func__);
4668 ret = __wlan_hdd_cfg80211_exttdls_get_status(wiphy, wdev, data, data_len);
4669 vos_ssr_unprotect(__func__);
4670
4671 return ret;
4672}
4673
Atul Mittal115287b2014-07-08 13:26:33 +05304674static int wlan_hdd_cfg80211_exttdls_callback(tANI_U8* mac,
4675 tANI_S32 state,
4676 tANI_S32 reason,
4677 void *ctx)
4678{
4679 hdd_adapter_t* pAdapter = (hdd_adapter_t*)ctx;
Atul Mittal115287b2014-07-08 13:26:33 +05304680 struct sk_buff *skb = NULL;
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304681 tANI_S32 global_operating_class = 0;
4682 tANI_S32 channel = 0;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304683 hdd_context_t *pHddCtx;
Atul Mittal115287b2014-07-08 13:26:33 +05304684
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304685 ENTER();
4686
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304687 if (!pAdapter) {
4688 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4689 return -EINVAL;
4690 }
4691
4692 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +05304693 if (wlan_hdd_validate_context(pHddCtx)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304694 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304695 return -EINVAL;
4696 }
4697
4698 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304699 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304700 return -ENOTSUPP;
4701 }
4702 skb = cfg80211_vendor_event_alloc(
4703 pHddCtx->wiphy,
4704 EXTTDLS_EVENT_BUF_SIZE + NLMSG_HDRLEN,
4705 QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE_CHANGE_INDEX,
4706 GFP_KERNEL);
4707
4708 if (!skb) {
4709 hddLog(VOS_TRACE_LEVEL_ERROR,
4710 FL("cfg80211_vendor_event_alloc failed"));
4711 return -EINVAL;
4712 }
4713 hddLog(VOS_TRACE_LEVEL_INFO, FL("Entering "));
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304714 hddLog(VOS_TRACE_LEVEL_INFO, "Reason: (%d) Status: (%d) Class: (%d) Channel: (%d)",
4715 reason,
4716 state,
4717 global_operating_class,
4718 channel);
Atul Mittal115287b2014-07-08 13:26:33 +05304719 hddLog(VOS_TRACE_LEVEL_WARN, "tdls peer " MAC_ADDRESS_STR,
4720 MAC_ADDR_ARRAY(mac));
4721
Atul Mittal0a9f68d2014-10-16 15:26:38 +05304722 if (nla_put(skb,
4723 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_MAC_ADDR,
4724 VOS_MAC_ADDR_SIZE, mac) ||
4725 nla_put_s32(skb,
4726 QCA_WLAN_VENDOR_ATTR_TDLS_NEW_STATE,
4727 state) ||
4728 nla_put_s32(skb,
4729 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_REASON,
4730 reason) ||
4731 nla_put_s32(skb,
4732 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_CHANNEL,
4733 channel) ||
4734 nla_put_s32(skb,
4735 QCA_WLAN_VENDOR_ATTR_TDLS_STATE_GLOBAL_OPERATING_CLASS,
4736 global_operating_class)
4737 ) {
Atul Mittal115287b2014-07-08 13:26:33 +05304738 hddLog(VOS_TRACE_LEVEL_ERROR, FL("nla put fail"));
4739 goto nla_put_failure;
4740 }
4741
4742 cfg80211_vendor_event(skb, GFP_KERNEL);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304743 EXIT();
Atul Mittal115287b2014-07-08 13:26:33 +05304744 return (0);
4745
4746nla_put_failure:
4747 kfree_skb(skb);
4748 return -EINVAL;
4749}
4750
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304751static int __wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304752 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304753 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304754 int data_len)
4755{
4756 u8 peer[6] = {0};
4757 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304758 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4759 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX + 1];
4760 eHalStatus status;
4761 tdls_req_params_t pReqMsg = {0};
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304762 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304763 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304764
4765 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304766
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304767 if (!dev) {
4768 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4769 return -EINVAL;
4770 }
4771
4772 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4773 if (!pAdapter) {
4774 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
4775 return -EINVAL;
4776 }
4777
Atul Mittal115287b2014-07-08 13:26:33 +05304778 status = wlan_hdd_validate_context(pHddCtx);
4779 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304780 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304781 return -EINVAL;
4782 }
4783 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304784 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304785 return -ENOTSUPP;
4786 }
4787 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX,
4788 data, data_len,
4789 wlan_hdd_tdls_config_enable_policy)) {
4790 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4791 return -EINVAL;
4792 }
4793
4794 /* Parse and fetch mac address */
4795 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]) {
4796 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4797 return -EINVAL;
4798 }
4799
4800 memcpy(peer, nla_data(
4801 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAC_ADDR]),
4802 sizeof(peer));
4803 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4804
4805 /* Parse and fetch channel */
4806 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]) {
4807 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr channel failed"));
4808 return -EINVAL;
4809 }
4810 pReqMsg.channel = nla_get_s32(
4811 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_CHANNEL]);
4812 hddLog(VOS_TRACE_LEVEL_INFO, FL("Channel Num (%d)"), pReqMsg.channel);
4813
4814 /* Parse and fetch global operating class */
4815 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]) {
4816 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr operating class failed"));
4817 return -EINVAL;
4818 }
4819 pReqMsg.global_operating_class = nla_get_s32(
4820 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_GLOBAL_OPERATING_CLASS]);
4821 hddLog(VOS_TRACE_LEVEL_INFO, FL("Operating class (%d)"),
4822 pReqMsg.global_operating_class);
4823
4824 /* Parse and fetch latency ms */
4825 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]) {
4826 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr latency failed"));
4827 return -EINVAL;
4828 }
4829 pReqMsg.max_latency_ms = nla_get_s32(
4830 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MAX_LATENCY_MS]);
4831 hddLog(VOS_TRACE_LEVEL_INFO, FL("Latency (%d)"),
4832 pReqMsg.max_latency_ms);
4833
4834 /* Parse and fetch required bandwidth kbps */
4835 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]) {
4836 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bandwidth failed"));
4837 return -EINVAL;
4838 }
4839
4840 pReqMsg.min_bandwidth_kbps = nla_get_s32(
4841 tb[QCA_WLAN_VENDOR_ATTR_TDLS_ENABLE_MIN_BANDWIDTH_KBPS]);
4842 hddLog(VOS_TRACE_LEVEL_INFO, FL("Bandwidth (%d)"),
4843 pReqMsg.min_bandwidth_kbps);
4844
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304845 ret = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
Atul Mittal115287b2014-07-08 13:26:33 +05304846 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +05304847 &pReqMsg,
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304848 wlan_hdd_cfg80211_exttdls_callback);
4849
4850 EXIT();
4851 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304852}
4853
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304854static int wlan_hdd_cfg80211_exttdls_enable(struct wiphy *wiphy,
4855 struct wireless_dev *wdev,
4856 const void *data,
4857 int data_len)
4858{
4859 int ret = 0;
4860
4861 vos_ssr_protect(__func__);
4862 ret = __wlan_hdd_cfg80211_exttdls_enable(wiphy, wdev, data, data_len);
4863 vos_ssr_unprotect(__func__);
4864
4865 return ret;
4866}
4867
4868static int __wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
Atul Mittal115287b2014-07-08 13:26:33 +05304869 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304870 const void *data,
Atul Mittal115287b2014-07-08 13:26:33 +05304871 int data_len)
4872{
4873 u8 peer[6] = {0};
4874 struct net_device *dev = wdev->netdev;
Atul Mittal115287b2014-07-08 13:26:33 +05304875 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4876 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX + 1];
4877 eHalStatus status;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304878 int ret;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304879 hdd_adapter_t *pAdapter;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304880
4881 ENTER();
Atul Mittal115287b2014-07-08 13:26:33 +05304882
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05304883 if (!dev) {
4884 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
4885 return -EINVAL;
4886 }
4887
4888 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4889 if (!pAdapter) {
4890 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
4891 return -EINVAL;
4892 }
4893
Atul Mittal115287b2014-07-08 13:26:33 +05304894 status = wlan_hdd_validate_context(pHddCtx);
4895 if (0 != status) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304896 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
Atul Mittal115287b2014-07-08 13:26:33 +05304897 return -EINVAL;
4898 }
4899 if (pHddCtx->cfg_ini->fTDLSExternalControl == FALSE) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05304900 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS external control is disabled"));
Atul Mittal115287b2014-07-08 13:26:33 +05304901 return -ENOTSUPP;
4902 }
4903 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAX,
4904 data, data_len,
4905 wlan_hdd_tdls_config_disable_policy)) {
4906 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
4907 return -EINVAL;
4908 }
4909 /* Parse and fetch mac address */
4910 if (!tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]) {
4911 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr mac addr failed"));
4912 return -EINVAL;
4913 }
4914
4915 memcpy(peer, nla_data(
4916 tb[QCA_WLAN_VENDOR_ATTR_TDLS_DISABLE_MAC_ADDR]),
4917 sizeof(peer));
4918 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(peer));
4919
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304920 ret = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
4921
4922 EXIT();
4923 return ret;
Atul Mittal115287b2014-07-08 13:26:33 +05304924}
4925
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304926static int wlan_hdd_cfg80211_exttdls_disable(struct wiphy *wiphy,
4927 struct wireless_dev *wdev,
4928 const void *data,
4929 int data_len)
4930{
4931 int ret = 0;
4932
4933 vos_ssr_protect(__func__);
4934 ret = __wlan_hdd_cfg80211_exttdls_disable(wiphy, wdev, data, data_len);
4935 vos_ssr_unprotect(__func__);
4936
4937 return ret;
4938}
4939
Dasari Srinivas7875a302014-09-26 17:50:57 +05304940static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304941__wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
Dasari Srinivas7875a302014-09-26 17:50:57 +05304942 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05304943 const void *data, int data_len)
Dasari Srinivas7875a302014-09-26 17:50:57 +05304944{
4945 struct net_device *dev = wdev->netdev;
4946 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4947 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
4948 struct sk_buff *skb = NULL;
4949 tANI_U32 fset = 0;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304950 int ret = 0;
Dasari Srinivas7875a302014-09-26 17:50:57 +05304951
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304952 ENTER();
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304953
4954 ret = wlan_hdd_validate_context(pHddCtx);
4955 if (0 != ret)
4956 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05304957 return ret;
4958 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304959 if (wiphy->interface_modes & BIT(NL80211_IFTYPE_STATION)) {
4960 hddLog(LOG1, FL("Infra Station mode is supported by driver"));
4961 fset |= WIFI_FEATURE_INFRA;
4962 }
4963
4964 if (TRUE == hdd_is_5g_supported(pHddCtx)) {
4965 hddLog(LOG1, FL("INFRA_5G is supported by firmware"));
4966 fset |= WIFI_FEATURE_INFRA_5G;
4967 }
4968
4969#ifdef WLAN_FEATURE_P2P
4970 if ((wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) &&
4971 (wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_GO))) {
4972 hddLog(LOG1, FL("WiFi-Direct is supported by driver"));
4973 fset |= WIFI_FEATURE_P2P;
4974 }
4975#endif
4976
4977 /* Soft-AP is supported currently by default */
4978 fset |= WIFI_FEATURE_SOFT_AP;
4979
Kanchanapally, Vidyullatha683aed02015-03-24 16:58:38 +05304980 /* HOTSPOT is a supplicant feature, enable it by default */
4981 fset |= WIFI_FEATURE_HOTSPOT;
4982
Dasari Srinivas7875a302014-09-26 17:50:57 +05304983#ifdef WLAN_FEATURE_EXTSCAN
4984 if ((TRUE == pHddCtx->cfg_ini->fEnableEXTScan) &&
4985 sme_IsFeatureSupportedByFW(EXTENDED_SCAN)) {
4986 hddLog(LOG1, FL("EXTScan is supported by firmware"));
4987 fset |= WIFI_FEATURE_EXTSCAN;
4988 }
4989#endif
4990
Dasari Srinivas7875a302014-09-26 17:50:57 +05304991 if (sme_IsFeatureSupportedByFW(NAN)) {
4992 hddLog(LOG1, FL("NAN is supported by firmware"));
4993 fset |= WIFI_FEATURE_NAN;
4994 }
Dasari Srinivas7875a302014-09-26 17:50:57 +05304995
4996 /* D2D RTT is not supported currently by default */
4997 if (sme_IsFeatureSupportedByFW(RTT)) {
4998 hddLog(LOG1, FL("RTT is supported by firmware"));
4999 fset |= WIFI_FEATURE_D2AP_RTT;
5000 }
5001
5002#ifdef FEATURE_WLAN_BATCH_SCAN
5003 if (fset & WIFI_FEATURE_EXTSCAN) {
5004 hddLog(LOG1, FL("Batch scan is supported as extscan is supported"));
5005 fset &= ~WIFI_FEATURE_BATCH_SCAN;
5006 } else if (sme_IsFeatureSupportedByFW(BATCH_SCAN)) {
5007 hddLog(LOG1, FL("Batch scan is supported by firmware"));
5008 fset |= WIFI_FEATURE_BATCH_SCAN;
5009 }
5010#endif
5011
5012#ifdef FEATURE_WLAN_SCAN_PNO
5013 if (pHddCtx->cfg_ini->configPNOScanSupport &&
5014 (eHAL_STATUS_SUCCESS == wlan_hdd_is_pno_allowed(pAdapter))) {
5015 hddLog(LOG1, FL("PNO is supported by firmware"));
5016 fset |= WIFI_FEATURE_PNO;
5017 }
5018#endif
5019
5020 /* STA+STA is supported currently by default */
5021 fset |= WIFI_FEATURE_ADDITIONAL_STA;
5022
5023#ifdef FEATURE_WLAN_TDLS
5024 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
5025 sme_IsFeatureSupportedByFW(TDLS)) {
5026 hddLog(LOG1, FL("TDLS is supported by firmware"));
5027 fset |= WIFI_FEATURE_TDLS;
5028 }
5029
5030 /* TDLS_OFFCHANNEL is not supported currently by default */
5031#endif
5032
5033#ifdef WLAN_AP_STA_CONCURRENCY
5034 /* AP+STA concurrency is supported currently by default */
5035 fset |= WIFI_FEATURE_AP_STA;
5036#endif
5037
5038 skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(fset) +
5039 NLMSG_HDRLEN);
5040
5041 if (!skb) {
5042 hddLog(LOGE, FL("cfg80211_vendor_cmd_alloc_reply_skb failed"));
5043 return -EINVAL;
5044 }
5045 hddLog(LOG1, FL("Supported Features : 0x%x"), fset);
5046
5047 if (nla_put_u32(skb, QCA_WLAN_VENDOR_ATTR_FEATURE_SET, fset)) {
5048 hddLog(LOGE, FL("nla put fail"));
5049 goto nla_put_failure;
5050 }
5051
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305052 ret = cfg80211_vendor_cmd_reply(skb);
5053 EXIT();
5054 return ret;
Dasari Srinivas7875a302014-09-26 17:50:57 +05305055
5056nla_put_failure:
5057 kfree_skb(skb);
5058 return -EINVAL;
5059}
5060
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305061static int
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305062wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
5063 struct wireless_dev *wdev,
5064 const void *data, int data_len)
5065{
5066 int ret = 0;
5067
5068 vos_ssr_protect(__func__);
5069 ret = __wlan_hdd_cfg80211_get_supported_features(wiphy, wdev, data, data_len);
5070 vos_ssr_unprotect(__func__);
5071
5072 return ret;
5073}
5074
5075static int
5076__wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305077 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305078 const void *data, int data_len)
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305079{
5080 uint32_t feature_set_matrix[WLAN_HDD_MAX_FEATURE_SET] = {0};
5081 uint8_t i, feature_sets, max_feature_sets;
5082 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX + 1];
5083 struct sk_buff *reply_skb;
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305084 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5085 int ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305086
5087 ENTER();
5088
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305089 ret = wlan_hdd_validate_context(pHddCtx);
5090 if (0 != ret)
5091 {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305092 return ret;
5093 }
5094
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305095 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_MAX,
5096 data, data_len, NULL)) {
5097 hddLog(LOGE, FL("Invalid ATTR"));
5098 return -EINVAL;
5099 }
5100
5101 /* Parse and fetch max feature set */
5102 if (!tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]) {
5103 hddLog(LOGE, FL("Attr max feature set size failed"));
5104 return -EINVAL;
5105 }
5106 max_feature_sets = nla_get_u32(
5107 tb[QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_CONFIG_PARAM_SET_SIZE_MAX]);
5108 hddLog(LOG1, FL("Max feature set size (%d)"), max_feature_sets);
5109
5110 /* Fill feature combination matrix */
5111 feature_sets = 0;
5112 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5113 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5114 WIFI_FEATURE_P2P;
5115
5116 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5117 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5118 WIFI_FEATURE_SOFT_AP;
5119
5120 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5121 feature_set_matrix[feature_sets++] = WIFI_FEATURE_P2P |
5122 WIFI_FEATURE_SOFT_AP;
5123
5124 if (feature_sets >= WLAN_HDD_MAX_FEATURE_SET) goto max_buffer_err;
5125 feature_set_matrix[feature_sets++] = WIFI_FEATURE_INFRA |
5126 WIFI_FEATURE_SOFT_AP |
5127 WIFI_FEATURE_P2P;
5128
5129 /* Add more feature combinations here */
5130
5131 feature_sets = VOS_MIN(feature_sets, max_feature_sets);
5132 hddLog(LOG1, FL("Number of feature sets (%d)"), feature_sets);
5133 hddLog(LOG1, "Feature set matrix");
5134 for (i = 0; i < feature_sets; i++)
5135 hddLog(LOG1, "[%d] 0x%02X", i, feature_set_matrix[i]);
5136
5137 reply_skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(u32) +
5138 sizeof(u32) * feature_sets +
5139 NLMSG_HDRLEN);
5140
5141 if (reply_skb) {
5142 if (nla_put_u32(reply_skb,
5143 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET_SIZE,
5144 feature_sets) ||
5145 nla_put(reply_skb,
5146 QCA_WLAN_VENDOR_ATTR_GET_CONCURRENCY_MATRIX_RESULTS_SET,
5147 sizeof(u32) * feature_sets, feature_set_matrix)) {
5148 hddLog(LOGE, FL("nla put fail"));
5149 kfree_skb(reply_skb);
5150 return -EINVAL;
5151 }
5152
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305153 ret = cfg80211_vendor_cmd_reply(reply_skb);
5154 EXIT();
5155 return ret;
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305156 }
5157 hddLog(LOGE, FL("Feature set matrix: buffer alloc fail"));
5158 return -ENOMEM;
5159
5160max_buffer_err:
5161 hddLog(LOGE, FL("Feature set max buffer size reached. feature_sets(%d) max(%d)"),
5162 feature_sets, WLAN_HDD_MAX_FEATURE_SET);
5163 return -EINVAL;
5164}
5165
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305166static int
5167wlan_hdd_cfg80211_get_concurrency_matrix(struct wiphy *wiphy,
5168 struct wireless_dev *wdev,
5169 const void *data, int data_len)
5170{
5171 int ret = 0;
5172
5173 vos_ssr_protect(__func__);
5174 ret = __wlan_hdd_cfg80211_get_concurrency_matrix(wiphy, wdev, data,
5175 data_len);
5176 vos_ssr_unprotect(__func__);
5177
5178 return ret;
5179}
5180
Agarwal Ashish738843c2014-09-25 12:27:56 +05305181static const struct nla_policy
5182wlan_hdd_set_no_dfs_flag_config_policy[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX
5183 +1] =
5184{
5185 [QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG] = {.type = NLA_U32 },
5186};
5187
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305188static int __wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305189 struct wireless_dev *wdev,
Jeff Johnson393c2702014-12-16 11:09:35 +05305190 const void *data,
Agarwal Ashish738843c2014-09-25 12:27:56 +05305191 int data_len)
5192{
5193 struct net_device *dev = wdev->netdev;
5194 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5195 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5196 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5197 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX + 1];
5198 eHalStatus status;
5199 u32 dfsFlag = 0;
5200
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305201 ENTER();
5202
Agarwal Ashish738843c2014-09-25 12:27:56 +05305203 status = wlan_hdd_validate_context(pHddCtx);
5204 if (0 != status) {
Agarwal Ashish738843c2014-09-25 12:27:56 +05305205 return -EINVAL;
5206 }
5207 if (nla_parse(tb, QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG_MAX,
5208 data, data_len,
5209 wlan_hdd_set_no_dfs_flag_config_policy)) {
5210 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5211 return -EINVAL;
5212 }
5213
5214 /* Parse and fetch required bandwidth kbps */
5215 if (!tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]) {
5216 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr dfs flag failed"));
5217 return -EINVAL;
5218 }
5219
5220 dfsFlag = nla_get_u32(
5221 tb[QCA_WLAN_VENDOR_ATTR_SET_NO_DFS_FLAG]);
5222 hddLog(VOS_TRACE_LEVEL_INFO, FL(" DFS flag (%d)"),
5223 dfsFlag);
5224
5225 pHddCtx->disable_dfs_flag = dfsFlag;
5226
5227 sme_disable_dfs_channel(hHal, dfsFlag);
5228 sme_FilterScanResults(hHal, pAdapter->sessionId);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305229
5230 EXIT();
Agarwal Ashish738843c2014-09-25 12:27:56 +05305231 return 0;
5232}
Atul Mittal115287b2014-07-08 13:26:33 +05305233
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305234static int wlan_hdd_cfg80211_disable_dfs_channels(struct wiphy *wiphy,
5235 struct wireless_dev *wdev,
5236 const void *data,
5237 int data_len)
5238{
5239 int ret = 0;
5240
5241 vos_ssr_protect(__func__);
5242 ret = __wlan_hdd_cfg80211_disable_dfs_channels(wiphy, wdev, data, data_len);
5243 vos_ssr_unprotect(__func__);
5244
5245 return ret;
5246
5247}
5248
Mukul Sharma2a271632014-10-13 14:59:01 +05305249const struct
5250nla_policy qca_wlan_vendor_attr[QCA_WLAN_VENDOR_ATTR_MAX+1] =
5251{
5252 [QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY] = { .type = NLA_U32 },
5253 [QCA_WLAN_VENDOR_ATTR_MAC_ADDR] = { .type = NLA_UNSPEC },
5254};
5255
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305256static int __wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
Jeff Johnson393c2702014-12-16 11:09:35 +05305257 struct wireless_dev *wdev, const void *data, int data_len)
Mukul Sharma2a271632014-10-13 14:59:01 +05305258{
5259
5260 u8 bssid[6] = {0};
5261 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5262 struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_MAX + 1];
5263 eHalStatus status = eHAL_STATUS_SUCCESS;
5264 v_U32_t isFwrRoamEnabled = FALSE;
5265 int ret;
5266
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305267 ENTER();
5268
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305269 ret = wlan_hdd_validate_context(pHddCtx);
5270 if (0 != ret) {
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305271 return ret;
Mukul Sharma2a271632014-10-13 14:59:01 +05305272 }
5273
5274 ret = nla_parse(tb, QCA_WLAN_VENDOR_ATTR_MAX,
5275 data, data_len,
5276 qca_wlan_vendor_attr);
5277 if (ret){
5278 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid ATTR"));
5279 return -EINVAL;
5280 }
5281
5282 /* Parse and fetch Enable flag */
5283 if (!tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]) {
5284 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr enable failed"));
5285 return -EINVAL;
5286 }
5287
5288 isFwrRoamEnabled = nla_get_u32(
5289 tb[QCA_WLAN_VENDOR_ATTR_ROAMING_POLICY]);
5290
5291 hddLog(VOS_TRACE_LEVEL_INFO, FL("isFwrRoamEnabled (%d)"), isFwrRoamEnabled);
5292
5293 /* Parse and fetch bssid */
5294 if (!tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]) {
5295 hddLog(VOS_TRACE_LEVEL_ERROR, FL("attr bss id failed"));
5296 return -EINVAL;
5297 }
5298
5299 memcpy(bssid, nla_data(
5300 tb[QCA_WLAN_VENDOR_ATTR_MAC_ADDR]),
5301 sizeof(bssid));
5302 hddLog(VOS_TRACE_LEVEL_INFO, FL(MAC_ADDRESS_STR),MAC_ADDR_ARRAY(bssid));
5303
5304 //Update roaming
5305 status = sme_ConfigFwrRoaming((tHalHandle)(pHddCtx->hHal), isFwrRoamEnabled);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305306 EXIT();
Mukul Sharma2a271632014-10-13 14:59:01 +05305307 return status;
5308}
5309
Mahesh A Saptasagare5440c72015-01-28 21:21:07 +05305310static int wlan_hdd_cfg80211_firmware_roaming(struct wiphy *wiphy,
5311 struct wireless_dev *wdev, const void *data, int data_len)
5312{
5313 int ret = 0;
5314
5315 vos_ssr_protect(__func__);
5316 ret = __wlan_hdd_cfg80211_firmware_roaming(wiphy, wdev, data, data_len);
5317 vos_ssr_unprotect(__func__);
5318
5319 return ret;
5320}
5321
Sunil Duttc69bccb2014-05-26 21:30:20 +05305322const struct wiphy_vendor_command hdd_wiphy_vendor_commands[] =
5323{
Mukul Sharma2a271632014-10-13 14:59:01 +05305324 {
5325 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5326 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_ROAMING,
5327 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5328 WIPHY_VENDOR_CMD_NEED_NETDEV |
5329 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305330 .doit = wlan_hdd_cfg80211_firmware_roaming
Mukul Sharma2a271632014-10-13 14:59:01 +05305331 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305332
5333 {
5334 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5335 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN,
5336 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5337 WIPHY_VENDOR_CMD_NEED_NETDEV |
5338 WIPHY_VENDOR_CMD_NEED_RUNNING,
5339 .doit = wlan_hdd_cfg80211_nan_request
5340 },
5341
Sunil Duttc69bccb2014-05-26 21:30:20 +05305342#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5343 {
5344 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5345 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR,
5346 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5347 WIPHY_VENDOR_CMD_NEED_NETDEV |
5348 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305349 .doit = wlan_hdd_cfg80211_ll_stats_clear
Sunil Duttc69bccb2014-05-26 21:30:20 +05305350 },
5351
5352 {
5353 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5354 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET,
5355 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5356 WIPHY_VENDOR_CMD_NEED_NETDEV |
5357 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305358 .doit = wlan_hdd_cfg80211_ll_stats_set
Sunil Duttc69bccb2014-05-26 21:30:20 +05305359 },
5360
5361 {
5362 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5363 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET,
5364 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5365 WIPHY_VENDOR_CMD_NEED_NETDEV |
5366 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305367 .doit = wlan_hdd_cfg80211_ll_stats_get
Dino Mycle6fb96c12014-06-10 11:52:40 +05305368 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305369#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305370#ifdef WLAN_FEATURE_EXTSCAN
5371 {
5372 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5373 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START,
5374 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5375 WIPHY_VENDOR_CMD_NEED_NETDEV |
5376 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305377 .doit = wlan_hdd_cfg80211_extscan_start
Dino Mycle6fb96c12014-06-10 11:52:40 +05305378 },
5379 {
5380 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5381 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP,
5382 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5383 WIPHY_VENDOR_CMD_NEED_NETDEV |
5384 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305385 .doit = wlan_hdd_cfg80211_extscan_stop
Dino Mycle6fb96c12014-06-10 11:52:40 +05305386 },
5387 {
5388 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5389 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_VALID_CHANNELS,
5390 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5391 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305392 .doit = wlan_hdd_cfg80211_extscan_get_valid_channels
Dino Mycle6fb96c12014-06-10 11:52:40 +05305393 },
5394 {
5395 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5396 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES,
5397 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5398 WIPHY_VENDOR_CMD_NEED_NETDEV |
5399 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305400 .doit = wlan_hdd_cfg80211_extscan_get_capabilities
Dino Mycle6fb96c12014-06-10 11:52:40 +05305401 },
5402 {
5403 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5404 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS,
5405 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5406 WIPHY_VENDOR_CMD_NEED_NETDEV |
5407 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305408 .doit = wlan_hdd_cfg80211_extscan_get_cached_results
Dino Mycle6fb96c12014-06-10 11:52:40 +05305409 },
5410 {
5411 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5412 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST,
5413 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5414 WIPHY_VENDOR_CMD_NEED_NETDEV |
5415 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305416 .doit = wlan_hdd_cfg80211_extscan_set_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305417 },
5418 {
5419 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5420 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST,
5421 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5422 WIPHY_VENDOR_CMD_NEED_NETDEV |
5423 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305424 .doit = wlan_hdd_cfg80211_extscan_reset_bssid_hotlist
Dino Mycle6fb96c12014-06-10 11:52:40 +05305425 },
5426 {
5427 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5428 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE,
5429 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5430 WIPHY_VENDOR_CMD_NEED_NETDEV |
5431 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305432 .doit = wlan_hdd_cfg80211_extscan_set_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305433 },
5434 {
5435 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5436 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE,
5437 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5438 WIPHY_VENDOR_CMD_NEED_NETDEV |
5439 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305440 .doit = wlan_hdd_cfg80211_extscan_reset_significant_change
Dino Mycle6fb96c12014-06-10 11:52:40 +05305441 },
5442#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305443/*EXT TDLS*/
5444 {
5445 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5446 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_ENABLE,
5447 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5448 WIPHY_VENDOR_CMD_NEED_NETDEV |
5449 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305450 .doit = wlan_hdd_cfg80211_exttdls_enable
Atul Mittal115287b2014-07-08 13:26:33 +05305451 },
5452 {
5453 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5454 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_DISABLE,
5455 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5456 WIPHY_VENDOR_CMD_NEED_NETDEV |
5457 WIPHY_VENDOR_CMD_NEED_RUNNING,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305458 .doit = wlan_hdd_cfg80211_exttdls_disable
Atul Mittal115287b2014-07-08 13:26:33 +05305459 },
5460 {
5461 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5462 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_GET_STATUS,
5463 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5464 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305465 .doit = wlan_hdd_cfg80211_exttdls_get_status
Atul Mittal115287b2014-07-08 13:26:33 +05305466 },
Dasari Srinivas7875a302014-09-26 17:50:57 +05305467 {
5468 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5469 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_SUPPORTED_FEATURES,
5470 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5471 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305472 .doit = wlan_hdd_cfg80211_get_supported_features
Dasari Srinivas7875a302014-09-26 17:50:57 +05305473 },
Agarwal Ashish738843c2014-09-25 12:27:56 +05305474 {
5475 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5476 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_NO_DFS_FLAG,
5477 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5478 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305479 .doit = wlan_hdd_cfg80211_disable_dfs_channels
Agarwal Ashish738843c2014-09-25 12:27:56 +05305480 },
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305481 {
5482 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5483 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_MAC_OUI,
5484 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5485 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305486 .doit = wlan_hdd_cfg80211_set_spoofed_mac_oui
Siddharth Bhala3a5cb42014-09-29 21:13:13 +05305487 },
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305488 {
5489 .info.vendor_id = QCA_NL80211_VENDOR_ID,
5490 .info.subcmd = QCA_NL80211_VENDOR_SUBCMD_GET_CONCURRENCY_MATRIX,
5491 .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
5492 WIPHY_VENDOR_CMD_NEED_NETDEV,
Edhar, Mahesh Kumar59129f52015-01-14 14:26:04 +05305493 .doit = wlan_hdd_cfg80211_get_concurrency_matrix
Dasari Srinivase18b2cf2014-10-28 17:09:42 +05305494 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305495};
5496
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005497/* vendor specific events */
Sunil Duttc69bccb2014-05-26 21:30:20 +05305498static const
5499struct nl80211_vendor_cmd_info wlan_hdd_cfg80211_vendor_events[] =
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005500{
5501#ifdef FEATURE_WLAN_CH_AVOID
5502 {
Sunil Duttc69bccb2014-05-26 21:30:20 +05305503 .vendor_id = QCA_NL80211_VENDOR_ID,
5504 .subcmd = QCA_NL80211_VENDOR_SUBCMD_AVOID_FREQUENCY
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005505 },
Sunil Duttc69bccb2014-05-26 21:30:20 +05305506#endif /* FEATURE_WLAN_CH_AVOID Index = 0*/
5507#ifdef WLAN_FEATURE_LINK_LAYER_STATS
5508 {
5509 /* Index = 1*/
5510 .vendor_id = QCA_NL80211_VENDOR_ID,
5511 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_SET
5512 },
5513 {
5514 /* Index = 2*/
5515 .vendor_id = QCA_NL80211_VENDOR_ID,
5516 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_GET
5517 },
5518 {
5519 /* Index = 3*/
5520 .vendor_id = QCA_NL80211_VENDOR_ID,
5521 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_CLR
5522 },
5523 {
5524 /* Index = 4*/
5525 .vendor_id = QCA_NL80211_VENDOR_ID,
5526 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_RADIO_RESULTS
5527 },
5528 {
5529 /* Index = 5*/
5530 .vendor_id = QCA_NL80211_VENDOR_ID,
5531 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_IFACE_RESULTS
5532 },
5533 {
5534 /* Index = 6*/
5535 .vendor_id = QCA_NL80211_VENDOR_ID,
5536 .subcmd = QCA_NL80211_VENDOR_SUBCMD_LL_STATS_PEERS_RESULTS
5537 },
5538#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Dino Mycle6fb96c12014-06-10 11:52:40 +05305539#ifdef WLAN_FEATURE_EXTSCAN
5540 {
5541 .vendor_id = QCA_NL80211_VENDOR_ID,
5542 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_START
5543 },
5544 {
5545 .vendor_id = QCA_NL80211_VENDOR_ID,
5546 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_STOP
5547 },
5548 {
5549 .vendor_id = QCA_NL80211_VENDOR_ID,
5550 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CAPABILITIES
5551 },
5552 {
5553 .vendor_id = QCA_NL80211_VENDOR_ID,
5554 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_GET_CACHED_RESULTS
5555 },
5556 {
5557 .vendor_id = QCA_NL80211_VENDOR_ID,
5558 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_RESULTS_AVAILABLE
5559 },
5560 {
5561 .vendor_id = QCA_NL80211_VENDOR_ID,
5562 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_FULL_SCAN_RESULT
5563 },
5564 {
5565 .vendor_id = QCA_NL80211_VENDOR_ID,
5566 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SCAN_EVENT
5567 },
5568 {
5569 .vendor_id = QCA_NL80211_VENDOR_ID,
5570 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_HOTLIST_AP_FOUND
5571 },
5572 {
5573 .vendor_id = QCA_NL80211_VENDOR_ID,
5574 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_BSSID_HOTLIST
5575 },
5576 {
5577 .vendor_id = QCA_NL80211_VENDOR_ID,
5578 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_BSSID_HOTLIST
5579 },
5580 {
5581 .vendor_id = QCA_NL80211_VENDOR_ID,
5582 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SIGNIFICANT_CHANGE
5583 },
5584 {
5585 .vendor_id = QCA_NL80211_VENDOR_ID,
5586 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_SET_SIGNIFICANT_CHANGE
5587 },
5588 {
5589 .vendor_id = QCA_NL80211_VENDOR_ID,
5590 .subcmd = QCA_NL80211_VENDOR_SUBCMD_EXTSCAN_RESET_SIGNIFICANT_CHANGE
5591 },
5592#endif /* WLAN_FEATURE_EXTSCAN */
Atul Mittal115287b2014-07-08 13:26:33 +05305593/*EXT TDLS*/
5594 {
5595 .vendor_id = QCA_NL80211_VENDOR_ID,
5596 .subcmd = QCA_NL80211_VENDOR_SUBCMD_TDLS_STATE
5597 },
Srinivas Dasari030bad32015-02-18 23:23:54 +05305598
5599 {
5600 .vendor_id = QCA_NL80211_VENDOR_ID,
5601 .subcmd = QCA_NL80211_VENDOR_SUBCMD_NAN
5602 },
5603
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005604};
5605
Jeff Johnson295189b2012-06-20 16:38:30 -07005606/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305607 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305608 * This function is called by hdd_wlan_startup()
5609 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305610 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -07005611 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305612struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -07005613{
5614 struct wiphy *wiphy;
5615 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305616 /*
5617 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 */
5619 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
5620
5621 if (!wiphy)
5622 {
5623 /* Print error and jump into err label and free the memory */
5624 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
5625 return NULL;
5626 }
5627
Sunil Duttc69bccb2014-05-26 21:30:20 +05305628
Jeff Johnson295189b2012-06-20 16:38:30 -07005629 return wiphy;
5630}
5631
5632/*
5633 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305634 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -07005635 * private ioctl to change the band value
5636 */
5637int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
5638{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305639 int i, j;
5640 eNVChannelEnabledType channelEnabledState;
5641
Jeff Johnsone7245742012-09-05 17:12:55 -07005642 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05305643
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305644 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005645 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305646
5647 if (NULL == wiphy->bands[i])
5648 {
5649 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5650 __func__, i);
5651 continue;
5652 }
5653
5654 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5655 {
5656 struct ieee80211_supported_band *band = wiphy->bands[i];
5657
5658 channelEnabledState = vos_nv_getChannelEnabledState(
5659 band->channels[j].hw_value);
5660
5661 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
5662 {
Abhishek Singh678227a2014-11-04 10:52:38 +05305663 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305664 continue;
5665 }
5666 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
5667 {
5668 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5669 continue;
5670 }
5671
5672 if (NV_CHANNEL_DISABLE == channelEnabledState ||
5673 NV_CHANNEL_INVALID == channelEnabledState)
5674 {
5675 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5676 }
5677 else if (NV_CHANNEL_DFS == channelEnabledState)
5678 {
5679 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5680 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
5681 }
5682 else
5683 {
5684 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
5685 |IEEE80211_CHAN_RADAR);
5686 }
5687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005688 }
5689 return 0;
5690}
5691/*
5692 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305693 * This function is called by hdd_wlan_startup()
5694 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -07005695 * This function is used to initialize and register wiphy structure.
5696 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305697int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07005698 struct wiphy *wiphy,
5699 hdd_config_t *pCfg
5700 )
5701{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305702 int i, j;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305703 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5704
Jeff Johnsone7245742012-09-05 17:12:55 -07005705 ENTER();
5706
Jeff Johnson295189b2012-06-20 16:38:30 -07005707 /* Now bind the underlying wlan device with wiphy */
5708 set_wiphy_dev(wiphy, dev);
5709
5710 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005711
Kiet Lam6c583332013-10-14 05:37:09 +05305712#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -07005713 /* the flag for the other case would be initialzed in
5714 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -07005715 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +05305716#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005717
Amar Singhalfddc28c2013-09-05 13:03:40 -07005718 /* This will disable updating of NL channels from passive to
5719 * active if a beacon is received on passive channel. */
5720 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -07005721
Amar Singhalfddc28c2013-09-05 13:03:40 -07005722
Amar Singhala49cbc52013-10-08 18:37:44 -07005723
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005724#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07005725 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
5726 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
5727 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -07005728 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +05305729 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005730#endif
Amar Singhala49cbc52013-10-08 18:37:44 -07005731
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005732#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005733 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -08005734#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005735 || pCfg->isFastRoamIniFeatureEnabled
5736#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005737#ifdef FEATURE_WLAN_ESE
5738 || pCfg->isEseIniFeatureEnabled
Srinivas Girigowda640728a2013-03-28 12:21:54 -07005739#endif
5740 )
5741 {
5742 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
5743 }
James Zmuda77fb5ae2013-01-29 08:00:17 -08005744#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005745#ifdef FEATURE_WLAN_TDLS
5746 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
5747 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
5748#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305749#ifdef FEATURE_WLAN_SCAN_PNO
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +05305750 if (pCfg->configPNOScanSupport)
5751 {
5752 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
5753 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
5754 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
5755 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
5756 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05305757#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -08005758
Abhishek Singh10d85972015-04-17 10:27:23 +05305759#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5760 wiphy->features |= NL80211_FEATURE_HT_IBSS;
5761#endif
5762
Amar Singhalfddc28c2013-09-05 13:03:40 -07005763#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005764 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
5765 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -07005766 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -07005767 driver need to determine what to do with both
5768 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -07005769
5770 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -07005771#else
5772 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -07005773#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005774
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305775 wiphy->max_scan_ssids = MAX_SCAN_SSID;
5776
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05305777 wiphy->max_scan_ie_len = SIR_MAC_MAX_ADD_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -07005778
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05305779 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
5780
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305782 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 | BIT(NL80211_IFTYPE_P2P_CLIENT)
5785 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 | BIT(NL80211_IFTYPE_AP);
5787
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305788 if( pCfg->advertiseConcurrentOperation )
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005789 {
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305790#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
5791 if( pCfg->enableMCC )
5792 {
5793 /* Currently, supports up to two channels */
5794 wlan_hdd_iface_combination.num_different_channels = 2;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005795
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305796 if( !pCfg->allowMCCGODiffBI )
5797 wlan_hdd_iface_combination.beacon_int_infra_match = true;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005798
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305799 }
5800 wiphy->iface_combinations = &wlan_hdd_iface_combination;
5801 wiphy->n_iface_combinations = 1;
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005802#endif
Rashmi Ramannabd3feb72014-02-25 16:14:48 +05305803 }
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -08005804
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 /* Before registering we need to update the ht capabilitied based
5806 * on ini values*/
5807 if( !pCfg->ShortGI20MhzEnable )
5808 {
5809 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5810 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5811 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
5812 }
5813
5814 if( !pCfg->ShortGI40MhzEnable )
5815 {
5816 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
5817 }
5818
5819 if( !pCfg->nChannelBondingMode5GHz )
5820 {
5821 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
5822 }
5823
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305824 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
Vinay Krishna Erannafacf5e22014-02-24 13:16:25 +05305825 if (true == hdd_is_5g_supported(pHddCtx))
5826 {
5827 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
5828 }
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +05305829
5830 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
5831 {
5832
5833 if (NULL == wiphy->bands[i])
5834 {
5835 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
5836 __func__, i);
5837 continue;
5838 }
5839
5840 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
5841 {
5842 struct ieee80211_supported_band *band = wiphy->bands[i];
5843
5844 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
5845 {
5846 // Enable social channels for P2P
5847 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
5848 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
5849 else
5850 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5851 continue;
5852 }
5853 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
5854 {
5855 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
5856 continue;
5857 }
5858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 }
5860 /*Initialise the supported cipher suite details*/
5861 wiphy->cipher_suites = hdd_cipher_suites;
5862 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
5863
5864 /*signal strength in mBm (100*dBm) */
5865 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
5866
5867#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Sushant Kaushik4f640e42014-07-08 12:27:09 +05305868 wiphy->max_remain_on_channel_duration = 5000;
Jeff Johnson295189b2012-06-20 16:38:30 -07005869#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005870
Sunil Duttc69bccb2014-05-26 21:30:20 +05305871 wiphy->n_vendor_commands = ARRAY_SIZE(hdd_wiphy_vendor_commands);
5872 wiphy->vendor_commands = hdd_wiphy_vendor_commands;
Rajesh Chauhan98a31f82014-01-06 20:15:25 -08005873 wiphy->vendor_events = wlan_hdd_cfg80211_vendor_events;
5874 wiphy->n_vendor_events = ARRAY_SIZE(wlan_hdd_cfg80211_vendor_events);
5875
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305876 EXIT();
5877 return 0;
5878}
5879
5880/* In this function we are registering wiphy. */
5881int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
5882{
5883 ENTER();
5884 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 if (0 > wiphy_register(wiphy))
5886 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305887 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -07005888 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
5889 return -EIO;
5890 }
5891
5892 EXIT();
5893 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305894}
Jeff Johnson295189b2012-06-20 16:38:30 -07005895
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305896/* In this function we are updating channel list when,
5897 regulatory domain is FCC and country code is US.
5898 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
5899 As per FCC smart phone is not a indoor device.
5900 GO should not opeate on indoor channels */
5901void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
5902{
5903 int j;
5904 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
5905 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
5906 //Default counrtycode from NV at the time of wiphy initialization.
5907 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
5908 &defaultCountryCode[0]))
5909 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005910 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305911 }
5912 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
5913 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +05305914 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
5915 {
5916 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
5917 return;
5918 }
5919 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
5920 {
5921 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
5922 // Mark UNII -1 band channel as passive
5923 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
5924 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
5925 }
5926 }
5927}
5928
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305929/* This function registers for all frame which supplicant is interested in */
5930void wlan_hdd_cfg80211_register_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005931{
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5933 /* Register for all P2P action, public action etc frames */
5934 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5935
Jeff Johnsone7245742012-09-05 17:12:55 -07005936 ENTER();
5937
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 /* Right now we are registering these frame when driver is getting
5939 initialized. Once we will move to 2.6.37 kernel, in which we have
5940 frame register ops, we will move this code as a part of that */
5941 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305942 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5944
5945 /* GAS Initial Response */
5946 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5947 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305948
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 /* GAS Comeback Request */
5950 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5951 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
5952
5953 /* GAS Comeback Response */
5954 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5955 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
5956
5957 /* P2P Public Action */
5958 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305959 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 P2P_PUBLIC_ACTION_FRAME_SIZE );
5961
5962 /* P2P Action */
5963 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5964 (v_U8_t*)P2P_ACTION_FRAME,
5965 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -07005966
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +05305967 /* WNM BSS Transition Request frame */
5968 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5969 (v_U8_t*)WNM_BSS_ACTION_FRAME,
5970 WNM_BSS_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07005971
5972 /* WNM-Notification */
5973 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
5974 (v_U8_t*)WNM_NOTIFICATION_FRAME,
5975 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005976}
5977
Agarwal Ashish8fa0e9a2014-05-23 00:40:12 +05305978void wlan_hdd_cfg80211_deregister_frames(hdd_adapter_t* pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005979{
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5981 /* Register for all P2P action, public action etc frames */
5982 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
5983
Jeff Johnsone7245742012-09-05 17:12:55 -07005984 ENTER();
5985
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 /* Right now we are registering these frame when driver is getting
5987 initialized. Once we will move to 2.6.37 kernel, in which we have
5988 frame register ops, we will move this code as a part of that */
5989 /* GAS Initial Request */
5990
5991 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5992 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
5993
5994 /* GAS Initial Response */
5995 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
5996 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305997
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 /* GAS Comeback Request */
5999 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6000 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
6001
6002 /* GAS Comeback Response */
6003 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6004 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
6005
6006 /* P2P Public Action */
6007 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306008 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 P2P_PUBLIC_ACTION_FRAME_SIZE );
6010
6011 /* P2P Action */
6012 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6013 (v_U8_t*)P2P_ACTION_FRAME,
6014 P2P_ACTION_FRAME_SIZE );
Leela Venkata Kiran Kumar Reddy Chiralae8e62c82013-10-29 18:23:26 -07006015 /* WNM-Notification */
6016 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
6017 (v_U8_t*)WNM_NOTIFICATION_FRAME,
6018 WNM_NOTIFICATION_FRAME_SIZE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006019}
6020
6021#ifdef FEATURE_WLAN_WAPI
6022void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
6023 const u8 *mac_addr, u8 *key , int key_Len)
6024{
6025 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6026 tCsrRoamSetKey setKey;
6027 v_BOOL_t isConnected = TRUE;
6028 int status = 0;
6029 v_U32_t roamId= 0xFF;
6030 tANI_U8 *pKeyPtr = NULL;
6031 int n = 0;
6032
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306033 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
6034 __func__, hdd_device_modetoString(pAdapter->device_mode),
6035 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07006036
Gopichand Nakkalae7480202013-02-11 15:24:22 +05306037 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 setKey.keyId = key_index; // Store Key ID
6039 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
6040 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
6041 setKey.paeRole = 0 ; // the PAE role
6042 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
6043 {
6044 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
6045 }
6046 else
6047 {
6048 isConnected = hdd_connIsConnected(pHddStaCtx);
6049 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
6050 }
6051 setKey.keyLength = key_Len;
6052 pKeyPtr = setKey.Key;
6053 memcpy( pKeyPtr, key, key_Len);
6054
Arif Hussain6d2a3322013-11-17 19:50:10 -08006055 hddLog(VOS_TRACE_LEVEL_INFO,"%s: WAPI KEY LENGTH:0x%04x",
Jeff Johnson295189b2012-06-20 16:38:30 -07006056 __func__, key_Len);
6057 for (n = 0 ; n < key_Len; n++)
6058 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
6059 __func__,n,setKey.Key[n]);
6060
6061 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
6062 if ( isConnected )
6063 {
6064 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
6065 pAdapter->sessionId, &setKey, &roamId );
6066 }
6067 if ( status != 0 )
6068 {
6069 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6070 "[%4d] sme_RoamSetKey returned ERROR status= %d",
6071 __LINE__, status );
6072 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
6073 }
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05306074 /* Need to clear any trace of key value in the memory.
6075 * Thus zero out the memory even though it is local
6076 * variable.
6077 */
6078 vos_mem_zero(&setKey, sizeof(setKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006079}
6080#endif /* FEATURE_WLAN_WAPI*/
6081
6082#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306083int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 beacon_data_t **ppBeacon,
6085 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006086#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306087int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006088 beacon_data_t **ppBeacon,
6089 struct cfg80211_beacon_data *params,
6090 int dtim_period)
6091#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306092{
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 int size;
6094 beacon_data_t *beacon = NULL;
6095 beacon_data_t *old = NULL;
6096 int head_len,tail_len;
6097
Jeff Johnsone7245742012-09-05 17:12:55 -07006098 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 if (params->head && !params->head_len)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306100 {
6101 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6102 FL("head_len is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006103 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306104 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006105
6106 old = pAdapter->sessionCtx.ap.beacon;
6107
6108 if (!params->head && !old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306109 {
6110 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6111 FL("session(%d) old and new heads points to NULL"),
6112 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306114 }
6115
6116 if (params->tail && !params->tail_len)
6117 {
6118 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6119 FL("tail_len is zero but tail is not NULL"));
6120 return -EINVAL;
6121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006122
Jeff Johnson295189b2012-06-20 16:38:30 -07006123#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
6124 /* Kernel 3.0 is not updating dtim_period for set beacon */
6125 if (!params->dtim_period)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306126 {
6127 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6128 FL("dtim period is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 return -EINVAL;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006131#endif
6132
6133 if(params->head)
6134 head_len = params->head_len;
6135 else
6136 head_len = old->head_len;
6137
6138 if(params->tail || !old)
6139 tail_len = params->tail_len;
6140 else
6141 tail_len = old->tail_len;
6142
6143 size = sizeof(beacon_data_t) + head_len + tail_len;
6144
6145 beacon = kzalloc(size, GFP_KERNEL);
6146
6147 if( beacon == NULL )
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306148 {
6149 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6150 FL("Mem allocation for beacon failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006151 return -ENOMEM;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006153
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006154#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 if(params->dtim_period || !old )
6156 beacon->dtim_period = params->dtim_period;
6157 else
6158 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006159#else
6160 if(dtim_period || !old )
6161 beacon->dtim_period = dtim_period;
6162 else
6163 beacon->dtim_period = old->dtim_period;
6164#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306165
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
6167 beacon->tail = beacon->head + head_len;
6168 beacon->head_len = head_len;
6169 beacon->tail_len = tail_len;
6170
6171 if(params->head) {
6172 memcpy (beacon->head,params->head,beacon->head_len);
6173 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306174 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 if(old)
6176 memcpy (beacon->head,old->head,beacon->head_len);
6177 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306178
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 if(params->tail) {
6180 memcpy (beacon->tail,params->tail,beacon->tail_len);
6181 }
6182 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306183 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07006184 memcpy (beacon->tail,old->tail,beacon->tail_len);
6185 }
6186
6187 *ppBeacon = beacon;
6188
6189 kfree(old);
6190
6191 return 0;
6192
6193}
Jeff Johnson295189b2012-06-20 16:38:30 -07006194
6195v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
6196{
6197 int left = length;
6198 v_U8_t *ptr = pIes;
6199 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306200
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306202 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006203 elem_id = ptr[0];
6204 elem_len = ptr[1];
6205 left -= 2;
6206 if(elem_len > left)
6207 {
6208 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07006209 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 eid,elem_len,left);
6211 return NULL;
6212 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306213 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 {
6215 return ptr;
6216 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306217
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 left -= elem_len;
6219 ptr += (elem_len + 2);
6220 }
6221 return NULL;
6222}
6223
Jeff Johnson295189b2012-06-20 16:38:30 -07006224/* Check if rate is 11g rate or not */
6225static int wlan_hdd_rate_is_11g(u8 rate)
6226{
Sanjay Devnani28322e22013-06-21 16:13:40 -07006227 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 u8 i;
6229 for (i = 0; i < 8; i++)
6230 {
6231 if(rate == gRateArray[i])
6232 return TRUE;
6233 }
6234 return FALSE;
6235}
6236
6237/* Check for 11g rate and set proper 11g only mode */
6238static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
6239 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
6240{
6241 u8 i, num_rates = pIe[0];
6242
6243 pIe += 1;
6244 for ( i = 0; i < num_rates; i++)
6245 {
6246 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
6247 {
6248 /* If rate set have 11g rate than change the mode to 11G */
6249 *pSapHw_mode = eSAP_DOT11_MODE_11g;
6250 if (pIe[i] & BASIC_RATE_MASK)
6251 {
6252 /* If we have 11g rate as basic rate, it means mode
6253 is 11g only mode.
6254 */
6255 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
6256 *pCheckRatesfor11g = FALSE;
6257 }
6258 }
6259 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
6260 {
6261 *require_ht = TRUE;
6262 }
6263 }
6264 return;
6265}
6266
6267static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
6268{
6269 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6270 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6271 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6272 u8 checkRatesfor11g = TRUE;
6273 u8 require_ht = FALSE;
6274 u8 *pIe=NULL;
6275
6276 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
6277
6278 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
6279 pBeacon->head_len, WLAN_EID_SUPP_RATES);
6280 if (pIe != NULL)
6281 {
6282 pIe += 1;
6283 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6284 &pConfig->SapHw_mode);
6285 }
6286
6287 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6288 WLAN_EID_EXT_SUPP_RATES);
6289 if (pIe != NULL)
6290 {
6291
6292 pIe += 1;
6293 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
6294 &pConfig->SapHw_mode);
6295 }
6296
6297 if( pConfig->channel > 14 )
6298 {
6299 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
6300 }
6301
6302 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
6303 WLAN_EID_HT_CAPABILITY);
6304
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306305 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 {
6307 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
6308 if(require_ht)
6309 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
6310 }
6311}
6312
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306313static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
6314 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
6315{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006316 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306317 v_U8_t *pIe = NULL;
6318 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6319
6320 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
6321 pBeacon->tail, pBeacon->tail_len);
6322
6323 if (pIe)
6324 {
6325 ielen = pIe[1] + 2;
6326 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6327 {
6328 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
6329 }
6330 else
6331 {
6332 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
6333 return -EINVAL;
6334 }
6335 *total_ielen += ielen;
6336 }
6337 return 0;
6338}
6339
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006340static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
6341 v_U8_t *genie, v_U8_t *total_ielen)
6342{
6343 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6344 int left = pBeacon->tail_len;
6345 v_U8_t *ptr = pBeacon->tail;
6346 v_U8_t elem_id, elem_len;
6347 v_U16_t ielen = 0;
6348
6349 if ( NULL == ptr || 0 == left )
6350 return;
6351
6352 while (left >= 2)
6353 {
6354 elem_id = ptr[0];
6355 elem_len = ptr[1];
6356 left -= 2;
6357 if (elem_len > left)
6358 {
6359 hddLog( VOS_TRACE_LEVEL_ERROR,
6360 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
6361 elem_id, elem_len, left);
6362 return;
6363 }
6364 if (IE_EID_VENDOR == elem_id)
6365 {
6366 /* skipping the VSIE's which we don't want to include or
6367 * it will be included by existing code
6368 */
6369 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
6370#ifdef WLAN_FEATURE_WFD
6371 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
6372#endif
6373 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6374 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6375 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
6376 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
6377 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
6378 {
6379 ielen = ptr[1] + 2;
6380 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
6381 {
6382 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
6383 *total_ielen += ielen;
6384 }
6385 else
6386 {
6387 hddLog( VOS_TRACE_LEVEL_ERROR,
6388 "IE Length is too big "
6389 "IEs eid=%d elem_len=%d total_ie_lent=%d",
6390 elem_id, elem_len, *total_ielen);
6391 }
6392 }
6393 }
6394
6395 left -= elem_len;
6396 ptr += (elem_len + 2);
6397 }
6398 return;
6399}
6400
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006401#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07006402static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6403 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006404#else
6405static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
6406 struct cfg80211_beacon_data *params)
6407#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006408{
6409 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306410 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07006412 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006413
6414 genie = vos_mem_malloc(MAX_GENIE_LEN);
6415
6416 if(genie == NULL) {
6417
6418 return -ENOMEM;
6419 }
6420
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306421 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6422 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006423 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306424 hddLog(LOGE,
6425 FL("Adding WPS IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306426 ret = -EINVAL;
6427 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006428 }
6429
6430#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306431 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6432 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
6433 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306434 hddLog(LOGE,
6435 FL("Adding WFD IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306436 ret = -EINVAL;
6437 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006438 }
6439#endif
6440
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306441 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
6442 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05306444 hddLog(LOGE,
6445 FL("Adding P2P IE failed"));
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306446 ret = -EINVAL;
6447 goto done;
6448 }
6449
6450 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
6451 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07006452 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006454
6455 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6456 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
6457 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6458 {
6459 hddLog(LOGE,
6460 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006461 ret = -EINVAL;
6462 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 }
6464
6465 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6466 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
6467 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6468 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6469 ==eHAL_STATUS_FAILURE)
6470 {
6471 hddLog(LOGE,
6472 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006473 ret = -EINVAL;
6474 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 }
6476
6477 // Added for ProResp IE
6478 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
6479 {
6480 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
6481 u8 probe_rsp_ie_len[3] = {0};
6482 u8 counter = 0;
6483 /* Check Probe Resp Length if it is greater then 255 then Store
6484 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
6485 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
6486 Store More then 255 bytes into One Variable.
6487 */
6488 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
6489 {
6490 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
6491 {
6492 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
6493 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
6494 }
6495 else
6496 {
6497 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
6498 rem_probe_resp_ie_len = 0;
6499 }
6500 }
6501
6502 rem_probe_resp_ie_len = 0;
6503
6504 if (probe_rsp_ie_len[0] > 0)
6505 {
6506 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6507 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
6508 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6509 probe_rsp_ie_len[0], NULL,
6510 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6511 {
6512 hddLog(LOGE,
6513 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006514 ret = -EINVAL;
6515 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006516 }
6517 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
6518 }
6519
6520 if (probe_rsp_ie_len[1] > 0)
6521 {
6522 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6523 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
6524 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6525 probe_rsp_ie_len[1], NULL,
6526 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6527 {
6528 hddLog(LOGE,
6529 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006530 ret = -EINVAL;
6531 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 }
6533 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
6534 }
6535
6536 if (probe_rsp_ie_len[2] > 0)
6537 {
6538 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6539 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
6540 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
6541 probe_rsp_ie_len[2], NULL,
6542 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6543 {
6544 hddLog(LOGE,
6545 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006546 ret = -EINVAL;
6547 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 }
6549 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
6550 }
6551
6552 if (probe_rsp_ie_len[1] == 0 )
6553 {
6554 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6555 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
6556 eANI_BOOLEAN_FALSE) )
6557 {
6558 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006559 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006560 }
6561 }
6562
6563 if (probe_rsp_ie_len[2] == 0 )
6564 {
6565 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6566 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
6567 eANI_BOOLEAN_FALSE) )
6568 {
6569 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006570 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006571 }
6572 }
6573
6574 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6575 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
6576 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6577 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6578 == eHAL_STATUS_FAILURE)
6579 {
6580 hddLog(LOGE,
6581 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006582 ret = -EINVAL;
6583 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006584 }
6585 }
6586 else
6587 {
6588 // Reset WNI_CFG_PROBE_RSP Flags
6589 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
6590
6591 hddLog(VOS_TRACE_LEVEL_INFO,
6592 "%s: No Probe Response IE received in set beacon",
6593 __func__);
6594 }
6595
6596 // Added for AssocResp IE
6597 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
6598 {
6599 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6600 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
6601 params->assocresp_ies_len, NULL,
6602 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
6603 {
6604 hddLog(LOGE,
6605 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006606 ret = -EINVAL;
6607 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 }
6609
6610 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6611 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
6612 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
6613 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
6614 == eHAL_STATUS_FAILURE)
6615 {
6616 hddLog(LOGE,
6617 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07006618 ret = -EINVAL;
6619 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 }
6621 }
6622 else
6623 {
6624 hddLog(VOS_TRACE_LEVEL_INFO,
6625 "%s: No Assoc Response IE received in set beacon",
6626 __func__);
6627
6628 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
6629 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
6630 eANI_BOOLEAN_FALSE) )
6631 {
6632 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006633 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 }
6635 }
6636
Jeff Johnsone7245742012-09-05 17:12:55 -07006637done:
Jeff Johnson295189b2012-06-20 16:38:30 -07006638 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05306639 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07006640}
Jeff Johnson295189b2012-06-20 16:38:30 -07006641
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306642/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 * FUNCTION: wlan_hdd_validate_operation_channel
6644 * called by wlan_hdd_cfg80211_start_bss() and
6645 * wlan_hdd_cfg80211_set_channel()
6646 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306647 * channel list.
6648 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07006649VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006650{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306651
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 v_U32_t num_ch = 0;
6653 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6654 u32 indx = 0;
6655 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306656 v_U8_t fValidChannel = FALSE, count = 0;
6657 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306658
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6660
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306661 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306663 /* Validate the channel */
6664 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306666 if ( channel == rfChannels[count].channelNum )
6667 {
6668 fValidChannel = TRUE;
6669 break;
6670 }
6671 }
6672 if (fValidChannel != TRUE)
6673 {
6674 hddLog(VOS_TRACE_LEVEL_ERROR,
6675 "%s: Invalid Channel [%d]", __func__, channel);
6676 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006677 }
6678 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306679 else
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05306681 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6682 valid_ch, &num_ch))
6683 {
6684 hddLog(VOS_TRACE_LEVEL_ERROR,
6685 "%s: failed to get valid channel list", __func__);
6686 return VOS_STATUS_E_FAILURE;
6687 }
6688 for (indx = 0; indx < num_ch; indx++)
6689 {
6690 if (channel == valid_ch[indx])
6691 {
6692 break;
6693 }
6694 }
6695
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306696 if (indx >= num_ch)
6697 {
6698 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6699 {
6700 eCsrBand band;
6701 unsigned int freq;
6702
6703 sme_GetFreqBand(hHal, &band);
6704
6705 if (eCSR_BAND_5G == band)
6706 {
6707#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
6708 if (channel <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
6709 {
6710 freq = ieee80211_channel_to_frequency(channel,
6711 IEEE80211_BAND_2GHZ);
6712 }
6713 else
6714 {
6715 freq = ieee80211_channel_to_frequency(channel,
6716 IEEE80211_BAND_5GHZ);
6717 }
6718#else
6719 freq = ieee80211_channel_to_frequency(channel);
6720#endif
6721 if(WLAN_HDD_IS_SOCIAL_CHANNEL(freq))
6722 return VOS_STATUS_SUCCESS;
6723 }
6724 }
6725
6726 hddLog(VOS_TRACE_LEVEL_ERROR,
6727 "%s: Invalid Channel [%d]", __func__, channel);
6728 return VOS_STATUS_E_FAILURE;
6729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 }
Rashmi Ramanna3b59e122014-04-10 14:45:13 +05306731
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306733
Jeff Johnson295189b2012-06-20 16:38:30 -07006734}
6735
Viral Modi3a32cc52013-02-08 11:14:52 -08006736/**
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306737 * FUNCTION: __wlan_hdd_cfg80211_set_channel
Viral Modi3a32cc52013-02-08 11:14:52 -08006738 * This function is used to set the channel number
6739 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306740static int __wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
Viral Modi3a32cc52013-02-08 11:14:52 -08006741 struct ieee80211_channel *chan,
6742 enum nl80211_channel_type channel_type
6743 )
6744{
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306745 hdd_adapter_t *pAdapter = NULL;
Viral Modi3a32cc52013-02-08 11:14:52 -08006746 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07006747 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08006748 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306749 hdd_context_t *pHddCtx;
6750 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006751
6752 ENTER();
6753
6754 if( NULL == dev )
6755 {
6756 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006757 "%s: Called with dev = NULL.", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006758 return -ENODEV;
6759 }
6760 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05306761
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05306762 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
6763 TRACE_CODE_HDD_CFG80211_SET_CHANNEL, pAdapter->sessionId,
6764 channel_type ));
Viral Modi3a32cc52013-02-08 11:14:52 -08006765 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306766 "%s: device_mode = %s (%d) freq = %d", __func__,
6767 hdd_device_modetoString(pAdapter->device_mode),
6768 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306769
6770 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6771 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306772 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08006773 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306774 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006775 }
6776
6777 /*
6778 * Do freq to chan conversion
6779 * TODO: for 11a
6780 */
6781
6782 channel = ieee80211_frequency_to_channel(freq);
6783
6784 /* Check freq range */
6785 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
6786 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
6787 {
6788 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006789 "%s: Channel [%d] is outside valid range from %d to %d",
Viral Modi3a32cc52013-02-08 11:14:52 -08006790 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
6791 WNI_CFG_CURRENT_CHANNEL_STAMAX);
6792 return -EINVAL;
6793 }
6794
6795 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6796
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05306797 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
6798 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08006799 {
6800 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
6801 {
6802 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006803 "%s: Invalid Channel [%d]", __func__, channel);
Viral Modi3a32cc52013-02-08 11:14:52 -08006804 return -EINVAL;
6805 }
6806 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
6807 "%s: set channel to [%d] for device mode =%d",
6808 __func__, channel,pAdapter->device_mode);
6809 }
6810 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08006811 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08006812 )
6813 {
6814 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6815 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
6816 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6817
6818 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
6819 {
6820 /* Link is up then return cant set channel*/
6821 hddLog( VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006822 "%s: IBSS Associated, can't set the channel", __func__);
Viral Modi3a32cc52013-02-08 11:14:52 -08006823 return -EINVAL;
6824 }
6825
6826 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
6827 pHddStaCtx->conn_info.operationChannel = channel;
6828 pRoamProfile->ChannelInfo.ChannelList =
6829 &pHddStaCtx->conn_info.operationChannel;
6830 }
6831 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08006832 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08006833 )
6834 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306835 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
6836 {
6837 if(VOS_STATUS_SUCCESS !=
6838 wlan_hdd_validate_operation_channel(pAdapter,channel))
6839 {
6840 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006841 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306842 return -EINVAL;
6843 }
6844 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6845 }
6846 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08006847 {
6848 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
6849
6850 /* If auto channel selection is configured as enable/ 1 then ignore
6851 channel set by supplicant
6852 */
6853 if ( cfg_param->apAutoChannelSelection )
6854 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306855 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
6856 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08006857 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05306858 "%s: set channel to auto channel (0) for device mode =%s (%d)",
6859 __func__, hdd_device_modetoString(pAdapter->device_mode),
6860 pAdapter->device_mode);
Viral Modi3a32cc52013-02-08 11:14:52 -08006861 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306862 else
6863 {
6864 if(VOS_STATUS_SUCCESS !=
6865 wlan_hdd_validate_operation_channel(pAdapter,channel))
6866 {
6867 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006868 "%s: Invalid Channel [%d]", __func__, channel);
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05306869 return -EINVAL;
6870 }
6871 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
6872 }
Viral Modi3a32cc52013-02-08 11:14:52 -08006873 }
6874 }
6875 else
6876 {
6877 hddLog(VOS_TRACE_LEVEL_FATAL,
6878 "%s: Invalid device mode failed to set valid channel", __func__);
6879 return -EINVAL;
6880 }
6881 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306882 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08006883}
6884
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05306885static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy,
6886 struct net_device *dev,
6887 struct ieee80211_channel *chan,
6888 enum nl80211_channel_type channel_type
6889 )
6890{
6891 int ret;
6892
6893 vos_ssr_protect(__func__);
6894 ret = __wlan_hdd_cfg80211_set_channel(wiphy, dev, chan, channel_type);
6895 vos_ssr_unprotect(__func__);
6896
6897 return ret;
6898}
6899
Jeff Johnson295189b2012-06-20 16:38:30 -07006900#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
6901static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6902 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006903#else
6904static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
6905 struct cfg80211_beacon_data *params,
6906 const u8 *ssid, size_t ssid_len,
6907 enum nl80211_hidden_ssid hidden_ssid)
6908#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006909{
6910 tsap_Config_t *pConfig;
6911 beacon_data_t *pBeacon = NULL;
6912 struct ieee80211_mgmt *pMgmt_frame;
6913 v_U8_t *pIe=NULL;
6914 v_U16_t capab_info;
6915 eCsrAuthType RSNAuthType;
6916 eCsrEncryptionType RSNEncryptType;
6917 eCsrEncryptionType mcRSNEncryptType;
6918 int status = VOS_STATUS_SUCCESS;
6919 tpWLAN_SAPEventCB pSapEventCallback;
6920 hdd_hostapd_state_t *pHostapdState;
6921 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
6922 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306923 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 struct qc_mac_acl_entry *acl_entry = NULL;
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306925 hdd_config_t *iniConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07006926 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08006927 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Peng Xu2446a892014-09-05 17:21:18 +05306928 tSmeConfigParams *psmeConfig;
Chet Lanctot40142442014-05-20 13:39:25 -07006929 v_BOOL_t MFPCapable = VOS_FALSE;
6930 v_BOOL_t MFPRequired = VOS_FALSE;
Sushant Kaushik7dc03272015-02-18 11:25:12 +05306931 v_BOOL_t sapEnable11AC =
6932 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->sapEnable11AC;
Jeff Johnson295189b2012-06-20 16:38:30 -07006933 ENTER();
6934
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05306935 iniConfig = pHddCtx->cfg_ini;
6936
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
6938
6939 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
6940
6941 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
6942
6943 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
6944
6945 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
6946
6947 //channel is already set in the set_channel Call back
6948 //pConfig->channel = pCommitConfig->channel;
6949
6950 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306951 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
6953
6954 pConfig->dtim_period = pBeacon->dtim_period;
6955
Arif Hussain6d2a3322013-11-17 19:50:10 -08006956 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***",
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 pConfig->dtim_period);
6958
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08006959 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07006960 {
6961 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07006962 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05306963 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
6964 {
6965 tANI_BOOLEAN restartNeeded;
6966 pConfig->ieee80211d = 1;
6967 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
6968 sme_setRegInfo(hHal, pConfig->countryCode);
6969 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
6970 }
6971 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07006973 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07006974 pConfig->ieee80211d = 1;
6975 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
6976 sme_setRegInfo(hHal, pConfig->countryCode);
6977 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07006978 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07006979 else
6980 {
6981 pConfig->ieee80211d = 0;
6982 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306983 /*
6984 * If auto channel is configured i.e. channel is 0,
6985 * so skip channel validation.
6986 */
6987 if( AUTO_CHANNEL_SELECT != pConfig->channel )
6988 {
6989 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
6990 {
6991 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08006992 "%s: Invalid Channel [%d]", __func__, pConfig->channel);
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05306993 return -EINVAL;
6994 }
6995 }
6996 else
6997 {
6998 if(1 != pHddCtx->is_dynamic_channel_range_set)
6999 {
7000 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
7001 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
7002 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
7003 }
7004 pHddCtx->is_dynamic_channel_range_set = 0;
7005 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007006 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07007007 else
Jeff Johnson295189b2012-06-20 16:38:30 -07007008 {
7009 pConfig->ieee80211d = 0;
7010 }
7011 pConfig->authType = eSAP_AUTO_SWITCH;
7012
7013 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307014
7015 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
7017
7018 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
7019
7020 /*Set wps station to configured*/
7021 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
7022
7023 if(pIe)
7024 {
7025 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
7026 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007027 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***");
Jeff Johnson295189b2012-06-20 16:38:30 -07007028 return -EINVAL;
7029 }
7030 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
7031 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007032 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 /* Check 15 bit of WPS IE as it contain information for wps state
7034 * WPS state
7035 */
7036 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
7037 {
7038 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
7039 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
7040 {
7041 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
7042 }
7043 }
7044 }
7045 else
7046 {
7047 pConfig->wps_state = SAP_WPS_DISABLED;
7048 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307049 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07007050
c_hpothufe599e92014-06-16 11:38:55 +05307051 pConfig->RSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7052 pConfig->mcRSNEncryptType = eCSR_ENCRYPT_TYPE_NONE;
7053 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType =
7054 eCSR_ENCRYPT_TYPE_NONE;
7055
Jeff Johnson295189b2012-06-20 16:38:30 -07007056 pConfig->RSNWPAReqIELength = 0;
7057 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307058 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07007059 WLAN_EID_RSN);
7060 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307061 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007062 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7063 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7064 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307065 /* The actual processing may eventually be more extensive than
7066 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07007067 * by the app.
7068 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307069 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7071 &RSNEncryptType,
7072 &mcRSNEncryptType,
7073 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007074 &MFPCapable,
7075 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 pConfig->pRSNWPAReqIE[1]+2,
7077 pConfig->pRSNWPAReqIE );
7078
7079 if( VOS_STATUS_SUCCESS == status )
7080 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307081 /* Now copy over all the security attributes you have
7082 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007083 * */
7084 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7085 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7086 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7087 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307088 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007089 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007090 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7091 }
7092 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307093
Jeff Johnson295189b2012-06-20 16:38:30 -07007094 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7095 pBeacon->tail, pBeacon->tail_len);
7096
7097 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
7098 {
7099 if (pConfig->pRSNWPAReqIE)
7100 {
7101 /*Mixed mode WPA/WPA2*/
7102 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
7103 pConfig->RSNWPAReqIELength += pIe[1] + 2;
7104 }
7105 else
7106 {
7107 pConfig->RSNWPAReqIELength = pIe[1] + 2;
7108 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
7109 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307110 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07007111 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
7112 &RSNEncryptType,
7113 &mcRSNEncryptType,
7114 &RSNAuthType,
Chet Lanctot8cecea22014-02-11 19:09:36 -08007115 &MFPCapable,
7116 &MFPRequired,
Jeff Johnson295189b2012-06-20 16:38:30 -07007117 pConfig->pRSNWPAReqIE[1]+2,
7118 pConfig->pRSNWPAReqIE );
7119
7120 if( VOS_STATUS_SUCCESS == status )
7121 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307122 /* Now copy over all the security attributes you have
7123 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 * */
7125 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
7126 pConfig->mcRSNEncryptType = mcRSNEncryptType;
7127 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
7128 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05307129 hddLog( LOG1, FL("CSR AuthType = %d, "
Arif Hussain6d2a3322013-11-17 19:50:10 -08007130 "EncryptionType = %d mcEncryptionType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
7132 }
7133 }
7134 }
7135
Jeff Johnson4416a782013-03-25 14:17:50 -07007136 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
7137 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
7138 return -EINVAL;
7139 }
7140
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
7142
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007143#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007144 if (params->ssid != NULL)
7145 {
7146 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
7147 pConfig->SSIDinfo.ssid.length = params->ssid_len;
7148 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7149 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7150 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007151#else
7152 if (ssid != NULL)
7153 {
7154 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
7155 pConfig->SSIDinfo.ssid.length = ssid_len;
7156 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
7157 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
7158 }
7159#endif
7160
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307161 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307163
Jeff Johnson295189b2012-06-20 16:38:30 -07007164 /* default value */
7165 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
7166 pConfig->num_accept_mac = 0;
7167 pConfig->num_deny_mac = 0;
7168
7169 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7170 pBeacon->tail, pBeacon->tail_len);
7171
7172 /* pIe for black list is following form:
7173 type : 1 byte
7174 length : 1 byte
7175 OUI : 4 bytes
7176 acl type : 1 byte
7177 no of mac addr in black list: 1 byte
7178 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307179 */
7180 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007181 {
7182 pConfig->SapMacaddr_acl = pIe[6];
7183 pConfig->num_deny_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007184 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307186 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
7187 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007188 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7189 for (i = 0; i < pConfig->num_deny_mac; i++)
7190 {
7191 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7192 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307193 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 }
7195 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
7196 pBeacon->tail, pBeacon->tail_len);
7197
7198 /* pIe for white list is following form:
7199 type : 1 byte
7200 length : 1 byte
7201 OUI : 4 bytes
7202 acl type : 1 byte
7203 no of mac addr in white list: 1 byte
7204 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307205 */
7206 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 {
7208 pConfig->SapMacaddr_acl = pIe[6];
7209 pConfig->num_accept_mac = pIe[7];
Arif Hussain6d2a3322013-11-17 19:50:10 -08007210 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307212 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
7213 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007214 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
7215 for (i = 0; i < pConfig->num_accept_mac; i++)
7216 {
7217 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
7218 acl_entry++;
7219 }
7220 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307221
Jeff Johnson295189b2012-06-20 16:38:30 -07007222 wlan_hdd_set_sapHwmode(pHostapdAdapter);
7223
Jeff Johnsone7245742012-09-05 17:12:55 -07007224#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007225 /* Overwrite the hostapd setting for HW mode only for 11ac.
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307226 * This is valid only if mode is set to 11n in hostapd, sapEnable11AC
7227 * is set in .ini and 11ac is supported by both host and firmware.
Kiet Lam0f320422013-11-21 19:29:17 +05307228 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
7229 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08007230 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
7231 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Sushant Kaushik7dc03272015-02-18 11:25:12 +05307232 (sapEnable11AC) && (sme_IsFeatureSupportedByDriver(DOT11AC)) &&
7233 (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07007234 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307235 v_U32_t operatingBand = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007236 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307237 ccmCfgGetInt(hHal, WNI_CFG_SAP_CHANNEL_SELECT_OPERATING_BAND, &operatingBand);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007238
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307239 /* If ACS disable and selected channel <= 14
7240 * OR
7241 * ACS enabled and ACS operating band is choosen as 2.4
7242 * AND
7243 * VHT in 2.4G Disabled
7244 * THEN
7245 * Fallback to 11N mode
7246 */
7247 if (((AUTO_CHANNEL_SELECT != pConfig->channel && pConfig->channel <= SIR_11B_CHANNEL_END)
7248 || (AUTO_CHANNEL_SELECT == pConfig->channel &&
Deepthi Gowri7db41f32014-10-13 17:02:29 +05307249 operatingBand == eSAP_RF_SUBBAND_2_4_GHZ)) &&
Siddharth Bhal5cba24e2014-05-08 18:59:39 +05307250 iniConfig->enableVhtFor24GHzBand == FALSE)
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007251 {
Siddharth Bhalf42f8592014-05-15 13:39:07 +05307252 hddLog(LOGW, FL("Setting hwmode to 11n, operatingBand = %d, Channel = %d"),
7253 operatingBand, pConfig->channel);
Ravi Joshi83bfaa12013-05-28 22:12:08 -07007254 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
7255 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007256 }
7257#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307258
Jeff Johnson295189b2012-06-20 16:38:30 -07007259 // ht_capab is not what the name conveys,this is used for protection bitmap
7260 pConfig->ht_capab =
7261 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
7262
7263 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
7264 {
7265 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
7266 return -EINVAL;
7267 }
7268
7269 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307270 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
7272 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307273 pConfig->obssProtEnabled =
7274 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07007275
Chet Lanctot8cecea22014-02-11 19:09:36 -08007276#ifdef WLAN_FEATURE_11W
7277 pConfig->mfpCapable = MFPCapable;
7278 pConfig->mfpRequired = MFPRequired;
7279 hddLog(LOGW, FL("Soft AP MFP capable %d, MFP required %d\n"),
7280 pConfig->mfpCapable, pConfig->mfpRequired);
7281#endif
7282
Arif Hussain6d2a3322013-11-17 19:50:10 -08007283 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07007284 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007285 hddLog(LOGW,FL("ssid =%s, beaconint=%d, channel=%d"),
7286 pConfig->SSIDinfo.ssid.ssId, (int)pConfig->beacon_int,
7287 (int)pConfig->channel);
7288 hddLog(LOGW,FL("hw_mode=%x, privacy=%d, authType=%d"),
7289 pConfig->SapHw_mode, pConfig->privacy,
7290 pConfig->authType);
7291 hddLog(LOGW,FL("RSN/WPALen=%d, Uapsd = %d"),
7292 (int)pConfig->RSNWPAReqIELength, pConfig->UapsdEnable);
7293 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d"),
7294 pConfig->protEnabled, pConfig->obssProtEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07007295
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307296 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07007297 {
7298 //Bss already started. just return.
7299 //TODO Probably it should update some beacon params.
7300 hddLog( LOGE, "Bss Already started...Ignore the request");
7301 EXIT();
7302 return 0;
7303 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307304
Agarwal Ashish51325b52014-06-16 16:50:49 +05307305 if (vos_max_concurrent_connections_reached()) {
7306 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7307 return -EINVAL;
7308 }
7309
Jeff Johnson295189b2012-06-20 16:38:30 -07007310 pConfig->persona = pHostapdAdapter->device_mode;
7311
Peng Xu2446a892014-09-05 17:21:18 +05307312 psmeConfig = (tSmeConfigParams*) vos_mem_malloc(sizeof(tSmeConfigParams));
7313 if ( NULL != psmeConfig)
7314 {
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307315 vos_mem_zero(psmeConfig, sizeof (tSmeConfigParams));
Peng Xu2446a892014-09-05 17:21:18 +05307316 sme_GetConfigParam(hHal, psmeConfig);
7317 pConfig->scanBandPreference = psmeConfig->csrConfig.scanBandPreference;
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +05307318#ifdef WLAN_FEATURE_AP_HT40_24G
7319 if (((pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
7320 || (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO))
7321 && pHddCtx->cfg_ini->apHT40_24GEnabled)
7322 {
7323 psmeConfig->csrConfig.apHT40_24GEnabled = 1;
7324 sme_UpdateConfig (hHal, psmeConfig);
7325 }
7326#endif
Peng Xu2446a892014-09-05 17:21:18 +05307327 vos_mem_free(psmeConfig);
7328 }
Peng Xuafc34e32014-09-25 13:23:55 +05307329 pConfig->acsBandSwitchThreshold = iniConfig->acsBandSwitchThreshold;
Peng Xu2446a892014-09-05 17:21:18 +05307330
Jeff Johnson295189b2012-06-20 16:38:30 -07007331 pSapEventCallback = hdd_hostapd_SAPEventCB;
7332 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
7333 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
7334 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08007335 hddLog(LOGE,FL("SAP Start Bss fail"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 return -EINVAL;
7337 }
7338
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307339 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07007340 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
7341
7342 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307343
Jeff Johnson295189b2012-06-20 16:38:30 -07007344 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307345 {
7346 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007347 ("ERROR: HDD vos wait for single_event failed!!"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07007348 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007349 VOS_ASSERT(0);
7350 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307351
Jeff Johnson295189b2012-06-20 16:38:30 -07007352 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
Kaushik, Sushantf6070802014-10-15 15:09:23 +05307353 /* Initialize WMM configuation */
7354 hdd_wmm_init(pHostapdAdapter);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307355 wlan_hdd_incr_active_session(pHddCtx, pHostapdAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007356
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007357#ifdef WLAN_FEATURE_P2P_DEBUG
7358 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
7359 {
7360 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
7361 {
7362 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7363 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007364 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007365 }
7366 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
7367 {
7368 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
7369 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08007370 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007371 }
7372 }
7373#endif
7374
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 pHostapdState->bCommit = TRUE;
7376 EXIT();
7377
7378 return 0;
7379}
7380
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007381#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307382static int __wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307383 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 struct beacon_parameters *params)
7385{
7386 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307387 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307388 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007389
7390 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307391
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307392 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7393 TRACE_CODE_HDD_CFG80211_ADD_BEACON,
7394 pAdapter->sessionId, params->interval));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307395 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%s (%d)",
7396 hdd_device_modetoString(pAdapter->device_mode),
7397 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007398
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307399 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7400 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307401 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007402 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307403 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007404 }
7405
Agarwal Ashish51325b52014-06-16 16:50:49 +05307406 if (vos_max_concurrent_connections_reached()) {
7407 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
7408 return -EINVAL;
7409 }
7410
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307411 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007413 )
7414 {
7415 beacon_data_t *old,*new;
7416
7417 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307418
Jeff Johnson295189b2012-06-20 16:38:30 -07007419 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307420 {
7421 hddLog(VOS_TRACE_LEVEL_WARN,
7422 FL("already beacon info added to session(%d)"),
7423 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007424 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007426
7427 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7428
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307429 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07007430 {
7431 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007432 "%s:Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007433 return -EINVAL;
7434 }
7435
7436 pAdapter->sessionCtx.ap.beacon = new;
7437
7438 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7439 }
7440
7441 EXIT();
7442 return status;
7443}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307444
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307445static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
7446 struct net_device *dev,
7447 struct beacon_parameters *params)
7448{
7449 int ret;
7450
7451 vos_ssr_protect(__func__);
7452 ret = __wlan_hdd_cfg80211_add_beacon(wiphy, dev, params);
7453 vos_ssr_unprotect(__func__);
7454
7455 return ret;
7456}
7457
7458static int __wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007459 struct net_device *dev,
7460 struct beacon_parameters *params)
7461{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307462 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307463 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7464 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307465 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007466
7467 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05307468
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307469 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7470 TRACE_CODE_HDD_CFG80211_SET_BEACON,
7471 pAdapter->sessionId, pHddStaCtx->conn_info.authType));
7472 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7473 __func__, hdd_device_modetoString(pAdapter->device_mode),
7474 pAdapter->device_mode);
7475
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307476 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7477 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307478 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007479 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307480 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007481 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307482
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307483 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007484 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307485 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 {
7487 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307488
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307490
Jeff Johnson295189b2012-06-20 16:38:30 -07007491 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307492 {
7493 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7494 FL("session(%d) old and new heads points to NULL"),
7495 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007496 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007498
7499 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
7500
7501 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307502 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007503 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007504 return -EINVAL;
7505 }
7506
7507 pAdapter->sessionCtx.ap.beacon = new;
7508
7509 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
7510 }
7511
7512 EXIT();
7513 return status;
7514}
7515
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307516static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
7517 struct net_device *dev,
7518 struct beacon_parameters *params)
7519{
7520 int ret;
7521
7522 vos_ssr_protect(__func__);
7523 ret = __wlan_hdd_cfg80211_set_beacon(wiphy, dev, params);
7524 vos_ssr_unprotect(__func__);
7525
7526 return ret;
7527}
7528
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007529#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7530
7531#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307532static int __wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007533 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007534#else
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307535static int __wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007536 struct net_device *dev)
7537#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007538{
7539 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07007540 hdd_context_t *pHddCtx = NULL;
7541 hdd_scaninfo_t *pScanInfo = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307542 VOS_STATUS status;
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307543 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007544
7545 ENTER();
7546
7547 if (NULL == pAdapter)
7548 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307549 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007550 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007551 return -ENODEV;
7552 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007553
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307554 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7555 TRACE_CODE_HDD_CFG80211_STOP_AP,
7556 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307557 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7558 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307559 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007560 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307561 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07007562 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007563
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07007564 pScanInfo = &pHddCtx->scan_info;
7565
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307566 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7567 __func__, hdd_device_modetoString(pAdapter->device_mode),
7568 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007569
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307570 ret = wlan_hdd_scan_abort(pAdapter);
7571
Girish Gowli4bf7a632014-06-12 13:42:11 +05307572 if (ret < 0)
Jeff Johnsone7245742012-09-05 17:12:55 -07007573 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307574 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7575 FL("Timeout occurred while waiting for abortscan %ld"), ret);
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307576
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307577 if (pHddCtx->isLogpInProgress)
Jeff Johnsone7245742012-09-05 17:12:55 -07007578 {
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7580 "%s: LOGP in Progress. Ignore!!!", __func__);
Yue Ma4f55ef32014-01-23 16:45:33 -08007581
Jeff Johnsone7245742012-09-05 17:12:55 -07007582 VOS_ASSERT(pScanInfo->mScanPending);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307583 return -EAGAIN;
Jeff Johnsone7245742012-09-05 17:12:55 -07007584 }
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +05307585 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07007586 }
7587
Rashmi Ramanna1f0948d2014-08-28 15:33:48 +05307588 /* Delete all associated STAs before stopping AP/P2P GO */
7589 hdd_del_all_sta(pAdapter);
Arun Kumar Khandavallia3bd8002014-01-17 16:21:19 +05307590 hdd_hostapd_stop(dev);
7591
Jeff Johnson295189b2012-06-20 16:38:30 -07007592 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007593 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07007594 )
7595 {
7596 beacon_data_t *old;
7597
7598 old = pAdapter->sessionCtx.ap.beacon;
7599
7600 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307601 {
7602 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7603 FL("session(%d) beacon data points to NULL"),
7604 pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007605 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007607
Jeff Johnson295189b2012-06-20 16:38:30 -07007608 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007609
7610 mutex_lock(&pHddCtx->sap_lock);
7611 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
7612 {
Jeff Johnson4416a782013-03-25 14:17:50 -07007613 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007614 {
7615 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
7616
7617 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
7618
7619 if (!VOS_IS_STATUS_SUCCESS(status))
7620 {
7621 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007622 ("ERROR: HDD vos wait for single_event failed!!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007623 VOS_ASSERT(0);
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307624 }
7625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007626 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
Agarwal Ashish51325b52014-06-16 16:50:49 +05307627 /* BSS stopped, clear the active sessions for this device mode */
7628 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007629 }
7630 mutex_unlock(&pHddCtx->sap_lock);
7631
7632 if(status != VOS_STATUS_SUCCESS)
7633 {
7634 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007635 "%s:Error!!! Stopping the BSS",__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 return -EINVAL;
7637 }
7638
Jeff Johnson4416a782013-03-25 14:17:50 -07007639 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007640 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
7641 ==eHAL_STATUS_FAILURE)
7642 {
7643 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007644 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007645 }
7646
Jeff Johnson4416a782013-03-25 14:17:50 -07007647 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07007648 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
7649 eANI_BOOLEAN_FALSE) )
7650 {
7651 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007652 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnson295189b2012-06-20 16:38:30 -07007653 }
7654
7655 // Reset WNI_CFG_PROBE_RSP Flags
7656 wlan_hdd_reset_prob_rspies(pAdapter);
7657
7658 pAdapter->sessionCtx.ap.beacon = NULL;
7659 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07007660#ifdef WLAN_FEATURE_P2P_DEBUG
7661 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
7662 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
7663 {
7664 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
7665 "GO got removed");
7666 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
7667 }
7668#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 }
7670 EXIT();
7671 return status;
7672}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007673
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307674#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7675static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
7676 struct net_device *dev)
7677{
7678 int ret;
7679
7680 vos_ssr_protect(__func__);
7681 ret = __wlan_hdd_cfg80211_del_beacon(wiphy, dev);
7682 vos_ssr_unprotect(__func__);
7683
7684 return ret;
7685}
7686#else
7687static int wlan_hdd_cfg80211_stop_ap(struct wiphy *wiphy,
7688 struct net_device *dev)
7689{
7690 int ret;
7691
7692 vos_ssr_protect(__func__);
7693 ret = __wlan_hdd_cfg80211_stop_ap(wiphy, dev);
7694 vos_ssr_unprotect(__func__);
7695
7696 return ret;
7697}
7698#endif
7699
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007700#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
7701
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307702static int __wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307703 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007704 struct cfg80211_ap_settings *params)
7705{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307706 hdd_adapter_t *pAdapter;
7707 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307708 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007709
7710 ENTER();
7711
Girish Gowlib143d7a2015-02-18 19:39:55 +05307712 if (NULL == dev || NULL == params)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007713 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307714 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Girish Gowlib143d7a2015-02-18 19:39:55 +05307715 "%s: Device or params is Null", __func__);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307716 return -ENODEV;
7717 }
7718
7719 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7720 if (NULL == pAdapter)
7721 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307722 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307723 "%s: HDD adapter is Null", __func__);
7724 return -ENODEV;
7725 }
7726
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307727 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7728 TRACE_CODE_HDD_CFG80211_START_AP, pAdapter->sessionId,
7729 params-> beacon_interval));
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307730 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
7731 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307732 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307733 "%s: HDD adapter magic is invalid", __func__);
7734 return -ENODEV;
7735 }
7736
7737 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307738 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307739 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307740 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307741 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307742 }
7743
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307744 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %s (%d)",
7745 __func__, hdd_device_modetoString(pAdapter->device_mode),
7746 pAdapter->device_mode);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307747
7748 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007749 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007750 )
7751 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307752 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007753
7754 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307755
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007756 if (old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307757 {
7758 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
7759 FL("already beacon info added to session(%d)"),
7760 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007761 return -EALREADY;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307762 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007763
Girish Gowlib143d7a2015-02-18 19:39:55 +05307764#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
7765 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7766 &new,
7767 &params->beacon);
7768#else
7769 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,
7770 &new,
7771 &params->beacon,
7772 params->dtim_period);
7773#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007774
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307775 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007776 {
7777 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05307778 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007779 return -EINVAL;
7780 }
7781 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08007782#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07007783 wlan_hdd_cfg80211_set_channel(wiphy, dev,
7784#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
7785 params->channel, params->channel_type);
7786#else
7787 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
7788#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08007789#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007790 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
7791 params->ssid_len, params->hidden_ssid);
7792 }
7793
7794 EXIT();
7795 return status;
7796}
7797
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307798static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
7799 struct net_device *dev,
7800 struct cfg80211_ap_settings *params)
7801{
7802 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007803
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307804 vos_ssr_protect(__func__);
7805 ret = __wlan_hdd_cfg80211_start_ap(wiphy, dev, params);
7806 vos_ssr_unprotect(__func__);
7807
7808 return ret;
7809}
7810
7811static int __wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007812 struct net_device *dev,
7813 struct cfg80211_beacon_data *params)
7814{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307815 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307816 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307817 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007818
7819 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307820
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307821 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7822 TRACE_CODE_HDD_CFG80211_CHANGE_BEACON,
7823 pAdapter->sessionId, pAdapter->device_mode));
Arif Hussain6d2a3322013-11-17 19:50:10 -08007824 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007825 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307826
7827 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7828 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307829 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007830 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307831 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07007832 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007833
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307834 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007835 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307836 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007837 {
7838 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307839
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007840 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307841
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007842 if (!old)
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307843 {
7844 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7845 FL("session(%d) beacon data points to NULL"),
7846 pAdapter->sessionId);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007847 return -ENOENT;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307848 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007849
7850 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
7851
7852 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307853 hddLog(VOS_TRACE_LEVEL_FATAL,
Arif Hussain6d2a3322013-11-17 19:50:10 -08007854 "%s: Error!!! Allocating the new beacon",__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007855 return -EINVAL;
7856 }
7857
7858 pAdapter->sessionCtx.ap.beacon = new;
7859
7860 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
7861 }
7862
7863 EXIT();
7864 return status;
7865}
7866
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307867static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
7868 struct net_device *dev,
7869 struct cfg80211_beacon_data *params)
7870{
7871 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007872
Mukul Sharmab0e0a982014-12-15 18:58:53 +05307873 vos_ssr_protect(__func__);
7874 ret = __wlan_hdd_cfg80211_change_beacon(wiphy, dev, params);
7875 vos_ssr_unprotect(__func__);
7876
7877 return ret;
7878}
7879
7880#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07007881
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307882static int __wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007883 struct net_device *dev,
7884 struct bss_parameters *params)
7885{
7886 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307887 hdd_context_t *pHddCtx;
7888 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007889
7890 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05307891
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307892 if (NULL == pAdapter)
7893 {
7894 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7895 "%s: HDD adapter is Null", __func__);
7896 return -ENODEV;
7897 }
7898 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307899 ret = wlan_hdd_validate_context(pHddCtx);
7900 if (0 != ret)
7901 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05307902 return ret;
7903 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307904 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7905 TRACE_CODE_HDD_CFG80211_CHANGE_BSS,
7906 pAdapter->sessionId, params->ap_isolate));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307907 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7908 __func__, hdd_device_modetoString(pAdapter->device_mode),
7909 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07007910
7911 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07007912 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307913 )
Jeff Johnson295189b2012-06-20 16:38:30 -07007914 {
7915 /* ap_isolate == -1 means that in change bss, upper layer doesn't
7916 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307917 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07007918 {
7919 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307920 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007921 }
7922
7923 EXIT();
7924 return 0;
7925}
7926
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +05307927static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
7928 struct net_device *dev,
7929 struct bss_parameters *params)
7930{
7931 int ret;
7932
7933 vos_ssr_protect(__func__);
7934 ret = __wlan_hdd_cfg80211_change_bss(wiphy, dev, params);
7935 vos_ssr_unprotect(__func__);
7936
7937 return ret;
7938}
Kiet Lam10841362013-11-01 11:36:50 +05307939/* FUNCTION: wlan_hdd_change_country_code_cd
7940* to wait for contry code completion
7941*/
7942void* wlan_hdd_change_country_code_cb(void *pAdapter)
7943{
7944 hdd_adapter_t *call_back_pAdapter = pAdapter;
7945 complete(&call_back_pAdapter->change_country_code);
7946 return NULL;
7947}
7948
Jeff Johnson295189b2012-06-20 16:38:30 -07007949/*
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307950 * FUNCTION: __wlan_hdd_cfg80211_change_iface
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
7952 */
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05307953int __wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07007954 struct net_device *ndev,
7955 enum nl80211_iftype type,
7956 u32 *flags,
7957 struct vif_params *params
7958 )
7959{
7960 struct wireless_dev *wdev;
7961 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007962 hdd_context_t *pHddCtx;
Mohit Khanna0f232092012-09-11 14:46:08 -07007963 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007964 tCsrRoamProfile *pRoamProfile = NULL;
7965 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307966 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007967 eMib_dot11DesiredBssType connectedBssType;
7968 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05307969 long ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07007970
7971 ENTER();
7972
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307973 if (!pAdapter)
Rajesh Chauhana0516c62014-01-30 16:11:18 -08007974 {
7975 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7976 "%s: Adapter context is null", __func__);
7977 return VOS_STATUS_E_FAILURE;
7978 }
7979
7980 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7981 if (!pHddCtx)
7982 {
7983 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7984 "%s: HDD context is null", __func__);
7985 return VOS_STATUS_E_FAILURE;
7986 }
7987
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05307988 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
7989 TRACE_CODE_HDD_CFG80211_CHANGE_IFACE,
7990 pAdapter->sessionId, type));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307991 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307992 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307994 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007995 }
7996
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05307997 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
7998 __func__, hdd_device_modetoString(pAdapter->device_mode),
7999 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008000
Agarwal Ashish51325b52014-06-16 16:50:49 +05308001 if (vos_max_concurrent_connections_reached()) {
8002 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
8003 return -EINVAL;
8004 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308005 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 wdev = ndev->ieee80211_ptr;
8007
8008#ifdef WLAN_BTAMP_FEATURE
8009 if((NL80211_IFTYPE_P2P_CLIENT == type)||
8010 (NL80211_IFTYPE_ADHOC == type)||
8011 (NL80211_IFTYPE_AP == type)||
8012 (NL80211_IFTYPE_P2P_GO == type))
8013 {
8014 pHddCtx->isAmpAllowed = VOS_FALSE;
8015 // stop AMP traffic
8016 status = WLANBAP_StopAmp();
8017 if(VOS_STATUS_SUCCESS != status )
8018 {
8019 pHddCtx->isAmpAllowed = VOS_TRUE;
8020 hddLog(VOS_TRACE_LEVEL_FATAL,
8021 "%s: Failed to stop AMP", __func__);
8022 return -EINVAL;
8023 }
8024 }
8025#endif //WLAN_BTAMP_FEATURE
8026 /* Reset the current device mode bit mask*/
8027 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
8028
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05308029 /* Notify Mode change in case of concurrency.
8030 * Below function invokes TDLS teardown Functionality Since TDLS is
8031 * not Supported in case of concurrency i.e Once P2P session
8032 * is detected disable offchannel and teardown TDLS links
8033 */
8034 hdd_tdls_notify_mode_change(pAdapter, pHddCtx);
8035
Jeff Johnson295189b2012-06-20 16:38:30 -07008036 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07008037 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07008038 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07008039 )
8040 {
8041 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -08008042 if (!pWextState)
8043 {
8044 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8045 "%s: pWextState is null", __func__);
8046 return VOS_STATUS_E_FAILURE;
8047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 pRoamProfile = &pWextState->roamProfile;
8049 LastBSSType = pRoamProfile->BSSType;
8050
8051 switch (type)
8052 {
8053 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008054 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008055 hddLog(VOS_TRACE_LEVEL_INFO,
8056 "%s: setting interface Type to INFRASTRUCTURE", __func__);
8057 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07008058#ifdef WLAN_FEATURE_11AC
8059 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
8060 {
8061 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
8062 }
8063#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308064 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07008065 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008066 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008067 //Check for sub-string p2p to confirm its a p2p interface
8068 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308069 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008070 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8071 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8072 }
8073 else
8074 {
8075 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008076 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 break;
Mahesh A Saptasagar36cdc802015-01-07 18:41:17 +05308079
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 case NL80211_IFTYPE_ADHOC:
8081 hddLog(VOS_TRACE_LEVEL_INFO,
8082 "%s: setting interface Type to ADHOC", __func__);
8083 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
8084 pRoamProfile->phyMode =
8085 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07008086 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 wdev->iftype = type;
Katya Nigam1fd24402015-02-16 14:52:19 +05308088 hdd_set_ibss_ops( pAdapter );
8089 hdd_ibss_init_tx_rx( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008090 break;
8091
8092 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008094 {
8095 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
8096 "%s: setting interface Type to %s", __func__,
8097 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
8098
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008099 //Cancel any remain on channel for GO mode
8100 if (NL80211_IFTYPE_P2P_GO == type)
8101 {
8102 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
8103 }
Mohit Khanna0f232092012-09-11 14:46:08 -07008104 if (NL80211_IFTYPE_AP == type)
8105 {
8106 /* As Loading WLAN Driver one interface being created for p2p device
8107 * address. This will take one HW STA and the max number of clients
8108 * that can connect to softAP will be reduced by one. so while changing
8109 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
8110 * interface as it is not required in SoftAP mode.
8111 */
8112
8113 // Get P2P Adapter
8114 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
8115
8116 if (pP2pAdapter)
8117 {
Agarwal Ashish3a38bd12014-06-12 15:16:52 +05308118 hdd_stop_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
c_hpothu002231a2015-02-05 14:58:51 +05308119 hdd_deinit_adapter(pHddCtx, pP2pAdapter, TRUE);
Mohit Khanna0f232092012-09-11 14:46:08 -07008120 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
8121 }
8122 }
Swaroop Goltia2e32212014-04-09 23:37:33 +05308123 //Disable IMPS & BMPS for SAP/GO
8124 if(VOS_STATUS_E_FAILURE ==
8125 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
8126 {
8127 //Fail to Exit BMPS
8128 VOS_ASSERT(0);
8129 }
Deepthi Gowri500fc472014-08-11 19:53:10 +05308130
8131 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
8132
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308133#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07008134
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308135 /* A Mutex Lock is introduced while changing the mode to
8136 * protect the concurrent access for the Adapters by TDLS
8137 * module.
8138 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308139 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308140#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008141 //De-init the adapter.
c_hpothu002231a2015-02-05 14:58:51 +05308142 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008143 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8145 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308146#ifdef FEATURE_WLAN_TDLS
8147 mutex_unlock(&pHddCtx->tdls_lock);
8148#endif
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008149 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
8150 (pConfig->apRandomBssidEnabled))
8151 {
8152 /* To meet Android requirements create a randomized
8153 MAC address of the form 02:1A:11:Fx:xx:xx */
8154 get_random_bytes(&ndev->dev_addr[3], 3);
8155 ndev->dev_addr[0] = 0x02;
8156 ndev->dev_addr[1] = 0x1A;
8157 ndev->dev_addr[2] = 0x11;
8158 ndev->dev_addr[3] |= 0xF0;
8159 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
8160 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08008161 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
8162 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07008163 }
8164
Jeff Johnson295189b2012-06-20 16:38:30 -07008165 hdd_set_ap_ops( pAdapter->dev );
8166
Kiet Lam10841362013-11-01 11:36:50 +05308167 /* This is for only SAP mode where users can
8168 * control country through ini.
8169 * P2P GO follows station country code
8170 * acquired during the STA scanning. */
8171 if((NL80211_IFTYPE_AP == type) &&
8172 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
8173 {
8174 int status = 0;
8175 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
8176 "%s: setting country code from INI ", __func__);
8177 init_completion(&pAdapter->change_country_code);
8178 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
8179 (void *)(tSmeChangeCountryCallback)
8180 wlan_hdd_change_country_code_cb,
8181 pConfig->apCntryCode, pAdapter,
8182 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05308183 eSIR_FALSE,
8184 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05308185 if (eHAL_STATUS_SUCCESS == status)
8186 {
8187 /* Wait for completion */
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308188 ret = wait_for_completion_interruptible_timeout(
Kiet Lam10841362013-11-01 11:36:50 +05308189 &pAdapter->change_country_code,
8190 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308191 if (ret <= 0)
Kiet Lam10841362013-11-01 11:36:50 +05308192 {
8193 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308194 FL("SME Timed out while setting country code %ld"),
8195 ret);
Yue Ma4f55ef32014-01-23 16:45:33 -08008196
8197 if (pHddCtx->isLogpInProgress)
8198 {
8199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8200 "%s: LOGP in Progress. Ignore!!!", __func__);
8201 return -EAGAIN;
8202 }
Kiet Lam10841362013-11-01 11:36:50 +05308203 }
8204 }
8205 else
8206 {
8207 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08008208 "%s: SME Change Country code failed",__func__);
Kiet Lam10841362013-11-01 11:36:50 +05308209 return -EINVAL;
8210 }
8211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008212 status = hdd_init_ap_mode(pAdapter);
8213 if(status != VOS_STATUS_SUCCESS)
8214 {
8215 hddLog(VOS_TRACE_LEVEL_FATAL,
8216 "%s: Error initializing the ap mode", __func__);
8217 return -EINVAL;
8218 }
8219 hdd_set_conparam(1);
8220
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 /*interface type changed update in wiphy structure*/
8222 if(wdev)
8223 {
8224 wdev->iftype = type;
8225 pHddCtx->change_iface = type;
8226 }
8227 else
8228 {
8229 hddLog(VOS_TRACE_LEVEL_ERROR,
8230 "%s: ERROR !!!! Wireless dev is NULL", __func__);
8231 return -EINVAL;
8232 }
8233 goto done;
8234 }
8235
8236 default:
8237 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8238 __func__);
8239 return -EOPNOTSUPP;
8240 }
8241 }
8242 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07008244 )
8245 {
8246 switch(type)
8247 {
8248 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07008249 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 case NL80211_IFTYPE_ADHOC:
Deepthi Gowri500fc472014-08-11 19:53:10 +05308251
8252 hdd_stop_adapter( pHddCtx, pAdapter, VOS_TRUE );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308253#ifdef FEATURE_WLAN_TDLS
8254
8255 /* A Mutex Lock is introduced while changing the mode to
8256 * protect the concurrent access for the Adapters by TDLS
8257 * module.
8258 */
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308259 mutex_lock(&pHddCtx->tdls_lock);
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308260#endif
c_hpothu002231a2015-02-05 14:58:51 +05308261 hdd_deinit_adapter( pHddCtx, pAdapter, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008262 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08008263 //Check for sub-string p2p to confirm its a p2p interface
8264 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008265 {
8266 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
8267 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
8268 }
8269 else
8270 {
8271 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07008272 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08008273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008274 hdd_set_conparam(0);
8275 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008276 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
8277 hdd_set_station_ops( pAdapter->dev );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308278#ifdef FEATURE_WLAN_TDLS
8279 mutex_unlock(&pHddCtx->tdls_lock);
8280#endif
Sunil Dutt66485cb2013-12-19 19:05:03 +05308281 status = hdd_init_station_mode( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07008282 if( VOS_STATUS_SUCCESS != status )
8283 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07008284 /* In case of JB, for P2P-GO, only change interface will be called,
8285 * This is the right place to enable back bmps_imps()
8286 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05308287 if (pHddCtx->hdd_wlan_suspended)
8288 {
8289 hdd_set_pwrparams(pHddCtx);
8290 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008291 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07008292 goto done;
8293 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07008294 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07008295 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07008296 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
8297 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 goto done;
8299 default:
8300 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
8301 __func__);
8302 return -EOPNOTSUPP;
8303
8304 }
8305
8306 }
8307 else
8308 {
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308309 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: unsupported device mode(%s (%d))",
8310 __func__, hdd_device_modetoString(pAdapter->device_mode),
8311 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 return -EOPNOTSUPP;
8313 }
8314
8315
8316 if(pRoamProfile)
8317 {
8318 if ( LastBSSType != pRoamProfile->BSSType )
8319 {
8320 /*interface type changed update in wiphy structure*/
8321 wdev->iftype = type;
8322
8323 /*the BSS mode changed, We need to issue disconnect
8324 if connected or in IBSS disconnect state*/
8325 if ( hdd_connGetConnectedBssType(
8326 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
8327 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
8328 {
8329 /*need to issue a disconnect to CSR.*/
8330 INIT_COMPLETION(pAdapter->disconnect_comp_var);
8331 if( eHAL_STATUS_SUCCESS ==
8332 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
8333 pAdapter->sessionId,
8334 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
8335 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308336 ret = wait_for_completion_interruptible_timeout(
8337 &pAdapter->disconnect_comp_var,
8338 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
8339 if (ret <= 0)
8340 {
8341 hddLog(VOS_TRACE_LEVEL_ERROR,
8342 FL("wait on disconnect_comp_var failed %ld"), ret);
8343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008344 }
8345 }
8346 }
8347 }
8348
8349done:
8350 /*set bitmask based on updated value*/
8351 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07008352
8353 /* Only STA mode support TM now
8354 * all other mode, TM feature should be disabled */
8355 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
8356 (~VOS_STA & pHddCtx->concurrency_mode) )
8357 {
8358 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
8359 }
8360
Jeff Johnson295189b2012-06-20 16:38:30 -07008361#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308362 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05308363 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 {
8365 //we are ok to do AMP
8366 pHddCtx->isAmpAllowed = VOS_TRUE;
8367 }
8368#endif //WLAN_BTAMP_FEATURE
8369 EXIT();
8370 return 0;
8371}
8372
Mahesh A Saptasagar0e59c472014-04-14 19:17:41 +05308373/*
8374 * FUNCTION: wlan_hdd_cfg80211_change_iface
8375 * wrapper function to protect the actual implementation from SSR.
8376 */
8377int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
8378 struct net_device *ndev,
8379 enum nl80211_iftype type,
8380 u32 *flags,
8381 struct vif_params *params
8382 )
8383{
8384 int ret;
8385
8386 vos_ssr_protect(__func__);
8387 ret = __wlan_hdd_cfg80211_change_iface(wiphy, ndev, type, flags, params);
8388 vos_ssr_unprotect(__func__);
8389
8390 return ret;
8391}
8392
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008393#ifdef FEATURE_WLAN_TDLS
8394static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
8395 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
8396{
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008397 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008398 hddTdlsPeer_t *pTdlsPeer;
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308399 long ret;
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308400 tANI_U16 numCurrTdlsPeers;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308401 hdd_adapter_t *pAdapter;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008402
8403 ENTER();
8404
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +05308405 if (!dev) {
8406 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Dev pointer is NULL"));
8407 return -EINVAL;
8408 }
8409
8410 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8411 if (!pAdapter) {
8412 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adapter is NULL"));
8413 return -EINVAL;
8414 }
8415
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308416 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008417 {
8418 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8419 "Invalid arguments");
8420 return -EINVAL;
8421 }
Hoonki Lee27511902013-03-14 18:19:06 -07008422
8423 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
8424 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
8425 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308426 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -07008427 "%s: TDLS mode is disabled OR not enabled in FW."
8428 MAC_ADDRESS_STR " Request declined.",
8429 __func__, MAC_ADDR_ARRAY(mac));
8430 return -ENOTSUPP;
8431 }
8432
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008433 if (pHddCtx->isLogpInProgress)
8434 {
8435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8436 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +05308437 wlan_hdd_tdls_set_link_status(pAdapter,
8438 mac,
8439 eTDLS_LINK_IDLE,
8440 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008441 return -EBUSY;
8442 }
8443
Naresh Jayaram9c6f4462014-02-13 12:20:31 +05308444 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, mac);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008445
8446 if ( NULL == pTdlsPeer ) {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308447 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008448 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
8449 __func__, MAC_ADDR_ARRAY(mac), update);
8450 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008451 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008452
8453 /* in add station, we accept existing valid staId if there is */
8454 if ((0 == update) &&
8455 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
8456 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008457 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308458 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008459 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008460 " link_status %d. staId %d. add station ignored.",
8461 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
8462 return 0;
8463 }
8464 /* in change station, we accept only when staId is valid */
8465 if ((1 == update) &&
8466 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
8467 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
8468 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308469 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008470 "%s: " MAC_ADDRESS_STR
8471 " link status %d. staId %d. change station %s.",
8472 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
8473 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
8474 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008475 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008476
8477 /* when others are on-going, we want to change link_status to idle */
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +05308478 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008479 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008480 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8481 "%s: " MAC_ADDRESS_STR
8482 " TDLS setup is ongoing. Request declined.",
8483 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07008484 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008485 }
8486
8487 /* first to check if we reached to maximum supported TDLS peer.
8488 TODO: for now, return -EPERM looks working fine,
8489 but need to check if any other errno fit into this category.*/
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308490 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
8491 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008492 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008493 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8494 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +05308495 " TDLS Max peer already connected. Request declined."
8496 " Num of peers (%d), Max allowed (%d).",
8497 __func__, MAC_ADDR_ARRAY(mac), numCurrTdlsPeers,
8498 HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008499 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008500 }
8501 else
8502 {
8503 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308504 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008505 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008506 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008507 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8508 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
8509 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008510 return -EPERM;
8511 }
8512 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008513 if (0 == update)
Atul Mittal115287b2014-07-08 13:26:33 +05308514 wlan_hdd_tdls_set_link_status(pAdapter,
8515 mac,
8516 eTDLS_LINK_CONNECTING,
8517 eTDLS_LINK_SUCCESS);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008518
Jeff Johnsond75fe012013-04-06 10:53:06 -07008519 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308520 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008521 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008523 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008524 if(StaParams->htcap_present)
8525 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008527 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308528 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008529 "ht_capa->extended_capabilities: %0x",
8530 StaParams->HTCap.extendedHtCapInfo);
8531 }
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008533 "params->capability: %0x",StaParams->capability);
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008535 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07008536 if(StaParams->vhtcap_present)
8537 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee66b75f32013-04-16 18:30:07 -07008539 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
8540 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
8541 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
8542 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008543 {
8544 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008545 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008546 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +05308547 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008548 "[%d]: %x ", i, StaParams->supported_rates[i]);
8549 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07008550 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05308551 else if ((1 == update) && (NULL == StaParams))
8552 {
8553 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8554 "%s : update is true, but staParams is NULL. Error!", __func__);
8555 return -EPERM;
8556 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008557
8558 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
8559
8560 if (!update)
8561 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308562 ret = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008563 pAdapter->sessionId, mac);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308564 if (ret != eHAL_STATUS_SUCCESS) {
8565 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to add TDLS peer STA"));
8566 return -EPERM;
8567 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008568 }
8569 else
8570 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308571 ret = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008572 pAdapter->sessionId, mac, StaParams);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +05308573 if (ret != eHAL_STATUS_SUCCESS) {
8574 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to change TDLS peer STA params"));
8575 return -EPERM;
8576 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008577 }
8578
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308579 ret = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008580 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
8581
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308582 if (ret <= 0)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008583 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008584 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308585 "%s: timeout waiting for tdls add station indication %ld",
8586 __func__, ret);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008587 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008588 }
c_hpothu6ff1c3c2013-10-01 19:01:57 +05308589
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008590 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
8591 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008592 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008593 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008594 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008595 }
8596
8597 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008598
8599error:
Atul Mittal115287b2014-07-08 13:26:33 +05308600 wlan_hdd_tdls_set_link_status(pAdapter,
8601 mac,
8602 eTDLS_LINK_IDLE,
8603 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008604 return -EPERM;
8605
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008606}
8607#endif
8608
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308609static int __wlan_hdd_change_station(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008610 struct net_device *dev,
8611 u8 *mac,
8612 struct station_parameters *params)
8613{
8614 VOS_STATUS status = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308615 hdd_adapter_t *pAdapter;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308616 hdd_context_t *pHddCtx;
8617 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008618 v_MACADDR_t STAMacAddress;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308619 int ret = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008620#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008621 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008622 tANI_U8 isBufSta = 0;
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308623 tANI_U8 isOffChannelSupported = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008624#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008625
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308626 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05308627
Mahesh A Saptasagar74088392015-02-05 17:22:09 +05308628 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308629 if ((NULL == pAdapter))
8630 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308631 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05308632 "invalid adapter ");
8633 return -EINVAL;
8634 }
8635
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308636 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8637 TRACE_CODE_HDD_CHANGE_STATION,
8638 pAdapter->sessionId, params->listen_interval));
Gopichand Nakkala29149562013-05-10 21:43:41 +05308639 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala29149562013-05-10 21:43:41 +05308640
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308641 ret = wlan_hdd_validate_context(pHddCtx);
8642 if (0 != ret)
Gopichand Nakkala29149562013-05-10 21:43:41 +05308643 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308644 return ret;
Gopichand Nakkala29149562013-05-10 21:43:41 +05308645 }
8646
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308647 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8648
8649 if (NULL == pHddStaCtx)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008650 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05308651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8652 "invalid HDD station context");
8653 return -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008655 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
8656
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008657 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
8658 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07008659 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008660 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07008661 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308662 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07008663 WLANTL_STA_AUTHENTICATED);
8664
Gopichand Nakkala29149562013-05-10 21:43:41 +05308665 if (status != VOS_STATUS_SUCCESS)
8666 {
8667 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8668 "%s: Not able to change TL state to AUTHENTICATED", __func__);
8669 return -EINVAL;
8670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008671 }
8672 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07008673 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
8674 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05308675#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008676 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
8677 StaParams.capability = params->capability;
8678 StaParams.uapsd_queues = params->uapsd_queues;
8679 StaParams.max_sp = params->max_sp;
8680
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308681 /* Convert (first channel , number of channels) tuple to
8682 * the total list of channels. This goes with the assumption
8683 * that if the first channel is < 14, then the next channels
8684 * are an incremental of 1 else an incremental of 4 till the number
8685 * of channels.
8686 */
8687 if (0 != params->supported_channels_len) {
8688 int i = 0,j = 0,k = 0, no_of_channels = 0 ;
8689 for ( i = 0 ; i < params->supported_channels_len ; i+=2)
8690 {
8691 int wifi_chan_index;
8692 StaParams.supported_channels[j] = params->supported_channels[i];
8693 wifi_chan_index =
8694 ((StaParams.supported_channels[j] <= HDD_CHANNEL_14 ) ? 1 : 4 );
8695 no_of_channels = params->supported_channels[i+1];
8696 for(k=1; k <= no_of_channels; k++)
8697 {
8698 StaParams.supported_channels[j+1] =
8699 StaParams.supported_channels[j] + wifi_chan_index;
8700 j+=1;
8701 }
8702 }
8703 StaParams.supported_channels_len = j;
8704 }
8705 vos_mem_copy(StaParams.supported_oper_classes,
8706 params->supported_oper_classes,
8707 params->supported_oper_classes_len);
8708 StaParams.supported_oper_classes_len =
8709 params->supported_oper_classes_len;
8710
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008711 if (0 != params->ext_capab_len)
8712 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
8713 sizeof(StaParams.extn_capability));
8714
8715 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008716 {
8717 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008718 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008719 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008720
8721 StaParams.supported_rates_len = params->supported_rates_len;
8722
8723 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
8724 * The supported_rates array , for all the structures propogating till Add Sta
8725 * to the firmware has to be modified , if the supplicant (ieee80211) is
8726 * modified to send more rates.
8727 */
8728
8729 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
8730 */
8731 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
8732 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
8733
8734 if (0 != StaParams.supported_rates_len) {
8735 int i = 0;
8736 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
8737 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008738 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008739 "Supported Rates with Length %d", StaParams.supported_rates_len);
8740 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008741 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008742 "[%d]: %0x", i, StaParams.supported_rates[i]);
8743 }
8744
8745 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07008746 {
8747 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008748 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07008749 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008750
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008751 if (0 != params->ext_capab_len ) {
8752 /*Define A Macro : TODO Sunil*/
8753 if ((1<<4) & StaParams.extn_capability[3]) {
8754 isBufSta = 1;
8755 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308756 /* TDLS Channel Switching Support */
8757 if ((1<<6) & StaParams.extn_capability[3]) {
8758 isOffChannelSupported = 1;
8759 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008760 }
Naresh Jayaram3180aa42014-02-12 21:47:26 +05308761 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac,
8762 &StaParams, isBufSta,
8763 isOffChannelSupported);
8764
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308765 if (VOS_STATUS_SUCCESS != status) {
8766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8767 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
8768 return -EINVAL;
8769 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08008770 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
8771
8772 if (VOS_STATUS_SUCCESS != status) {
8773 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8774 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
8775 return -EINVAL;
8776 }
8777 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07008778#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05308779 }
Jeff Johnsone7245742012-09-05 17:12:55 -07008780 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07008781 return status;
8782}
8783
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05308784static int wlan_hdd_change_station(struct wiphy *wiphy,
8785 struct net_device *dev,
8786 u8 *mac,
8787 struct station_parameters *params)
8788{
8789 int ret;
8790
8791 vos_ssr_protect(__func__);
8792 ret = __wlan_hdd_change_station(wiphy, dev, mac, params);
8793 vos_ssr_unprotect(__func__);
8794
8795 return ret;
8796}
8797
Jeff Johnson295189b2012-06-20 16:38:30 -07008798/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308799 * FUNCTION: __wlan_hdd_cfg80211_add_key
Jeff Johnson295189b2012-06-20 16:38:30 -07008800 * This function is used to initialize the key information
8801 */
8802#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308803static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 struct net_device *ndev,
8805 u8 key_index, bool pairwise,
8806 const u8 *mac_addr,
8807 struct key_params *params
8808 )
8809#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05308810static int __wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07008811 struct net_device *ndev,
8812 u8 key_index, const u8 *mac_addr,
8813 struct key_params *params
8814 )
8815#endif
8816{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008817 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 tCsrRoamSetKey setKey;
8819 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308820 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008821 v_U32_t roamId= 0xFF;
8822 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07008823 hdd_hostapd_state_t *pHostapdState;
8824 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008825 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308826 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07008827
8828 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05308829
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05308830 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
8831 TRACE_CODE_HDD_CFG80211_ADD_KEY,
8832 pAdapter->sessionId, params->key_len));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308833 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8834 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308835 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008836 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308837 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008838 }
8839
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05308840 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
8841 __func__, hdd_device_modetoString(pAdapter->device_mode),
8842 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008843
8844 if (CSR_MAX_NUM_KEY <= key_index)
8845 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008846 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07008847 key_index);
8848
8849 return -EINVAL;
8850 }
8851
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008852 if (CSR_MAX_KEY_LEN < params->key_len)
8853 {
8854 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
8855 params->key_len);
8856
8857 return -EINVAL;
8858 }
8859
8860 hddLog(VOS_TRACE_LEVEL_INFO,
8861 "%s: called with key index = %d & key length %d",
8862 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07008863
8864 /*extract key idx, key len and key*/
8865 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8866 setKey.keyId = key_index;
8867 setKey.keyLength = params->key_len;
8868 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
8869
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008870 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 {
8872 case WLAN_CIPHER_SUITE_WEP40:
8873 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
8874 break;
8875
8876 case WLAN_CIPHER_SUITE_WEP104:
8877 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
8878 break;
8879
8880 case WLAN_CIPHER_SUITE_TKIP:
8881 {
8882 u8 *pKey = &setKey.Key[0];
8883 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
8884
8885 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
8886
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008887 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07008888
8889 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008890 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008891 |--------------|----------|----------|
8892 <---16bytes---><--8bytes--><--8bytes-->
8893
8894 */
8895 /*Sme expects the 32 bytes key to be in the below order
8896
8897 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008898 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07008899 |--------------|----------|----------|
8900 <---16bytes---><--8bytes--><--8bytes-->
8901 */
8902 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008903 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07008904
8905 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008906 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008907
8908 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008909 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07008910
8911
8912 break;
8913 }
8914
8915 case WLAN_CIPHER_SUITE_CCMP:
8916 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
8917 break;
8918
8919#ifdef FEATURE_WLAN_WAPI
8920 case WLAN_CIPHER_SUITE_SMS4:
8921 {
8922 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
8923 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
8924 params->key, params->key_len);
8925 return 0;
8926 }
8927#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008928
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008929#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 case WLAN_CIPHER_SUITE_KRK:
8931 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
8932 break;
8933#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07008934
8935#ifdef WLAN_FEATURE_11W
8936 case WLAN_CIPHER_SUITE_AES_CMAC:
8937 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07008938 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07008939#endif
8940
Jeff Johnson295189b2012-06-20 16:38:30 -07008941 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008942 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 __func__, params->cipher);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308944 status = -EOPNOTSUPP;
8945 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07008946 }
8947
8948 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
8949 __func__, setKey.encType);
8950
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008951 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07008952#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8953 (!pairwise)
8954#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008955 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07008956#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008957 )
8958 {
8959 /* set group key*/
8960 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8961 "%s- %d: setting Broadcast key",
8962 __func__, __LINE__);
8963 setKey.keyDirection = eSIR_RX_ONLY;
8964 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
8965 }
8966 else
8967 {
8968 /* set pairwise key*/
8969 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8970 "%s- %d: setting pairwise key",
8971 __func__, __LINE__);
8972 setKey.keyDirection = eSIR_TX_RX;
8973 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
8974 }
8975 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
8976 {
8977 setKey.keyDirection = eSIR_TX_RX;
8978 /*Set the group key*/
8979 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
8980 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008981
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008982 if ( 0 != status )
8983 {
8984 hddLog(VOS_TRACE_LEVEL_ERROR,
8985 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308986 status = -EINVAL;
8987 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008988 }
8989 /*Save the keys here and call sme_RoamSetKey for setting
8990 the PTK after peer joins the IBSS network*/
8991 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
8992 &setKey, sizeof(tCsrRoamSetKey));
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05308993 goto end;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07008994 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05308995 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
8996 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
8997 {
Jeff Johnson295189b2012-06-20 16:38:30 -07008998 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07008999 if( pHostapdState->bssState == BSS_START )
9000 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009001 status = WLANSAP_SetKeySta( pVosContext, &setKey);
9002
9003 if ( status != eHAL_STATUS_SUCCESS )
9004 {
9005 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9006 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9007 __LINE__, status );
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309008 status = -EINVAL;
9009 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009010 }
9011 }
9012
9013 /* Saving WEP keys */
9014 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
9015 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
9016 {
9017 //Save the wep key in ap context. Issue setkey after the BSS is started.
9018 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9019 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
9020 }
9021 else
9022 {
9023 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009024 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009025 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
9026 }
9027 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009028 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
9029 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009030 {
9031 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9032 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9033
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309034#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9035 if (!pairwise)
9036#else
9037 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
9038#endif
9039 {
9040 /* set group key*/
9041 if (pHddStaCtx->roam_info.deferKeyComplete)
9042 {
9043 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9044 "%s- %d: Perform Set key Complete",
9045 __func__, __LINE__);
9046 hdd_PerformRoamSetKeyComplete(pAdapter);
9047 }
9048 }
9049
Jeff Johnson295189b2012-06-20 16:38:30 -07009050 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
9051
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08009052 pWextState->roamProfile.Keys.defaultIndex = key_index;
9053
9054
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07009055 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009056 params->key, params->key_len);
9057
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309058
Jeff Johnson295189b2012-06-20 16:38:30 -07009059 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9060
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309061 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009062 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309063 __func__, setKey.peerMac[0], setKey.peerMac[1],
9064 setKey.peerMac[2], setKey.peerMac[3],
9065 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009066 setKey.keyDirection);
9067
Nirav Shah4f765af2015-01-21 19:51:30 +05309068 /* Wait for EAPOL M4 before setting key.
9069 * No need to consider Dynamic WEP as we will receive M8.
9070 */
9071 if ( (setKey.encType == eCSR_ENCRYPT_TYPE_AES ||
9072 setKey.encType == eCSR_ENCRYPT_TYPE_TKIP) &&
9073 ( 1
9074#if defined WLAN_FEATURE_VOWIFI_11R
9075 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_FT_RSN
9076 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_FT_RSN_PSK
9077#endif
9078#ifdef FEATURE_WLAN_ESE
9079 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_CCKM_WPA
9080 && pHddStaCtx->conn_info.authType != eCSR_AUTH_TYPE_CCKM_RSN
9081#endif
9082 ))
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 {
Nirav Shah4f765af2015-01-21 19:51:30 +05309084 vos_status = wlan_hdd_check_ula_done(pAdapter);
9085
9086 if ( vos_status != VOS_STATUS_SUCCESS )
9087 {
9088 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009089 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
9090 __LINE__, vos_status );
9091
Nirav Shah4f765af2015-01-21 19:51:30 +05309092 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009093
Nirav Shah4f765af2015-01-21 19:51:30 +05309094 status = -EINVAL;
9095 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009096
Nirav Shah4f765af2015-01-21 19:51:30 +05309097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009098 }
9099
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009100#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309101 /* The supplicant may attempt to set the PTK once pre-authentication
9102 is done. Save the key in the UMAC and include it in the ADD BSS
9103 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009104 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309105 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009106 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309107 hddLog(VOS_TRACE_LEVEL_INFO_MED,
9108 "%s: Update PreAuth Key success", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309109 status = 0;
9110 goto end;
Gopichand Nakkala3d295922013-05-07 16:19:14 +05309111 }
9112 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
9113 {
9114 hddLog(VOS_TRACE_LEVEL_ERROR,
9115 "%s: Update PreAuth Key failed", __func__);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309116 status = -EINVAL;
9117 goto end;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009118 }
9119#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07009120
9121 /* issue set key request to SME*/
9122 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
9123 pAdapter->sessionId, &setKey, &roamId );
9124
9125 if ( 0 != status )
9126 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309127 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009128 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
9129 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309130 status = -EINVAL;
9131 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009132 }
9133
9134
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309135 /* in case of IBSS as there was no information available about WEP keys during
9136 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07009137 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309138 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
9139 !( ( IW_AUTH_KEY_MGMT_802_1X
9140 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07009141 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
9142 )
9143 &&
9144 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
9145 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
9146 )
9147 )
9148 {
9149 setKey.keyDirection = eSIR_RX_ONLY;
9150 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
9151
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309152 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009153 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309154 __func__, setKey.peerMac[0], setKey.peerMac[1],
9155 setKey.peerMac[2], setKey.peerMac[3],
9156 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07009157 setKey.keyDirection);
9158
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309159 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009160 pAdapter->sessionId, &setKey, &roamId );
9161
9162 if ( 0 != status )
9163 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309164 hddLog(VOS_TRACE_LEVEL_ERROR,
9165 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009166 __func__, status);
9167 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309168 status = -EINVAL;
9169 goto end;
Jeff Johnson295189b2012-06-20 16:38:30 -07009170 }
9171 }
9172 }
9173
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309174end:
9175 /* Need to clear any trace of key value in the memory.
9176 * Thus zero out the memory even though it is local
9177 * variable.
9178 */
9179 vos_mem_zero(&setKey, sizeof(setKey));
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309180 EXIT();
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +05309181 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07009182}
9183
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309184#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9185static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9186 struct net_device *ndev,
9187 u8 key_index, bool pairwise,
9188 const u8 *mac_addr,
9189 struct key_params *params
9190 )
9191#else
9192static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
9193 struct net_device *ndev,
9194 u8 key_index, const u8 *mac_addr,
9195 struct key_params *params
9196 )
9197#endif
9198{
9199 int ret;
9200 vos_ssr_protect(__func__);
9201#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9202 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, pairwise,
9203 mac_addr, params);
9204#else
9205 ret = __wlan_hdd_cfg80211_add_key(wiphy, ndev, key_index, mac_addr,
9206 params);
9207#endif
9208 vos_ssr_unprotect(__func__);
9209
9210 return ret;
9211}
9212
Jeff Johnson295189b2012-06-20 16:38:30 -07009213/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309214 * FUNCTION: __wlan_hdd_cfg80211_get_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009215 * This function is used to get the key information
9216 */
9217#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309218static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309219 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009220 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309221 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009222 const u8 *mac_addr, void *cookie,
9223 void (*callback)(void *cookie, struct key_params*)
9224 )
9225#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309226static int __wlan_hdd_cfg80211_get_key(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309227 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009228 struct net_device *ndev,
9229 u8 key_index, const u8 *mac_addr, void *cookie,
9230 void (*callback)(void *cookie, struct key_params*)
9231 )
9232#endif
9233{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309234 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309235 hdd_wext_state_t *pWextState = NULL;
9236 tCsrRoamProfile *pRoamProfile = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009237 struct key_params params;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309238 hdd_context_t *pHddCtx;
9239 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07009240
9241 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309242
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309243 if (NULL == pAdapter)
9244 {
9245 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9246 "%s: HDD adapter is Null", __func__);
9247 return -ENODEV;
9248 }
9249
9250 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9251 ret = wlan_hdd_validate_context(pHddCtx);
9252 if (0 != ret)
9253 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +05309254 return ret;
9255 }
9256
9257 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9258 pRoamProfile = &(pWextState->roamProfile);
9259
Sushant Kaushik8bc7df22014-04-09 17:55:29 +05309260 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
9261 __func__, hdd_device_modetoString(pAdapter->device_mode),
9262 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309263
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 memset(&params, 0, sizeof(params));
9265
9266 if (CSR_MAX_NUM_KEY <= key_index)
9267 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +05309268 hddLog(VOS_TRACE_LEVEL_ERROR, FL("invalid key index %d"), key_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07009269 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009271
9272 switch(pRoamProfile->EncryptionType.encryptionType[0])
9273 {
9274 case eCSR_ENCRYPT_TYPE_NONE:
9275 params.cipher = IW_AUTH_CIPHER_NONE;
9276 break;
9277
9278 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9279 case eCSR_ENCRYPT_TYPE_WEP40:
9280 params.cipher = WLAN_CIPHER_SUITE_WEP40;
9281 break;
9282
9283 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9284 case eCSR_ENCRYPT_TYPE_WEP104:
9285 params.cipher = WLAN_CIPHER_SUITE_WEP104;
9286 break;
9287
9288 case eCSR_ENCRYPT_TYPE_TKIP:
9289 params.cipher = WLAN_CIPHER_SUITE_TKIP;
9290 break;
9291
9292 case eCSR_ENCRYPT_TYPE_AES:
9293 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
9294 break;
9295
9296 default:
9297 params.cipher = IW_AUTH_CIPHER_NONE;
9298 break;
9299 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309300
c_hpothuaaf19692014-05-17 17:01:48 +05309301 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9302 TRACE_CODE_HDD_CFG80211_GET_KEY,
9303 pAdapter->sessionId, params.cipher));
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309304
Jeff Johnson295189b2012-06-20 16:38:30 -07009305 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
9306 params.seq_len = 0;
9307 params.seq = NULL;
9308 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
9309 callback(cookie, &params);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309310 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009311 return 0;
9312}
9313
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309314#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9315static int wlan_hdd_cfg80211_get_key(
9316 struct wiphy *wiphy,
9317 struct net_device *ndev,
9318 u8 key_index, bool pairwise,
9319 const u8 *mac_addr, void *cookie,
9320 void (*callback)(void *cookie, struct key_params*)
9321 )
9322#else
9323static int wlan_hdd_cfg80211_get_key(
9324 struct wiphy *wiphy,
9325 struct net_device *ndev,
9326 u8 key_index, const u8 *mac_addr, void *cookie,
9327 void (*callback)(void *cookie, struct key_params*)
9328 )
9329#endif
9330{
9331 int ret;
9332
9333 vos_ssr_protect(__func__);
9334#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9335 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, pairwise,
9336 mac_addr, cookie, callback);
9337#else
9338 ret = __wlan_hdd_cfg80211_get_key(wiphy, ndev, key_index, mac_addr,
9339 callback);
9340#endif
9341 vos_ssr_unprotect(__func__);
9342
9343 return ret;
9344}
9345
Jeff Johnson295189b2012-06-20 16:38:30 -07009346/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309347 * FUNCTION: __wlan_hdd_cfg80211_del_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009348 * This function is used to delete the key information
9349 */
9350#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309351static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009352 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309353 u8 key_index,
9354 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07009355 const u8 *mac_addr
9356 )
9357#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309358static int __wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009359 struct net_device *ndev,
9360 u8 key_index,
9361 const u8 *mac_addr
9362 )
9363#endif
9364{
9365 int status = 0;
9366
9367 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309368 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009369 //it is observed that this is invalidating peer
9370 //key index whenever re-key is done. This is affecting data link.
9371 //It should be ok to ignore del_key.
9372#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309373 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
9374 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
9376 tCsrRoamSetKey setKey;
9377 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309378
Jeff Johnson295189b2012-06-20 16:38:30 -07009379 ENTER();
9380
9381 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
9382 __func__,pAdapter->device_mode);
9383
9384 if (CSR_MAX_NUM_KEY <= key_index)
9385 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309386 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009387 key_index);
9388
9389 return -EINVAL;
9390 }
9391
9392 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9393 setKey.keyId = key_index;
9394
9395 if (mac_addr)
9396 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
9397 else
9398 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
9399
9400 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
9401
9402 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07009403 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309404 )
9405 {
9406
9407 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07009408 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
9409 if( pHostapdState->bssState == BSS_START)
9410 {
9411 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309412
Jeff Johnson295189b2012-06-20 16:38:30 -07009413 if ( status != eHAL_STATUS_SUCCESS )
9414 {
9415 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9416 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
9417 __LINE__, status );
9418 }
9419 }
9420 }
9421 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309422 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07009423 )
9424 {
9425 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9426
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309427 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
9428
9429 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07009430 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309431 __func__, setKey.peerMac[0], setKey.peerMac[1],
9432 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309434 if(pAdapter->sessionCtx.station.conn_info.connState ==
9435 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07009436 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309437 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309439
Jeff Johnson295189b2012-06-20 16:38:30 -07009440 if ( 0 != status )
9441 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309442 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07009443 "%s: sme_RoamSetKey failure, returned %d",
9444 __func__, status);
9445 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
9446 return -EINVAL;
9447 }
9448 }
9449 }
9450#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07009451 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 return status;
9453}
9454
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05309455#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9456static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9457 struct net_device *ndev,
9458 u8 key_index,
9459 bool pairwise,
9460 const u8 *mac_addr
9461 )
9462#else
9463static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
9464 struct net_device *ndev,
9465 u8 key_index,
9466 const u8 *mac_addr
9467 )
9468#endif
9469{
9470 int ret;
9471
9472 vos_ssr_protect(__func__);
9473#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9474 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, pairwise,
9475 mac_addr);
9476#else
9477 ret = __wlan_hdd_cfg80211_del_key(wiphy, ndev, key_index, mac_addr);
9478#endif
9479 vos_ssr_unprotect(__func__);
9480
9481 return ret;
9482}
9483
Jeff Johnson295189b2012-06-20 16:38:30 -07009484/*
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309485 * FUNCTION: __wlan_hdd_cfg80211_set_default_key
Jeff Johnson295189b2012-06-20 16:38:30 -07009486 * This function is used to set the default tx key index
9487 */
9488#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
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 bool unicast, bool multicast)
9493#else
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309494static int __wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07009495 struct net_device *ndev,
9496 u8 key_index)
9497#endif
9498{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309499 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309500 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05309501 hdd_wext_state_t *pWextState;
9502 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309503 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009504
9505 ENTER();
9506
Gopichand Nakkala29149562013-05-10 21:43:41 +05309507 if ((NULL == pAdapter))
9508 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala29149562013-05-10 21:43:41 +05309510 "invalid adapter");
9511 return -EINVAL;
9512 }
9513
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309514 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9515 TRACE_CODE_HDD_CFG80211_SET_DEFAULT_KEY,
9516 pAdapter->sessionId, key_index));
9517
Gopichand Nakkala29149562013-05-10 21:43:41 +05309518 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
9519 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
9520
9521 if ((NULL == pWextState) || (NULL == pHddStaCtx))
9522 {
9523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9524 "invalid Wext state or HDD context");
9525 return -EINVAL;
9526 }
9527
Arif Hussain6d2a3322013-11-17 19:50:10 -08009528 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309530
Jeff Johnson295189b2012-06-20 16:38:30 -07009531 if (CSR_MAX_NUM_KEY <= key_index)
9532 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309533 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009534 key_index);
9535
9536 return -EINVAL;
9537 }
9538
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309539 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9540 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309541 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009542 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05309543 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009544 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309545
Jeff Johnson295189b2012-06-20 16:38:30 -07009546 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07009547 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309548 )
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05309550 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08009551 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309552 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08009553 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309555 {
9556 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07009557 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309558
Jeff Johnson295189b2012-06-20 16:38:30 -07009559 tCsrRoamSetKey setKey;
9560 v_U32_t roamId= 0xFF;
9561 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309562
9563 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07009564 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309565
Jeff Johnson295189b2012-06-20 16:38:30 -07009566 Keys->defaultIndex = (u8)key_index;
9567 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
9568 setKey.keyId = key_index;
9569 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309570
9571 vos_mem_copy(&setKey.Key[0],
9572 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07009573 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309574
Gopichand Nakkala29149562013-05-10 21:43:41 +05309575 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309576
9577 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07009578 &pHddStaCtx->conn_info.bssId[0],
9579 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309580
Gopichand Nakkala29149562013-05-10 21:43:41 +05309581 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
9582 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
9583 eCSR_ENCRYPT_TYPE_WEP104)
9584 {
9585 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
9586 even though ap is configured for WEP-40 encryption. In this canse the key length
9587 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
9588 type(104) and switching encryption type to 40*/
9589 pWextState->roamProfile.EncryptionType.encryptionType[0] =
9590 eCSR_ENCRYPT_TYPE_WEP40;
9591 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
9592 eCSR_ENCRYPT_TYPE_WEP40;
9593 }
9594
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309595 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309597
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309599 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07009600 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309601
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 if ( 0 != status )
9603 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309604 hddLog(VOS_TRACE_LEVEL_ERROR,
9605 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07009606 status);
9607 return -EINVAL;
9608 }
9609 }
9610 }
9611
9612 /* In SoftAp mode setting key direction for default mode */
9613 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
9614 {
9615 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
9616 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
9617 (eCSR_ENCRYPT_TYPE_AES !=
9618 pWextState->roamProfile.EncryptionType.encryptionType[0])
9619 )
9620 {
9621 /* Saving key direction for default key index to TX default */
9622 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
9623 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
9624 }
9625 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309626 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009627 return status;
9628}
9629
Mahesh A Saptasagar1a51bc02014-06-02 18:28:08 +05309630#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9631static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9632 struct net_device *ndev,
9633 u8 key_index,
9634 bool unicast, bool multicast)
9635#else
9636static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
9637 struct net_device *ndev,
9638 u8 key_index)
9639#endif
9640{
9641 int ret;
9642 vos_ssr_protect(__func__);
9643#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9644 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index, unicast,
9645 multicast);
9646#else
9647 ret = __wlan_hdd_cfg80211_set_default_key(wiphy, ndev, key_index);
9648#endif
9649 vos_ssr_unprotect(__func__);
9650
9651 return ret;
9652}
9653
Jeff Johnson295189b2012-06-20 16:38:30 -07009654/*
9655 * FUNCTION: wlan_hdd_cfg80211_inform_bss
9656 * This function is used to inform the BSS details to nl80211 interface.
9657 */
9658static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
9659 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
9660{
9661 struct net_device *dev = pAdapter->dev;
9662 struct wireless_dev *wdev = dev->ieee80211_ptr;
9663 struct wiphy *wiphy = wdev->wiphy;
9664 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
9665 int chan_no;
9666 int ie_length;
9667 const char *ie;
9668 unsigned int freq;
9669 struct ieee80211_channel *chan;
9670 int rssi = 0;
9671 struct cfg80211_bss *bss = NULL;
9672
9673 ENTER();
9674
9675 if( NULL == pBssDesc )
9676 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009677 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009678 return bss;
9679 }
9680
9681 chan_no = pBssDesc->channelId;
9682 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
9683 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
9684
9685 if( NULL == ie )
9686 {
Arif Hussain6d2a3322013-11-17 19:50:10 -08009687 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009688 return bss;
9689 }
9690
9691#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
9692 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
9693 {
9694 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9695 }
9696 else
9697 {
9698 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9699 }
9700#else
9701 freq = ieee80211_channel_to_frequency(chan_no);
9702#endif
9703
9704 chan = __ieee80211_get_channel(wiphy, freq);
9705
Santhosh Kumar Padmaa45fdb12014-04-15 15:54:38 +05309706 if (!chan) {
9707 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
9708 return NULL;
9709 }
9710
Abhishek Singhaee43942014-06-16 18:55:47 +05309711 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009712
Abhishek Singhaee43942014-06-16 18:55:47 +05309713 return cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309714 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07009715 pBssDesc->capabilityInfo,
9716 pBssDesc->beaconInterval, ie, ie_length,
Abhishek Singhaee43942014-06-16 18:55:47 +05309717 rssi, GFP_KERNEL );
Jeff Johnson295189b2012-06-20 16:38:30 -07009718}
9719
9720
9721
9722/*
9723 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
9724 * This function is used to inform the BSS details to nl80211 interface.
9725 */
9726struct cfg80211_bss*
9727wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
9728 tSirBssDescription *bss_desc
9729 )
9730{
9731 /*
9732 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
9733 already exists in bss data base of cfg80211 for that particular BSS ID.
9734 Using cfg80211_inform_bss_frame to update the bss entry instead of
9735 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
9736 now there is no possibility to get the mgmt(probe response) frame from PE,
9737 converting bss_desc to ieee80211_mgmt(probe response) and passing to
9738 cfg80211_inform_bss_frame.
9739 */
9740 struct net_device *dev = pAdapter->dev;
9741 struct wireless_dev *wdev = dev->ieee80211_ptr;
9742 struct wiphy *wiphy = wdev->wiphy;
9743 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009744#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9745 qcom_ie_age *qie_age = NULL;
9746 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
9747#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009748 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009749#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009750 const char *ie =
9751 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
9752 unsigned int freq;
9753 struct ieee80211_channel *chan;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309754 struct ieee80211_mgmt *mgmt = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07009755 struct cfg80211_bss *bss_status = NULL;
9756 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
9757 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07009758 hdd_context_t *pHddCtx;
9759 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07009760#ifdef WLAN_OPEN_SOURCE
9761 struct timespec ts;
9762#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009763
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309764 ENTER();
9765
Wilson Yangf80a0542013-10-07 13:02:37 -07009766 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9767 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yangf80a0542013-10-07 13:02:37 -07009768 if (0 != status)
9769 {
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009770 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009771 }
9772
Abhishek Singh1e2bfa32014-01-02 15:44:15 +05309773 mgmt = kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
Wilson Yangf80a0542013-10-07 13:02:37 -07009774 if (!mgmt)
9775 {
9776 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9777 "%s: memory allocation failed ", __func__);
9778 return NULL;
9779 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07009780
Jeff Johnson295189b2012-06-20 16:38:30 -07009781 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07009782
9783#ifdef WLAN_OPEN_SOURCE
9784 /* Android does not want the timestamp from the frame.
9785 Instead it wants a monotonic increasing value */
9786 get_monotonic_boottime(&ts);
9787 mgmt->u.probe_resp.timestamp =
9788 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
9789#else
9790 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
9792 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07009793
9794#endif
9795
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
9797 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08009798
9799#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
9800 /* GPS Requirement: need age ie per entry. Using vendor specific. */
9801 /* Assuming this is the last IE, copy at the end */
9802 ie_length -=sizeof(qcom_ie_age);
9803 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
9804 qie_age->element_id = QCOM_VENDOR_IE_ID;
9805 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
9806 qie_age->oui_1 = QCOM_OUI1;
9807 qie_age->oui_2 = QCOM_OUI2;
9808 qie_age->oui_3 = QCOM_OUI3;
9809 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
9810 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
9811#endif
9812
Jeff Johnson295189b2012-06-20 16:38:30 -07009813 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05309814 if (bss_desc->fProbeRsp)
9815 {
9816 mgmt->frame_control |=
9817 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
9818 }
9819 else
9820 {
9821 mgmt->frame_control |=
9822 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
9823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009824
9825#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309826 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009827 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
9828 {
9829 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
9830 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309831 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07009832 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
9833
9834 {
9835 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
9836 }
9837 else
9838 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309839 hddLog(VOS_TRACE_LEVEL_ERROR, "%s Invalid chan_no:%d",
9840 __func__, chan_no);
Jeff Johnson295189b2012-06-20 16:38:30 -07009841 kfree(mgmt);
9842 return NULL;
9843 }
9844#else
9845 freq = ieee80211_channel_to_frequency(chan_no);
9846#endif
9847 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009848 /*when the band is changed on the fly using the GUI, three things are done
9849 * 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)
9850 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
9851 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
9852 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
9853 * and discards the channels correponding to previous band and calls back with zero bss results.
9854 * 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
9855 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
9856 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
9857 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
9858 * So drop the bss and continue to next bss.
9859 */
9860 if(chan == NULL)
9861 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309862 hddLog(VOS_TRACE_LEVEL_ERROR, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07009863 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08009864 return NULL;
9865 }
Sachin Ahuja40530ed2015-04-20 00:20:58 +05309866 /* Supplicant takes the signal strength in terms of mBm(100*dBm) */
9867 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0)) * 100;
Jeff Johnson295189b2012-06-20 16:38:30 -07009868
Nirav Shah20ac06f2013-12-12 18:14:06 +05309869 hddLog(VOS_TRACE_LEVEL_INFO, "%s: BSSID:" MAC_ADDRESS_STR " Channel:%d"
9870 "RSSI:%d", __func__, MAC_ADDR_ARRAY(mgmt->bssid),
9871 chan->center_freq, (int)(rssi/100));
9872
Jeff Johnson295189b2012-06-20 16:38:30 -07009873 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
9874 frame_len, rssi, GFP_KERNEL);
9875 kfree(mgmt);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05309876 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07009877 return bss_status;
9878}
9879
9880/*
9881 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
9882 * This function is used to update the BSS data base of CFG8011
9883 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309884struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07009885 tCsrRoamInfo *pRoamInfo
9886 )
9887{
9888 tCsrRoamConnectedProfile roamProfile;
9889 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
9890 struct cfg80211_bss *bss = NULL;
9891
9892 ENTER();
9893
9894 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
9895 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
9896
9897 if (NULL != roamProfile.pBssDesc)
9898 {
Girish Gowlif4b68022014-08-28 23:18:57 +05309899 bss = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9900 roamProfile.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009901
9902 if (NULL == bss)
9903 {
9904 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
9905 __func__);
9906 }
9907
9908 sme_RoamFreeConnectProfile(hHal, &roamProfile);
9909 }
9910 else
9911 {
9912 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
9913 __func__);
9914 }
9915 return bss;
9916}
9917
9918/*
9919 * FUNCTION: wlan_hdd_cfg80211_update_bss
9920 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309921static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
9922 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309924{
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309925 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07009926 tCsrScanResultInfo *pScanResult;
9927 eHalStatus status = 0;
9928 tScanResultHandle pResult;
9929 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07009930 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07009931
9932 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +05309933
Sushant Kaushik4b7cb302014-01-06 17:45:01 +05309934 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
9935 TRACE_CODE_HDD_CFG80211_UPDATE_BSS,
9936 NO_SESSION, pAdapter->sessionId));
9937
Wilson Yangf80a0542013-10-07 13:02:37 -07009938 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
9939
9940 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07009941 {
Wilson Yangf80a0542013-10-07 13:02:37 -07009942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9943 "%s:LOGP in Progress. Ignore!!!",__func__);
9944 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07009945 }
9946
Wilson Yangf80a0542013-10-07 13:02:37 -07009947
9948 /*bss_update is not allowed during wlan driver loading or unloading*/
Mihir Shete18156292014-03-11 15:38:30 +05309949 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Wilson Yangf80a0542013-10-07 13:02:37 -07009950 {
9951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9952 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
9953 return VOS_STATUS_E_PERM;
9954 }
9955
9956
Jeff Johnson295189b2012-06-20 16:38:30 -07009957 /*
9958 * start getting scan results and populate cgf80211 BSS database
9959 */
9960 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
9961
9962 /* no scan results */
9963 if (NULL == pResult)
9964 {
Nirav Shah20ac06f2013-12-12 18:14:06 +05309965 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result Status %d",
9966 __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -07009967 return status;
9968 }
9969
9970 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
9971
9972 while (pScanResult)
9973 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309974 /*
9975 * cfg80211_inform_bss() is not updating ie field of bss entry, if
9976 * entry already exists in bss data base of cfg80211 for that
9977 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
9978 * bss entry instead of cfg80211_inform_bss, But this call expects
9979 * mgmt packet as input. As of now there is no possibility to get
9980 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07009981 * ieee80211_mgmt(probe response) and passing to c
9982 * fg80211_inform_bss_frame.
9983 * */
9984
9985 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
9986 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309987
Jeff Johnson295189b2012-06-20 16:38:30 -07009988
9989 if (NULL == bss_status)
9990 {
9991 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -08009992 "%s: NULL returned by cfg80211_inform_bss", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07009993 }
9994 else
9995 {
Yue Maf49ba872013-08-19 12:04:25 -07009996 cfg80211_put_bss(
9997#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
9998 wiphy,
9999#endif
10000 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010001 }
10002
10003 pScanResult = sme_ScanResultGetNext(hHal, pResult);
10004 }
10005
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010006 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010007
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010008 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010009}
10010
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010011void
10012hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
10013{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010014 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -080010015 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010016} /****** end hddPrintMacAddr() ******/
10017
10018void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010019hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010020{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010021 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussain6d2a3322013-11-17 19:50:10 -080010022 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070010023 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
10024 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
10025 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010026} /****** end hddPrintPmkId() ******/
10027
10028//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
10029//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
10030
10031//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
10032//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
10033
10034#define dump_bssid(bssid) \
10035 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010036 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
10037 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010038 }
10039
10040#define dump_pmkid(pMac, pmkid) \
10041 { \
Jeff Johnsone7245742012-09-05 17:12:55 -070010042 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
10043 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010044 }
10045
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -070010046#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010047/*
10048 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
10049 * This function is used to notify the supplicant of a new PMKSA candidate.
10050 */
10051int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010052 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010053 int index, bool preauth )
10054{
Jeff Johnsone7245742012-09-05 17:12:55 -070010055#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010056 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010057 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010058
10059 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -070010060 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010061
10062 if( NULL == pRoamInfo )
10063 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010064 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010065 return -EINVAL;
10066 }
10067
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010068 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
10069 {
10070 dump_bssid(pRoamInfo->bssid);
10071 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010072 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -070010073 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010074#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010075 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010076}
10077#endif //FEATURE_WLAN_LFR
10078
Yue Maef608272013-04-08 23:09:17 -070010079#ifdef FEATURE_WLAN_LFR_METRICS
10080/*
10081 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
10082 * 802.11r/LFR metrics reporting function to report preauth initiation
10083 *
10084 */
10085#define MAX_LFR_METRICS_EVENT_LENGTH 100
10086VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
10087 tCsrRoamInfo *pRoamInfo)
10088{
10089 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10090 union iwreq_data wrqu;
10091
10092 ENTER();
10093
10094 if (NULL == pAdapter)
10095 {
10096 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10097 return VOS_STATUS_E_FAILURE;
10098 }
10099
10100 /* create the event */
10101 memset(&wrqu, 0, sizeof(wrqu));
10102 memset(metrics_notification, 0, sizeof(metrics_notification));
10103
10104 wrqu.data.pointer = metrics_notification;
10105 wrqu.data.length = scnprintf(metrics_notification,
10106 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
10107 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10108
10109 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10110
10111 EXIT();
10112
10113 return VOS_STATUS_SUCCESS;
10114}
10115
10116/*
10117 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
10118 * 802.11r/LFR metrics reporting function to report preauth completion
10119 * or failure
10120 */
10121VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
10122 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
10123{
10124 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10125 union iwreq_data wrqu;
10126
10127 ENTER();
10128
10129 if (NULL == pAdapter)
10130 {
10131 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10132 return VOS_STATUS_E_FAILURE;
10133 }
10134
10135 /* create the event */
10136 memset(&wrqu, 0, sizeof(wrqu));
10137 memset(metrics_notification, 0, sizeof(metrics_notification));
10138
10139 scnprintf(metrics_notification, sizeof(metrics_notification),
10140 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
10141 MAC_ADDR_ARRAY(pRoamInfo->bssid));
10142
10143 if (1 == preauth_status)
10144 strncat(metrics_notification, " TRUE", 5);
10145 else
10146 strncat(metrics_notification, " FALSE", 6);
10147
10148 wrqu.data.pointer = metrics_notification;
10149 wrqu.data.length = strlen(metrics_notification);
10150
10151 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10152
10153 EXIT();
10154
10155 return VOS_STATUS_SUCCESS;
10156}
10157
10158/*
10159 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
10160 * 802.11r/LFR metrics reporting function to report handover initiation
10161 *
10162 */
10163VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
10164 tCsrRoamInfo *pRoamInfo)
10165{
10166 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
10167 union iwreq_data wrqu;
10168
10169 ENTER();
10170
10171 if (NULL == pAdapter)
10172 {
10173 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
10174 return VOS_STATUS_E_FAILURE;
10175 }
10176
10177 /* create the event */
10178 memset(&wrqu, 0, sizeof(wrqu));
10179 memset(metrics_notification, 0, sizeof(metrics_notification));
10180
10181 wrqu.data.pointer = metrics_notification;
10182 wrqu.data.length = scnprintf(metrics_notification,
10183 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
10184 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
10185
10186 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
10187
10188 EXIT();
10189
10190 return VOS_STATUS_SUCCESS;
10191}
10192#endif
10193
Jeff Johnson295189b2012-06-20 16:38:30 -070010194/*
10195 * FUNCTION: hdd_cfg80211_scan_done_callback
10196 * scanning callback function, called after finishing scan
10197 *
10198 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010199static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -070010200 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
10201{
10202 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010203 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -070010204 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010205 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 struct cfg80211_scan_request *req = NULL;
10207 int ret = 0;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010208 bool aborted = false;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010209 long waitRet = 0;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010210 tANI_U8 i;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010211 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070010212
10213 ENTER();
10214
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053010215 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
10216 if (0 != wlan_hdd_validate_context(pHddCtx)) {
10217 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Invalid HDD context"));
10218 goto allow_suspend;
10219 }
10220
10221 pScanInfo = &pHddCtx->scan_info;
10222
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 hddLog(VOS_TRACE_LEVEL_INFO,
10224 "%s called with halHandle = %p, pContext = %p,"
Arif Hussain6d2a3322013-11-17 19:50:10 -080010225 "scanID = %d, returned status = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070010226 __func__, halHandle, pContext, (int) scanId, (int) status);
10227
Kiet Lamac06e2c2013-10-23 16:25:07 +053010228 pScanInfo->mScanPendingCounter = 0;
10229
Jeff Johnson295189b2012-06-20 16:38:30 -070010230 //Block on scan req completion variable. Can't wait forever though.
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010231 waitRet = wait_for_completion_interruptible_timeout(
Jeff Johnson295189b2012-06-20 16:38:30 -070010232 &pScanInfo->scan_req_completion_event,
10233 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010234 if (waitRet <= 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070010235 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053010236 hddLog(VOS_TRACE_LEVEL_ERROR,
10237 "%s wait on scan_req_completion_event failed %ld",__func__, waitRet);
Jeff Johnson295189b2012-06-20 16:38:30 -070010238 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010239 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010240 }
10241
Yue Maef608272013-04-08 23:09:17 -070010242 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -070010243 {
10244 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -070010245 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010246 }
10247
10248 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010249 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -070010250 {
10251 hddLog(VOS_TRACE_LEVEL_INFO,
10252 "%s called with mismatched scanId pScanInfo->scanId = %d "
Arif Hussain6d2a3322013-11-17 19:50:10 -080010253 "scanId = %d", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -070010254 (int) scanId);
10255 }
10256
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010257 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070010258 pAdapter);
10259
10260 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010261 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010262
10263
10264 /* If any client wait scan result through WEXT
10265 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010266 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -070010267 {
10268 /* The other scan request waiting for current scan finish
10269 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010270 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010271 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010272 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -070010273 }
10274 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010275 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -070010276 {
10277 struct net_device *dev = pAdapter->dev;
10278 union iwreq_data wrqu;
10279 int we_event;
10280 char *msg;
10281
10282 memset(&wrqu, '\0', sizeof(wrqu));
10283 we_event = SIOCGIWSCAN;
10284 msg = NULL;
10285 wireless_send_event(dev, we_event, &wrqu, msg);
10286 }
10287 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -070010288 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010289
10290 /* Get the Scan Req */
10291 req = pAdapter->request;
10292
10293 if (!req)
10294 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080010295 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010296 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -070010297 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -070010298 }
10299
Jeff Johnson295189b2012-06-20 16:38:30 -070010300 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -070010301 /* Scan is no longer pending */
10302 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010303
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010304 /* last_scan_timestamp is used to decide if new scan
10305 * is needed or not on station interface. If last station
10306 * scan time and new station scan time is less then
10307 * last_scan_timestamp ; driver will return cached scan.
10308 */
10309 if (req->no_cck == FALSE && status == eCSR_SCAN_SUCCESS) // no_cck will be set during p2p find
10310 {
10311 pScanInfo->last_scan_timestamp = vos_timer_get_system_time();
10312
10313 if ( req->n_channels )
10314 {
10315 for (i = 0; i < req->n_channels ; i++ )
10316 {
10317 pHddCtx->scan_info.last_scan_channelList[i] = req->channels[i]->hw_value;
10318 }
10319 /* store no of channel scanned */
10320 pHddCtx->scan_info.last_scan_numChannels= req->n_channels;
10321 }
10322
10323 }
10324
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -070010325 /*
10326 * cfg80211_scan_done informing NL80211 about completion
10327 * of scanning
10328 */
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053010329 if (status == eCSR_SCAN_ABORT || status == eCSR_SCAN_FAILURE)
10330 {
10331 aborted = true;
10332 }
10333 cfg80211_scan_done(req, aborted);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -080010334 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -070010335
Siddharth Bhal76972212014-10-15 16:22:51 +053010336 if (pHddCtx->spoofMacAddr.isEnabled || pHddCtx->spoofMacAddr.isReqDeferred) {
10337 /* Generate new random mac addr for next scan */
10338 hddLog(VOS_TRACE_LEVEL_INFO, "scan completed - generate new spoof mac addr");
10339 hdd_processSpoofMacAddrRequest(pHddCtx);
10340 }
10341
Jeff Johnsone7245742012-09-05 17:12:55 -070010342allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010343 /* release the wake lock at the end of the scan*/
10344 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -070010345
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010346 /* Acquire wakelock to handle the case where APP's tries to suspend
10347 * immediatly after the driver gets connect request(i.e after scan)
10348 * from supplicant, this result in app's is suspending and not able
10349 * to process the connect request to AP */
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053010350 hdd_prevent_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -070010351
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010352#ifdef FEATURE_WLAN_TDLS
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010353 wlan_hdd_tdls_scan_done_callback(pAdapter);
Gopichand Nakkala638ebc72013-03-21 18:04:02 -070010354#endif
10355
Jeff Johnson295189b2012-06-20 16:38:30 -070010356 EXIT();
10357 return 0;
10358}
10359
10360/*
Rashmi Ramannab1429032014-04-26 14:59:09 +053010361 * FUNCTION: hdd_isConnectionInProgress
10362 * Go through each adapter and check if Connection is in progress
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010363 *
10364 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010365v_BOOL_t hdd_isConnectionInProgress( hdd_context_t *pHddCtx)
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010366{
10367 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
10368 hdd_station_ctx_t *pHddStaCtx = NULL;
10369 hdd_adapter_t *pAdapter = NULL;
10370 VOS_STATUS status = 0;
10371 v_U8_t staId = 0;
10372 v_U8_t *staMac = NULL;
10373
c_hpothu9b781ba2013-12-30 20:57:45 +053010374 if (TRUE == pHddCtx->btCoexModeSet)
10375 {
10376 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Rashmi Ramannab1429032014-04-26 14:59:09 +053010377 FL("BTCoex Mode operation in progress"));
10378 return VOS_TRUE;
c_hpothu9b781ba2013-12-30 20:57:45 +053010379 }
10380
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010381 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
10382
10383 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
10384 {
10385 pAdapter = pAdapterNode->pAdapter;
10386
10387 if( pAdapter )
10388 {
10389 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010390 "%s: Adapter with device mode %s (%d) exists",
10391 __func__, hdd_device_modetoString(pAdapter->device_mode),
10392 pAdapter->device_mode);
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010393 if (((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Rashmi Ramannab1429032014-04-26 14:59:09 +053010394 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10395 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)) &&
10396 (eConnectionState_Connecting ==
10397 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
10398 {
10399 hddLog(VOS_TRACE_LEVEL_ERROR,
10400 "%s: %p(%d) Connection is in progress", __func__,
10401 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10402 return VOS_TRUE;
10403 }
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010404 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Padma, Santhosh Kumar3b9657d2015-02-04 19:37:32 +053010405 smeNeighborMiddleOfRoaming(WLAN_HDD_GET_HAL_CTX(pAdapter)))
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010406 {
10407 hddLog(VOS_TRACE_LEVEL_ERROR,
10408 "%s: %p(%d) Reassociation is in progress", __func__,
10409 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
10410 return VOS_TRUE;
10411 }
10412 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010413 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10414 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010415 {
10416 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
10417 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010418 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010419 {
10420 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
10421 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010422 "%s: client " MAC_ADDRESS_STR
10423 " is in the middle of WPS/EAPOL exchange.", __func__,
10424 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010425 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010426 }
10427 }
10428 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
10429 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
10430 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010431 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
10432 ptSapContext pSapCtx = NULL;
10433 pSapCtx = VOS_GET_SAP_CB(pVosContext);
10434 if(pSapCtx == NULL){
10435 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
10436 FL("psapCtx is NULL"));
10437 return VOS_FALSE;
10438 }
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010439 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
10440 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010441 if ((pSapCtx->aStaInfo[staId].isUsed) &&
10442 (WLANTL_STA_CONNECTED == pSapCtx->aStaInfo[staId].tlSTAState))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010443 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053010444 staMac = (v_U8_t *) &(pSapCtx->aStaInfo[staId].macAddrSTA.bytes[0]);
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010445
10446 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -080010447 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
10448 "middle of WPS/EAPOL exchange.", __func__,
10449 MAC_ADDR_ARRAY(staMac));
Rashmi Ramannab1429032014-04-26 14:59:09 +053010450 return VOS_TRUE;
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010451 }
10452 }
10453 }
10454 }
10455 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
10456 pAdapterNode = pNext;
10457 }
Rashmi Ramannab1429032014-04-26 14:59:09 +053010458 return VOS_FALSE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010459}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010460
10461/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010462 * FUNCTION: __wlan_hdd_cfg80211_scan
Jeff Johnson295189b2012-06-20 16:38:30 -070010463 * this scan respond to scan trigger and update cfg80211 scan database
10464 * later, scan dump command can be used to recieve scan results
10465 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010466int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080010467#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10468 struct net_device *dev,
10469#endif
10470 struct cfg80211_scan_request *request)
10471{
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010472 hdd_adapter_t *pAdapter = NULL;
10473 hdd_context_t *pHddCtx = NULL;
10474 hdd_wext_state_t *pwextBuf = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010475 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010476 tCsrScanRequest scanRequest;
10477 tANI_U8 *channelList = NULL, i;
10478 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010479 int status;
10480 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070010481 v_U8_t* pP2pIe = NULL;
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010482 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010483
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010484#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
10485 struct net_device *dev = NULL;
10486 if (NULL == request)
10487 {
10488 hddLog(VOS_TRACE_LEVEL_ERROR,
10489 "%s: scan req param null", __func__);
10490 return -EINVAL;
10491 }
10492 dev = request->wdev->netdev;
10493#endif
10494
10495 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
10496 pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
10497 pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
10498
Jeff Johnson295189b2012-06-20 16:38:30 -070010499 ENTER();
10500
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010501 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)",
10502 __func__, hdd_device_modetoString(pAdapter->device_mode),
10503 pAdapter->device_mode);
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053010504
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010505 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010506 if (0 != status)
10507 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010508 return status;
10509 }
10510
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010511 if (NULL == pwextBuf)
10512 {
10513 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: invalid WEXT state\n",
10514 __func__);
10515 return -EIO;
10516 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053010517 cfg_param = pHddCtx->cfg_ini;
10518 pScanInfo = &pHddCtx->scan_info;
10519
Jeff Johnson295189b2012-06-20 16:38:30 -070010520#ifdef WLAN_BTAMP_FEATURE
10521 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010522 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -070010523 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080010524 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010525 "%s: No scanning when AMP is on", __func__);
10526 return -EOPNOTSUPP;
10527 }
10528#endif
10529 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010530 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -070010531 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010532 hddLog(VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010533 "%s: Not scanning on device_mode = %s (%d)",
10534 __func__, hdd_device_modetoString(pAdapter->device_mode),
10535 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070010536 return -EOPNOTSUPP;
10537 }
10538
10539 if (TRUE == pScanInfo->mScanPending)
10540 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010541 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
10542 {
10543 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
10544 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010545 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010546 }
10547
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010548 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -070010549 //Channel and action frame is pending
10550 //Otherwise Cancel Remain On Channel and allow Scan
10551 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -080010552 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -070010553 {
Kiet Lamac06e2c2013-10-23 16:25:07 +053010554 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010555 return -EBUSY;
10556 }
10557
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
10559 {
10560 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -080010561 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070010562 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010563 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
10565 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010566 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 "%s: MAX TM Level Scan not allowed", __func__);
10568 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010569 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -070010570 }
10571 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
10572
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010573 /* Check if scan is allowed at this point of time.
10574 */
Padma, Santhosh Kumar98f271d2014-12-31 17:23:31 +053010575 if (hdd_isConnectionInProgress(pHddCtx))
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -080010576 {
10577 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
10578 return -EBUSY;
10579 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053010580
Jeff Johnson295189b2012-06-20 16:38:30 -070010581 vos_mem_zero( &scanRequest, sizeof(scanRequest));
10582
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010583 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
10584 (int)request->n_ssids);
10585
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010586
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010587 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
10588 * Becasue of this, driver is assuming that this is not wildcard scan and so
10589 * is not aging out the scan results.
10590 */
10591 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -070010592 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010593 request->n_ssids = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010595
10596 if ((request->ssids) && (0 < request->n_ssids))
10597 {
10598 tCsrSSIDInfo *SsidInfo;
10599 int j;
10600 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
10601 /* Allocate num_ssid tCsrSSIDInfo structure */
10602 SsidInfo = scanRequest.SSIDs.SSIDList =
10603 ( tCsrSSIDInfo *)vos_mem_malloc(
10604 request->n_ssids*sizeof(tCsrSSIDInfo));
10605
10606 if(NULL == scanRequest.SSIDs.SSIDList)
10607 {
10608 hddLog(VOS_TRACE_LEVEL_ERROR,
10609 "%s: memory alloc failed SSIDInfo buffer", __func__);
10610 return -ENOMEM;
10611 }
10612
10613 /* copy all the ssid's and their length */
10614 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
10615 {
10616 /* get the ssid length */
10617 SsidInfo->SSID.length = request->ssids[j].ssid_len;
10618 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
10619 SsidInfo->SSID.length);
10620 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
10621 hddLog(VOS_TRACE_LEVEL_INFO, "SSID number %d: %s",
10622 j, SsidInfo->SSID.ssId);
10623 }
10624 /* set the scan type to active */
10625 scanRequest.scanType = eSIR_ACTIVE_SCAN;
10626 }
10627 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070010628 {
Siddharth Bhal0c162d02014-05-06 19:50:42 +053010629 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
10630 TRACE_CODE_HDD_CFG80211_SCAN,
10631 pAdapter->sessionId, 0));
Jeff Johnson295189b2012-06-20 16:38:30 -070010632 /* set the scan type to active */
10633 scanRequest.scanType = eSIR_ACTIVE_SCAN;
Jeff Johnson295189b2012-06-20 16:38:30 -070010634 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010635 else
10636 {
10637 /*Set the scan type to default type, in this case it is ACTIVE*/
10638 scanRequest.scanType = pScanInfo->scan_mode;
10639 }
10640 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
10641 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -070010642
10643 /* set BSSType to default type */
10644 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
10645
10646 /*TODO: scan the requested channels only*/
10647
10648 /*Right now scanning all the channels */
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010649 if (MAX_CHANNEL < request->n_channels)
Jeff Johnson295189b2012-06-20 16:38:30 -070010650 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010651 hddLog(VOS_TRACE_LEVEL_WARN,
10652 "No of Scan Channels exceeded limit: %d", request->n_channels);
10653 request->n_channels = MAX_CHANNEL;
10654 }
10655
10656 hddLog(VOS_TRACE_LEVEL_INFO,
10657 "No of Scan Channels: %d", request->n_channels);
10658
10659
10660 if( request->n_channels )
10661 {
10662 char chList [(request->n_channels*5)+1];
10663 int len;
10664 channelList = vos_mem_malloc( request->n_channels );
10665 if( NULL == channelList )
c_hpothu53512302014-04-15 18:49:53 +053010666 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010667 hddLog(VOS_TRACE_LEVEL_ERROR,
10668 "%s: memory alloc failed channelList", __func__);
10669 status = -ENOMEM;
10670 goto free_mem;
c_hpothu53512302014-04-15 18:49:53 +053010671 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010672
10673 for( i = 0, len = 0; i < request->n_channels ; i++ )
10674 {
10675 channelList[i] = request->channels[i]->hw_value;
10676 len += snprintf(chList+len, 5, "%d ", channelList[i]);
10677 }
10678
Nirav Shah20ac06f2013-12-12 18:14:06 +053010679 hddLog(VOS_TRACE_LEVEL_INFO,
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010680 "Channel-List: %s ", chList);
10681 }
c_hpothu53512302014-04-15 18:49:53 +053010682
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010683 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
10684 scanRequest.ChannelInfo.ChannelList = channelList;
10685
10686 /* set requestType to full scan */
10687 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
10688
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010689 /* if there is back to back scan happening in driver with in
10690 * nDeferScanTimeInterval interval driver should defer new scan request
10691 * and should provide last cached scan results instead of new channel list.
10692 * This rule is not applicable if scan is p2p scan.
10693 * This condition will work only in case when last request no of channels
10694 * and channels are exactly same as new request.
Agarwal Ashish57e84372014-12-05 18:26:53 +053010695 * This should be done only in connected state
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010696 */
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010697
Agarwal Ashish57e84372014-12-05 18:26:53 +053010698 if ((VOS_STATUS_SUCCESS == hdd_is_any_session_connected(pHddCtx)))
10699 {
10700 if ( pScanInfo->last_scan_timestamp !=0 &&
10701 ((vos_timer_get_system_time() - pScanInfo->last_scan_timestamp ) < pHddCtx->cfg_ini->nDeferScanTimeInterval))
10702 {
10703 if ( request->no_cck == FALSE && scanRequest.ChannelInfo.numOfChannels != 1 &&
10704 (pScanInfo->last_scan_numChannels == scanRequest.ChannelInfo.numOfChannels) &&
10705 vos_mem_compare(pScanInfo->last_scan_channelList,
10706 channelList, pScanInfo->last_scan_numChannels))
10707 {
10708 hddLog(VOS_TRACE_LEVEL_WARN,
10709 " New and old station scan time differ is less then %u",
10710 pHddCtx->cfg_ini->nDeferScanTimeInterval);
10711
10712 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010713 pAdapter);
10714
Agarwal Ashish57e84372014-12-05 18:26:53 +053010715 hddLog(VOS_TRACE_LEVEL_WARN,
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010716 "Return old cached scan as all channels and no of channels are same");
10717
Agarwal Ashish57e84372014-12-05 18:26:53 +053010718 if (0 > ret)
10719 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010720
Agarwal Ashish57e84372014-12-05 18:26:53 +053010721 cfg80211_scan_done(request, eCSR_SCAN_SUCCESS);
Masti, Narayanraddide03eb02015-02-06 11:23:50 +053010722
10723 status = eHAL_STATUS_SUCCESS;
10724 goto free_mem;
Agarwal Ashish57e84372014-12-05 18:26:53 +053010725 }
10726 }
Agarwal Ashishbd3e10b2014-11-24 19:19:46 +053010727 }
10728
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010729 /* Flush the scan results(only p2p beacons) for STA scan and P2P
10730 * search (Flush on both full scan and social scan but not on single
10731 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
10732 */
10733
10734 /* Supplicant does single channel scan after 8-way handshake
10735 * and in that case driver shoudnt flush scan results. If
10736 * driver flushes the scan results here and unfortunately if
10737 * the AP doesnt respond to our probe req then association
10738 * fails which is not desired
10739 */
10740
10741 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
10742 {
10743 hddLog(VOS_TRACE_LEVEL_DEBUG, "Flushing P2P Results");
10744 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
10745 pAdapter->sessionId );
10746 }
10747
10748 if( request->ie_len )
10749 {
10750 /* save this for future association (join requires this) */
10751 /*TODO: Array needs to be converted to dynamic allocation,
10752 * as multiple ie.s can be sent in cfg80211_scan_request structure
10753 * CR 597966
10754 */
10755 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
10756 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
10757 pScanInfo->scanAddIE.length = request->ie_len;
10758
10759 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
10760 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
10761 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010762 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053010763 if (request->ie_len <= SIR_MAC_MAX_ADD_IE_LENGTH)
Jeff Johnson295189b2012-06-20 16:38:30 -070010764 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010765 pwextBuf->roamProfile.nAddIEScanLength = request->ie_len;
10766 memcpy( pwextBuf->roamProfile.addIEScan,
10767 request->ie, request->ie_len);
10768 }
10769 else
10770 {
10771 hddLog(VOS_TRACE_LEVEL_ERROR, "Scan Ie length is invalid:"
10772 "%zu", request->ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070010773 }
10774
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010775 }
10776 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
10777 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
10778
10779 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
10780 request->ie_len);
10781 if (pP2pIe != NULL)
10782 {
10783#ifdef WLAN_FEATURE_P2P_DEBUG
10784 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
10785 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
10786 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Nirav Shah20ac06f2013-12-12 18:14:06 +053010787 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010788 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
10789 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10790 "Go nego completed to Connection is started");
10791 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10792 "for 8way Handshake");
Nirav Shah20ac06f2013-12-12 18:14:06 +053010793 }
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010794 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
10795 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Jeff Johnson295189b2012-06-20 16:38:30 -070010796 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010797 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
10798 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
10799 "Disconnected state to Connection is started");
10800 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
10801 "for 4way Handshake");
10802 }
10803#endif
10804
10805 /* no_cck will be set during p2p find to disable 11b rates */
10806 if(TRUE == request->no_cck)
10807 {
10808 hddLog(VOS_TRACE_LEVEL_INFO,
10809 "%s: This is a P2P Search", __func__);
10810 scanRequest.p2pSearch = 1;
10811
10812 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
Agarwal Ashish4f616132013-12-30 23:32:50 +053010813 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010814 /* set requestType to P2P Discovery */
10815 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
10816 }
10817
10818 /*
10819 Skip Dfs Channel in case of P2P Search
10820 if it is set in ini file
10821 */
10822 if(cfg_param->skipDfsChnlInP2pSearch)
10823 {
10824 scanRequest.skipDfsChnlInP2pSearch = 1;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010825 }
10826 else
10827 {
Padma, Santhosh Kumar787bd5c2014-05-15 20:09:31 +053010828 scanRequest.skipDfsChnlInP2pSearch = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053010829 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010830
Agarwal Ashish4f616132013-12-30 23:32:50 +053010831 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 }
10833 }
10834
10835 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
10836
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010837#ifdef FEATURE_WLAN_TDLS
10838 /* if tdls disagree scan right now, return immediately.
10839 tdls will schedule the scan when scan is allowed. (return SUCCESS)
10840 or will reject the scan if any TDLS is in progress. (return -EBUSY)
10841 */
10842 status = wlan_hdd_tdls_scan_callback (pAdapter,
10843 wiphy,
10844#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10845 dev,
10846#endif
10847 request);
10848 if(status <= 0)
10849 {
10850 if(!status)
10851 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS in progress."
10852 "scan rejected %d", __func__, status);
10853 else
10854 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: TDLS teardown is ongoing %d",
10855 __func__, status);
10856
10857 return status;
10858 }
10859#endif
10860
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010861 /* acquire the wakelock to avoid the apps suspend during the scan. To
10862 * address the following issues.
10863 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
10864 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
10865 * for long time, this result in apps running at full power for long time.
10866 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
10867 * be stuck in full power because of resume BMPS
10868 */
10869 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -070010870
Nirav Shah20ac06f2013-12-12 18:14:06 +053010871 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
10872 "requestType %d, scanType %d, minChnTime %d, maxChnTime %d,"
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053010873 "p2pSearch %d, skipDfsChnlInP2pSearch %d",
10874 scanRequest.requestType, scanRequest.scanType,
10875 scanRequest.minChnTime, scanRequest.maxChnTime,
Nirav Shah20ac06f2013-12-12 18:14:06 +053010876 scanRequest.p2pSearch, scanRequest.skipDfsChnlInP2pSearch);
10877
Siddharth Bhal76972212014-10-15 16:22:51 +053010878 if (pHddCtx->spoofMacAddr.isEnabled)
10879 {
10880 hddLog(VOS_TRACE_LEVEL_INFO,
10881 "%s: MAC Spoofing enabled for current scan", __func__);
10882 /* Updating SelfSta Mac Addr in TL which will be used to get staidx
10883 * to fill TxBds for probe request during current scan
10884 */
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053010885 status = WLANTL_updateSpoofMacAddr(pHddCtx->pvosContext,
Siddharth Bhal76972212014-10-15 16:22:51 +053010886 &pHddCtx->spoofMacAddr.randomMacAddr, &pAdapter->macAddressCurrent);
Padma, Santhosh Kumar79236142015-02-09 18:19:33 +053010887
10888 if(status != VOS_STATUS_SUCCESS)
10889 {
10890 hdd_allow_suspend();
10891 status = -EFAULT;
10892 goto free_mem;
10893 }
Siddharth Bhal76972212014-10-15 16:22:51 +053010894 }
10895
Jeff Johnsone7245742012-09-05 17:12:55 -070010896 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070010897 pAdapter->sessionId, &scanRequest, &scanId,
10898 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -070010899
Jeff Johnson295189b2012-06-20 16:38:30 -070010900 if (eHAL_STATUS_SUCCESS != status)
10901 {
10902 hddLog(VOS_TRACE_LEVEL_ERROR,
10903 "%s: sme_ScanRequest returned error %d", __func__, status);
10904 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010905 if(eHAL_STATUS_RESOURCES == status)
10906 {
Nirav Shah20ac06f2013-12-12 18:14:06 +053010907 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: HO is in progress."
10908 "So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -070010909 status = -EBUSY;
10910 } else {
10911 status = -EIO;
10912 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -070010913 hdd_allow_suspend();
Pradeep Reddy POTTETIc7822df2015-02-19 20:15:41 +053010914
10915#ifdef FEATURE_WLAN_TDLS
10916 wlan_hdd_tdls_scan_done_callback(pAdapter);
10917#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010918 goto free_mem;
10919 }
10920
10921 pScanInfo->mScanPending = TRUE;
Kaushik, Sushant4975a572014-10-21 16:07:48 +053010922 pScanInfo->sessionId = pAdapter->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010923 pAdapter->request = request;
10924 pScanInfo->scanId = scanId;
10925
10926 complete(&pScanInfo->scan_req_completion_event);
10927
10928free_mem:
10929 if( scanRequest.SSIDs.SSIDList )
10930 {
10931 vos_mem_free(scanRequest.SSIDs.SSIDList);
10932 }
10933
10934 if( channelList )
10935 vos_mem_free( channelList );
10936
10937 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070010938 return status;
10939}
10940
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053010941int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
10942#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10943 struct net_device *dev,
10944#endif
10945 struct cfg80211_scan_request *request)
10946{
10947 int ret;
10948
10949 vos_ssr_protect(__func__);
10950 ret = __wlan_hdd_cfg80211_scan(wiphy,
10951#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
10952 dev,
10953#endif
10954 request);
10955 vos_ssr_unprotect(__func__);
10956
10957 return ret;
10958}
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010959
10960void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
10961{
10962 v_U8_t iniDot11Mode =
10963 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
10964 eHddDot11Mode hddDot11Mode = iniDot11Mode;
10965
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053010966 hddLog(LOG1, FL("Channel Bonding Mode Selected is %u"),
10967 iniDot11Mode);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010968 switch ( iniDot11Mode )
10969 {
10970 case eHDD_DOT11_MODE_AUTO:
10971 case eHDD_DOT11_MODE_11ac:
10972 case eHDD_DOT11_MODE_11ac_ONLY:
10973#ifdef WLAN_FEATURE_11AC
Abhishek Singh4b1d2352014-08-01 21:59:28 +053010974 if ( sme_IsFeatureSupportedByDriver(DOT11AC) &&
10975 sme_IsFeatureSupportedByFW(DOT11AC) )
10976 hddDot11Mode = eHDD_DOT11_MODE_11ac;
10977 else
10978 hddDot11Mode = eHDD_DOT11_MODE_11n;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010979#else
10980 hddDot11Mode = eHDD_DOT11_MODE_11n;
10981#endif
10982 break;
10983 case eHDD_DOT11_MODE_11n:
10984 case eHDD_DOT11_MODE_11n_ONLY:
10985 hddDot11Mode = eHDD_DOT11_MODE_11n;
10986 break;
10987 default:
10988 hddDot11Mode = iniDot11Mode;
10989 break;
10990 }
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053010991#ifdef WLAN_FEATURE_AP_HT40_24G
10992 if (operationChannel > SIR_11B_CHANNEL_END)
10993#endif
10994 {
10995 /* This call decides required channel bonding mode */
10996 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070010997 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
10998 operationChannel);
Hardik Kantilal Patel086e0a32014-11-20 14:56:26 +053010999 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011000}
11001
Jeff Johnson295189b2012-06-20 16:38:30 -070011002/*
11003 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011004 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070011005 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011006int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -070011007 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -070011008{
11009 int status = 0;
11010 hdd_wext_state_t *pWextState;
Yue Mae36e3552014-03-05 17:06:20 -080011011 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011012 v_U32_t roamId;
11013 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -070011014 eCsrAuthType RSNAuthType;
11015
11016 ENTER();
11017
11018 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Yue Mae36e3552014-03-05 17:06:20 -080011019 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
11020
11021 status = wlan_hdd_validate_context(pHddCtx);
11022 if (status)
11023 {
Yue Mae36e3552014-03-05 17:06:20 -080011024 return status;
11025 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011026
Jeff Johnson295189b2012-06-20 16:38:30 -070011027 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
11028 {
11029 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
11030 return -EINVAL;
11031 }
11032
11033 pRoamProfile = &pWextState->roamProfile;
11034
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011035 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -070011036 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011037 hdd_station_ctx_t *pHddStaCtx;
11038 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011039
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011040 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -070011041 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
11042 {
11043 /*QoS not enabled in cfg file*/
11044 pRoamProfile->uapsd_mask = 0;
11045 }
11046 else
11047 {
11048 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011049 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -070011050 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
11051 }
11052
11053 pRoamProfile->SSIDs.numOfSSIDs = 1;
11054 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
11055 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011056 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -070011057 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
11058 ssid, ssid_len);
11059
11060 if (bssid)
11061 {
11062 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
11063 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
11064 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011065 /* Save BSSID in seperate variable as well, as RoamProfile
11066 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -070011067 case of join failure we should send valid BSSID to supplicant
11068 */
11069 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
11070 WNI_CFG_BSSID_LEN);
11071 }
Dhanashri Atre51981c62013-06-13 11:47:57 -070011072 else
11073 {
11074 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
11075 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011076
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011077 hddLog(LOG1, FL("Connect to SSID: %s opertating Channel: %u"),
11078 pRoamProfile->SSIDs.SSIDList->SSID.ssId, operatingChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070011079 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
11080 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011081 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011082 /*set gen ie*/
11083 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
11084 /*set auth*/
11085 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
11086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011087#ifdef FEATURE_WLAN_WAPI
11088 if (pAdapter->wapi_info.nWapiMode)
11089 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011090 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011091 switch (pAdapter->wapi_info.wapiAuthMode)
11092 {
11093 case WAPI_AUTH_MODE_PSK:
11094 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011095 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011096 pAdapter->wapi_info.wapiAuthMode);
11097 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
11098 break;
11099 }
11100 case WAPI_AUTH_MODE_CERT:
11101 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011102 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011103 pAdapter->wapi_info.wapiAuthMode);
11104 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
11105 break;
11106 }
11107 } // End of switch
11108 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
11109 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
11110 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011111 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011112 pRoamProfile->AuthType.numEntries = 1;
11113 pRoamProfile->EncryptionType.numEntries = 1;
11114 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11115 pRoamProfile->mcEncryptionType.numEntries = 1;
11116 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
11117 }
11118 }
11119#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011120#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011121 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011122 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
11123 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
11124 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053011125 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
11126 sizeof (tSirGtkOffloadParams));
11127 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053011128 }
11129#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011130 pRoamProfile->csrPersona = pAdapter->device_mode;
11131
Jeff Johnson32d95a32012-09-10 13:15:23 -070011132 if( operatingChannel )
11133 {
11134 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
11135 pRoamProfile->ChannelInfo.numOfChannels = 1;
11136 }
Chet Lanctot186b5732013-03-18 10:26:30 -070011137 else
11138 {
11139 pRoamProfile->ChannelInfo.ChannelList = NULL;
11140 pRoamProfile->ChannelInfo.numOfChannels = 0;
11141 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070011142 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
11143 {
11144 hdd_select_cbmode(pAdapter,operatingChannel);
11145 }
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053011146
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011147 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
11148 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011149 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011150 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011151 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
11152 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011153 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11154 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Abhishek Singhf4669da2014-05-26 15:07:49 +053011155 {
11156 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
11157 "%s: Set HDD connState to eConnectionState_Connecting",
11158 __func__);
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011159 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
11160 eConnectionState_Connecting);
Abhishek Singhf4669da2014-05-26 15:07:49 +053011161 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011162 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -070011163 pAdapter->sessionId, pRoamProfile, &roamId);
11164
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +053011165 if ((eHAL_STATUS_SUCCESS != status) &&
11166 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
11167 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011168
11169 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011170 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
11171 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
11172 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011173 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -080011174 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053011175 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -080011176
11177 pRoamProfile->ChannelInfo.ChannelList = NULL;
11178 pRoamProfile->ChannelInfo.numOfChannels = 0;
11179
Jeff Johnson295189b2012-06-20 16:38:30 -070011180 }
11181 else
11182 {
11183 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
11184 return -EINVAL;
11185 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -080011186 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070011187 return status;
11188}
11189
11190/*
11191 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
11192 * This function is used to set the authentication type (OPEN/SHARED).
11193 *
11194 */
11195static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
11196 enum nl80211_auth_type auth_type)
11197{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011198 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011199 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11200
11201 ENTER();
11202
11203 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011204 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -070011205 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011206 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011207 hddLog(VOS_TRACE_LEVEL_INFO,
11208 "%s: set authentication type to AUTOSWITCH", __func__);
11209 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
11210 break;
11211
11212 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070011213#ifdef WLAN_FEATURE_VOWIFI_11R
11214 case NL80211_AUTHTYPE_FT:
11215#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011216 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011217 "%s: set authentication type to OPEN", __func__);
11218 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
11219 break;
11220
11221 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011222 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011223 "%s: set authentication type to SHARED", __func__);
11224 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
11225 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011226#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011227 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011228 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -070011229 "%s: set authentication type to CCKM WPA", __func__);
11230 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
11231 break;
11232#endif
11233
11234
11235 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011236 hddLog(VOS_TRACE_LEVEL_ERROR,
11237 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011238 auth_type);
11239 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
11240 return -EINVAL;
11241 }
11242
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011243 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 pHddStaCtx->conn_info.authType;
11245 return 0;
11246}
11247
11248/*
11249 * FUNCTION: wlan_hdd_set_akm_suite
11250 * This function is used to set the key mgmt type(PSK/8021x).
11251 *
11252 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011253static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011254 u32 key_mgmt
11255 )
11256{
11257 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11258 ENTER();
Abhishek Singhae408032014-09-25 17:22:04 +053011259 /* Should be in ieee802_11_defs.h */
11260#define WLAN_AKM_SUITE_8021X_SHA256 0x000FAC05
11261#define WLAN_AKM_SUITE_PSK_SHA256 0x000FAC06
Jeff Johnson295189b2012-06-20 16:38:30 -070011262 /*set key mgmt type*/
11263 switch(key_mgmt)
11264 {
11265 case WLAN_AKM_SUITE_PSK:
Abhishek Singhae408032014-09-25 17:22:04 +053011266 case WLAN_AKM_SUITE_PSK_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011267#ifdef WLAN_FEATURE_VOWIFI_11R
11268 case WLAN_AKM_SUITE_FT_PSK:
11269#endif
11270 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -070011271 __func__);
11272 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
11273 break;
11274
11275 case WLAN_AKM_SUITE_8021X:
Abhishek Singhae408032014-09-25 17:22:04 +053011276 case WLAN_AKM_SUITE_8021X_SHA256:
Gopichand Nakkala356fb102013-03-06 12:34:04 +053011277#ifdef WLAN_FEATURE_VOWIFI_11R
11278 case WLAN_AKM_SUITE_FT_8021X:
11279#endif
11280 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -070011281 __func__);
11282 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11283 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011284#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011285#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
11286#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
11287 case WLAN_AKM_SUITE_CCKM:
11288 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
11289 __func__);
11290 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
11291 break;
11292#endif
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -070011293#ifndef WLAN_AKM_SUITE_OSEN
11294#define WLAN_AKM_SUITE_OSEN 0x506f9a01 /* Should be in ieee802_11_defs.h */
11295 case WLAN_AKM_SUITE_OSEN:
11296 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to OSEN",
11297 __func__);
11298 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
11299 break;
11300#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070011301
11302 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011303 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011304 __func__, key_mgmt);
11305 return -EINVAL;
11306
11307 }
11308 return 0;
11309}
11310
11311/*
11312 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011313 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -070011314 * (NONE/WEP40/WEP104/TKIP/CCMP).
11315 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011316static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
11317 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -070011318 bool ucast
11319 )
11320{
11321 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011322 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011323 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11324
11325 ENTER();
11326
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011327 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011328 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011329 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -070011330 __func__, cipher);
11331 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11332 }
11333 else
11334 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011335
Jeff Johnson295189b2012-06-20 16:38:30 -070011336 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011337 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -070011338 {
11339 case IW_AUTH_CIPHER_NONE:
11340 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
11341 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011342
Jeff Johnson295189b2012-06-20 16:38:30 -070011343 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011344 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -070011345 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011346
Jeff Johnson295189b2012-06-20 16:38:30 -070011347 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +053011348 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -070011349 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011350
Jeff Johnson295189b2012-06-20 16:38:30 -070011351 case WLAN_CIPHER_SUITE_TKIP:
11352 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
11353 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011354
Jeff Johnson295189b2012-06-20 16:38:30 -070011355 case WLAN_CIPHER_SUITE_CCMP:
11356 encryptionType = eCSR_ENCRYPT_TYPE_AES;
11357 break;
11358#ifdef FEATURE_WLAN_WAPI
11359 case WLAN_CIPHER_SUITE_SMS4:
11360 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
11361 break;
11362#endif
11363
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080011364#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070011365 case WLAN_CIPHER_SUITE_KRK:
11366 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
11367 break;
11368#endif
11369 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011370 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011371 __func__, cipher);
11372 return -EOPNOTSUPP;
11373 }
11374 }
11375
11376 if (ucast)
11377 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011378 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011379 __func__, encryptionType);
11380 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
11381 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011382 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011383 encryptionType;
11384 }
11385 else
11386 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011387 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070011388 __func__, encryptionType);
11389 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
11390 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
11391 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
11392 }
11393
11394 return 0;
11395}
11396
11397
11398/*
11399 * FUNCTION: wlan_hdd_cfg80211_set_ie
11400 * This function is used to parse WPA/RSN IE's.
11401 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011402int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
11403 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -070011404 size_t ie_len
11405 )
11406{
11407 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
11408 u8 *genie = ie;
11409 v_U16_t remLen = ie_len;
11410#ifdef FEATURE_WLAN_WAPI
11411 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
11412 u16 *tmp;
11413 v_U16_t akmsuiteCount;
11414 int *akmlist;
11415#endif
11416 ENTER();
11417
11418 /* clear previous assocAddIE */
11419 pWextState->assocAddIE.length = 0;
11420 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011421 pWextState->roamProfile.bOSENAssociation = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011422
11423 while (remLen >= 2)
11424 {
11425 v_U16_t eLen = 0;
11426 v_U8_t elementId;
11427 elementId = *genie++;
11428 eLen = *genie++;
11429 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011430
Arif Hussain6d2a3322013-11-17 19:50:10 -080011431 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]",
Jeff Johnson295189b2012-06-20 16:38:30 -070011432 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011433
11434 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -070011435 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011436 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011437 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 -070011438 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011439 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011440 "%s: Invalid WPA IE", __func__);
11441 return -EINVAL;
11442 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011443 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 {
11445 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011446 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011447 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011448
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011449 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011450 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011451 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
11452 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 VOS_ASSERT(0);
11454 return -ENOMEM;
11455 }
11456 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11457 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11458 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011459
Jeff Johnson295189b2012-06-20 16:38:30 -070011460 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
11461 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11462 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11463 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011464 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
11465 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011466 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
11467 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11468 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
11469 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
11470 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
11471 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011472 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +053011473 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -070011474 {
11475 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011476 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011477 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011478
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011479 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011480 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011481 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11482 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 VOS_ASSERT(0);
11484 return -ENOMEM;
11485 }
11486 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
11487 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11488 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011489
Jeff Johnson295189b2012-06-20 16:38:30 -070011490 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11491 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11492 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011493#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011494 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
11495 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -070011496 /*Consider WFD IE, only for P2P Client */
11497 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
11498 {
11499 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011500 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070011501 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011502
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011503 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011504 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011505 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11506 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -070011507 VOS_ASSERT(0);
11508 return -ENOMEM;
11509 }
11510 // WFD IE is saved to Additional IE ; it should be accumulated to handle
11511 // WPS IE + P2P IE + WFD IE
11512 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11513 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011514
Jeff Johnson295189b2012-06-20 16:38:30 -070011515 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11516 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11517 }
11518#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011519 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011520 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011521 HS20_OUI_TYPE_SIZE)) )
11522 {
11523 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011524 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011525 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011526
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011527 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011528 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011529 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11530 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011531 VOS_ASSERT(0);
11532 return -ENOMEM;
11533 }
11534 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11535 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011536
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -070011537 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11538 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11539 }
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011540 /* Appending OSEN Information Element in Assiciation Request */
11541 else if ( (0 == memcmp(&genie[0], OSEN_OUI_TYPE,
11542 OSEN_OUI_TYPE_SIZE)) )
11543 {
11544 v_U16_t curAddIELen = pWextState->assocAddIE.length;
11545 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set OSEN IE(len %d)",
11546 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011547
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011548 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070011549 {
11550 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11551 "Need bigger buffer space");
11552 VOS_ASSERT(0);
11553 return -ENOMEM;
11554 }
11555 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11556 pWextState->assocAddIE.length += eLen + 2;
11557
11558 pWextState->roamProfile.bOSENAssociation = VOS_TRUE;
11559 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11560 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11561 }
11562
11563 break;
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -070011564 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
11565
11566 /* populating as ADDIE in beacon frames */
11567 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11568 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
11569 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
11570 {
11571 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11572 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
11573 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11574 {
11575 hddLog(LOGE,
11576 "Coldn't pass "
11577 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
11578 }
11579 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
11580 else
11581 hddLog(LOGE,
11582 "Could not pass on "
11583 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
11584
11585 /* IBSS mode doesn't contain params->proberesp_ies still
11586 beaconIE's need to be populated in probe response frames */
11587 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
11588 {
11589 u16 rem_probe_resp_ie_len = eLen + 2;
11590 u8 probe_rsp_ie_len[3] = {0};
11591 u8 counter = 0;
11592
11593 /* Check Probe Resp Length if it is greater then 255 then
11594 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
11595 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
11596 not able Store More then 255 bytes into One Variable */
11597
11598 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
11599 {
11600 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
11601 {
11602 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
11603 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
11604 }
11605 else
11606 {
11607 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
11608 rem_probe_resp_ie_len = 0;
11609 }
11610 }
11611
11612 rem_probe_resp_ie_len = 0;
11613
11614 if (probe_rsp_ie_len[0] > 0)
11615 {
11616 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11617 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
11618 (tANI_U8*)(genie - 2),
11619 probe_rsp_ie_len[0], NULL,
11620 eANI_BOOLEAN_FALSE)
11621 == eHAL_STATUS_FAILURE)
11622 {
11623 hddLog(LOGE,
11624 "Could not pass"
11625 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
11626 }
11627 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
11628 }
11629
11630 if (probe_rsp_ie_len[1] > 0)
11631 {
11632 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11633 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
11634 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11635 probe_rsp_ie_len[1], NULL,
11636 eANI_BOOLEAN_FALSE)
11637 == eHAL_STATUS_FAILURE)
11638 {
11639 hddLog(LOGE,
11640 "Could not pass"
11641 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
11642 }
11643 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
11644 }
11645
11646 if (probe_rsp_ie_len[2] > 0)
11647 {
11648 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
11649 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
11650 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
11651 probe_rsp_ie_len[2], NULL,
11652 eANI_BOOLEAN_FALSE)
11653 == eHAL_STATUS_FAILURE)
11654 {
11655 hddLog(LOGE,
11656 "Could not pass"
11657 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
11658 }
11659 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
11660 }
11661
11662 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
11663 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
11664 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
11665 {
11666 hddLog(LOGE,
11667 "Could not pass"
11668 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
11669 }
11670 }
11671 else
11672 {
11673 // Reset WNI_CFG_PROBE_RSP Flags
11674 wlan_hdd_reset_prob_rspies(pAdapter);
11675
11676 hddLog(VOS_TRACE_LEVEL_INFO,
11677 "%s: No Probe Response IE received in set beacon",
11678 __func__);
11679 }
11680 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -070011681 break;
11682 case DOT11F_EID_RSN:
11683 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
11684 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
11685 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
11686 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
11687 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
11688 break;
Abhishek Singh15d95602015-03-24 15:52:57 +053011689
11690 /* Appending Extended Capabilities with Interworking bit set
11691 * in Assoc Req.
11692 *
11693 * In assoc req this EXT Cap will only be taken into account if
11694 * interworkingService bit is set to 1. Currently
11695 * driver is only interested in interworkingService capability
11696 * from supplicant. If in future any other EXT Cap info is
11697 * required from supplicat, it needs to be handled while
11698 * sending Assoc Req in LIM.
11699 */
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011700 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011701 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011702 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011703 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011704 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011705
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053011706 if( SIR_MAC_MAX_ADD_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011707 {
Jeff Johnson902c9832012-12-10 14:28:09 -080011708 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
11709 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011710 VOS_ASSERT(0);
11711 return -ENOMEM;
11712 }
11713 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
11714 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011715
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011716 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
11717 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
11718 break;
11719 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011720#ifdef FEATURE_WLAN_WAPI
11721 case WLAN_EID_WAPI:
11722 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -070011723 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 pAdapter->wapi_info.nWapiMode);
11725 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011726 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -070011727 akmsuiteCount = WPA_GET_LE16(tmp);
11728 tmp = tmp + 1;
11729 akmlist = (int *)(tmp);
11730 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
11731 {
11732 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
11733 }
11734 else
11735 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080011736 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count");
Jeff Johnson295189b2012-06-20 16:38:30 -070011737 VOS_ASSERT(0);
11738 return -EINVAL;
11739 }
11740
11741 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
11742 {
11743 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011744 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011745 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011746 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011747 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011748 {
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011750 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070011751 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
11752 }
11753 break;
11754#endif
11755 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011756 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011757 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -070011758 /* when Unknown IE is received we should break and continue
11759 * to the next IE in the buffer instead we were returning
11760 * so changing this to break */
11761 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 }
11763 genie += eLen;
11764 remLen -= eLen;
11765 }
11766 EXIT();
11767 return 0;
11768}
11769
11770/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +053011771 * FUNCTION: hdd_isWPAIEPresent
11772 * Parse the received IE to find the WPA IE
11773 *
11774 */
11775static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
11776{
11777 v_U8_t eLen = 0;
11778 v_U16_t remLen = ie_len;
11779 v_U8_t elementId = 0;
11780
11781 while (remLen >= 2)
11782 {
11783 elementId = *ie++;
11784 eLen = *ie++;
11785 remLen -= 2;
11786 if (eLen > remLen)
11787 {
11788 hddLog(VOS_TRACE_LEVEL_ERROR,
11789 "%s: IE length is wrong %d", __func__, eLen);
11790 return FALSE;
11791 }
11792 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
11793 {
11794 /* OUI - 0x00 0X50 0XF2
11795 WPA Information Element - 0x01
11796 WPA version - 0x01*/
11797 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
11798 return TRUE;
11799 }
11800 ie += eLen;
11801 remLen -= eLen;
11802 }
11803 return FALSE;
11804}
11805
11806/*
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011808 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070011809 * parameters during connect operation.
11810 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011811int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070011812 struct cfg80211_connect_params *req
11813 )
11814{
11815 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011816 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011817 ENTER();
11818
11819 /*set wpa version*/
11820 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
11821
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011822 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011823 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +053011824 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -070011825 {
11826 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
11827 }
11828 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
11829 {
11830 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
11831 }
11832 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011833
11834 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070011835 pWextState->wpaVersion);
11836
11837 /*set authentication type*/
11838 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
11839
11840 if (0 > status)
11841 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011842 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011843 "%s: failed to set authentication type ", __func__);
11844 return status;
11845 }
11846
11847 /*set key mgmt type*/
11848 if (req->crypto.n_akm_suites)
11849 {
11850 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
11851 if (0 > status)
11852 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011853 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -070011854 __func__);
11855 return status;
11856 }
11857 }
11858
11859 /*set pairwise cipher type*/
11860 if (req->crypto.n_ciphers_pairwise)
11861 {
11862 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
11863 req->crypto.ciphers_pairwise[0], true);
11864 if (0 > status)
11865 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011866 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011867 "%s: failed to set unicast cipher type", __func__);
11868 return status;
11869 }
11870 }
11871 else
11872 {
11873 /*Reset previous cipher suite to none*/
11874 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
11875 if (0 > status)
11876 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011877 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 "%s: failed to set unicast cipher type", __func__);
11879 return status;
11880 }
11881 }
11882
11883 /*set group cipher type*/
11884 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
11885 false);
11886
11887 if (0 > status)
11888 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011889 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -070011890 __func__);
11891 return status;
11892 }
11893
Chet Lanctot186b5732013-03-18 10:26:30 -070011894#ifdef WLAN_FEATURE_11W
11895 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
11896#endif
11897
Jeff Johnson295189b2012-06-20 16:38:30 -070011898 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
11899 if (req->ie_len)
11900 {
11901 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
11902 if ( 0 > status)
11903 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011904 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070011905 __func__);
11906 return status;
11907 }
11908 }
11909
11910 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011911 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011912 {
11913 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
11914 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
11915 )
11916 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011917 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -070011918 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
11919 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011920 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070011921 __func__);
11922 return -EOPNOTSUPP;
11923 }
11924 else
11925 {
11926 u8 key_len = req->key_len;
11927 u8 key_idx = req->key_idx;
11928
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011929 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -070011930 && (CSR_MAX_NUM_KEY > key_idx)
11931 )
11932 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011933 hddLog(VOS_TRACE_LEVEL_INFO,
11934 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070011935 __func__, key_idx, key_len);
11936 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011937 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -070011938 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053011939 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -070011940 (u8)key_len;
11941 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
11942 }
11943 }
11944 }
11945 }
11946
11947 return status;
11948}
11949
11950/*
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053011951 * FUNCTION: wlan_hdd_try_disconnect
11952 * This function is used to disconnect from previous
11953 * connection
11954 */
11955static int wlan_hdd_try_disconnect( hdd_adapter_t *pAdapter )
11956{
11957 long ret = 0;
11958 hdd_station_ctx_t *pHddStaCtx;
11959 eMib_dot11DesiredBssType connectedBssType;
11960
11961 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
11962
11963 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
11964
11965 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
11966 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
11967 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
11968 {
11969 /* Issue disconnect to CSR */
11970 INIT_COMPLETION(pAdapter->disconnect_comp_var);
11971 if( eHAL_STATUS_SUCCESS ==
11972 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
11973 pAdapter->sessionId,
11974 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
11975 {
11976 ret = wait_for_completion_interruptible_timeout(
11977 &pAdapter->disconnect_comp_var,
11978 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11979 if (0 >= ret)
11980 {
11981 hddLog(LOGE, FL("Failed to receive disconnect event"));
11982 return -EALREADY;
11983 }
11984 }
11985 }
11986 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
11987 {
11988 ret = wait_for_completion_interruptible_timeout(
11989 &pAdapter->disconnect_comp_var,
11990 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
11991 if (0 >= ret)
11992 {
11993 hddLog(LOGE, FL("Failed to receive disconnect event"));
11994 return -EALREADY;
11995 }
11996 }
11997
11998 return 0;
11999}
12000
12001/*
Agarwal Ashish51325b52014-06-16 16:50:49 +053012002 * FUNCTION: __wlan_hdd_cfg80211_connect
12003 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -070012004 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012005static int __wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012006 struct net_device *ndev,
12007 struct cfg80211_connect_params *req
12008 )
12009{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012010 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012011 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012012 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
Sushant Kaushikba6764e2014-06-30 19:52:09 +053012013 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012014
12015 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012016
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012017 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12018 TRACE_CODE_HDD_CFG80211_CONNECT,
12019 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012020 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012021 "%s: device_mode = %s (%d)", __func__,
12022 hdd_device_modetoString(pAdapter->device_mode),
12023 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012024
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012025 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012026 if (!pHddCtx)
12027 {
12028 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
12029 "%s: HDD context is null", __func__);
Agarwal Ashish51325b52014-06-16 16:50:49 +053012030 return -EINVAL;
Rajesh Chauhana0516c62014-01-30 16:11:18 -080012031 }
12032
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012033 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012034 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012035 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012036 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012037 }
12038
Agarwal Ashish51325b52014-06-16 16:50:49 +053012039 if (vos_max_concurrent_connections_reached()) {
12040 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12041 return -ECONNREFUSED;
12042 }
12043
Jeff Johnson295189b2012-06-20 16:38:30 -070012044#ifdef WLAN_BTAMP_FEATURE
12045 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012046 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012048 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012049 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -080012050 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012051 }
12052#endif
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012053
12054 //If Device Mode is Station Concurrent Sessions Exit BMps
12055 //P2P Mode will be taken care in Open/close adapter
12056 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +053012057 (vos_concurrent_open_sessions_running())) {
12058 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx,
12059 WLAN_HDD_INFRA_STATION);
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012060 }
12061
12062 /*Try disconnecting if already in connected state*/
12063 status = wlan_hdd_try_disconnect(pAdapter);
12064 if ( 0 > status)
12065 {
12066 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12067 " connection"));
12068 return -EALREADY;
12069 }
12070
Jeff Johnson295189b2012-06-20 16:38:30 -070012071 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012072 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -070012073
12074 if ( 0 > status)
12075 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012076 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -070012077 __func__);
12078 return status;
12079 }
Mohit Khanna765234a2012-09-11 15:08:35 -070012080 if ( req->channel )
12081 {
12082 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
12083 req->ssid_len, req->bssid,
12084 req->channel->hw_value);
12085 }
12086 else
12087 {
12088 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012089 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -070012090 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012091
Sushant Kaushikd7083982015-03-18 14:33:24 +053012092 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012093 {
12094 //ReEnable BMPS if disabled
12095 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
12096 (NULL != pHddCtx))
12097 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +053012098 if (pHddCtx->hdd_wlan_suspended)
12099 {
12100 hdd_set_pwrparams(pHddCtx);
12101 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012102 //ReEnable Bmps and Imps back
12103 hdd_enable_bmps_imps(pHddCtx);
12104 }
Agarwal Ashish51325b52014-06-16 16:50:49 +053012105 hddLog(VOS_TRACE_LEVEL_ERROR, FL("connect failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012106 return status;
12107 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012108 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012109 EXIT();
12110 return status;
12111}
12112
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012113static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
12114 struct net_device *ndev,
12115 struct cfg80211_connect_params *req)
12116{
12117 int ret;
12118 vos_ssr_protect(__func__);
12119 ret = __wlan_hdd_cfg80211_connect(wiphy, ndev, req);
12120 vos_ssr_unprotect(__func__);
12121
12122 return ret;
12123}
Jeff Johnson295189b2012-06-20 16:38:30 -070012124
12125/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012126 * FUNCTION: wlan_hdd_disconnect
12127 * This function is used to issue a disconnect request to SME
12128 */
12129int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
12130{
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012131 int status, result = 0;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012132 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012133 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012134 long ret;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012135
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012136 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012137
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012138 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012139 if (0 != status)
12140 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012141 return status;
12142 }
12143
12144 pHddCtx->isAmpAllowed = VOS_TRUE;
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012145
Agarwal Ashish47d18112014-08-04 19:55:07 +053012146 /* Need to apply spin lock before decreasing active sessions
12147 * as there can be chance for double decrement if context switch
12148 * Calls hdd_DisConnectHandler.
12149 */
12150
12151 spin_lock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012152 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
12153 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012154 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
12155 }
Agarwal Ashish47d18112014-08-04 19:55:07 +053012156 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
12157 spin_unlock_bh(&pAdapter->lock_for_active_session);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +053012158
Abhishek Singhf4669da2014-05-26 15:07:49 +053012159 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +053012160 FL( "Set HDD connState to eConnectionState_Disconnecting" ));
12161
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012162 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012163
Mihir Shete182a0b22014-08-18 16:08:48 +053012164 /*
12165 * stop tx queues before deleting STA/BSS context from the firmware.
12166 * tx has to be disabled because the firmware can get busy dropping
12167 * the tx frames after BSS/STA has been deleted and will not send
12168 * back a response resulting in WDI timeout
12169 */
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +053012170 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Mihir Shete182a0b22014-08-18 16:08:48 +053012171 netif_tx_disable(pAdapter->dev);
12172 netif_carrier_off(pAdapter->dev);
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012173
Mihir Shete182a0b22014-08-18 16:08:48 +053012174 /*issue disconnect*/
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012175 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
12176 pAdapter->sessionId, reason);
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012177 if(eHAL_STATUS_CMD_NOT_QUEUED == status)
12178 {
12179 hddLog(VOS_TRACE_LEVEL_INFO,
12180 FL("status = %d, already disconnected"),
12181 (int)status );
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012182
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012183 }
12184 else if ( 0 != status )
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012185 {
12186 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012187 "%s csrRoamDisconnect failure, returned %d",
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012188 __func__, (int)status );
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012189 result = -EINVAL;
12190 goto disconnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012191 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012192 ret = wait_for_completion_interruptible_timeout(
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012193 &pAdapter->disconnect_comp_var,
12194 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012195 if (!ret && ( eHAL_STATUS_CMD_NOT_QUEUED != status ))
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012196 {
12197 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012198 "%s: Failed to disconnect, timed out", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012199 result = -ETIMEDOUT;
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012200 }
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012201 else if (ret == -ERESTARTSYS)
Mahesh A Saptasagar05a357e2014-02-26 16:28:06 +053012202 {
12203 hddLog(VOS_TRACE_LEVEL_ERROR,
12204 "%s: Failed to disconnect, wait interrupted", __func__);
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012205 result = -ERESTARTSYS;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053012206 }
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012207disconnected:
Abhishek Singhdc2bfd42014-06-19 17:59:05 +053012208 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
12209 FL("Set HDD connState to eConnectionState_NotConnected"));
12210 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
12211
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012212 EXIT();
Abhishek Singh6ab864d2014-11-27 12:10:10 +053012213 return result;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012214}
12215
12216
12217/*
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012218 * FUNCTION: __wlan_hdd_cfg80211_disconnect
Jeff Johnson295189b2012-06-20 16:38:30 -070012219 * This function is used to issue a disconnect request to SME
12220 */
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012221static int __wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012222 struct net_device *dev,
12223 u16 reason
12224 )
12225{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012226 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012227 int status;
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012228 tCsrRoamProfile *pRoamProfile;
12229 hdd_station_ctx_t *pHddStaCtx;
12230 hdd_context_t *pHddCtx;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012231#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012232 tANI_U8 staIdx;
12233#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012234
Jeff Johnson295189b2012-06-20 16:38:30 -070012235 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012236
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053012237 if (!pAdapter) {
12238 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
12239 return -EINVAL;
12240 }
12241
12242 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12243 if (!pHddStaCtx) {
12244 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD STA context is NULL"));
12245 return -EINVAL;
12246 }
12247
12248 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
12249 status = wlan_hdd_validate_context(pHddCtx);
12250 if (0 != status)
12251 {
12252 return status;
12253 }
12254
12255 pRoamProfile = &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
12256
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012257 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12258 TRACE_CODE_HDD_CFG80211_DISCONNECT,
12259 pAdapter->sessionId, reason));
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012260 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s(%d)",
12261 __func__, hdd_device_modetoString(pAdapter->device_mode),
12262 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012263
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012264 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
12265 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -070012266
Jeff Johnson295189b2012-06-20 16:38:30 -070012267 if (NULL != pRoamProfile)
12268 {
12269 /*issue disconnect request to SME, if station is in connected state*/
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012270 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
12271 (pHddStaCtx->conn_info.connState == eConnectionState_Connecting))
Jeff Johnson295189b2012-06-20 16:38:30 -070012272 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012273 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -070012274 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012275 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070012276 switch(reason)
12277 {
12278 case WLAN_REASON_MIC_FAILURE:
12279 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
12280 break;
12281
12282 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
12283 case WLAN_REASON_DISASSOC_AP_BUSY:
12284 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
12285 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
12286 break;
12287
12288 case WLAN_REASON_PREV_AUTH_NOT_VALID:
12289 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
Abhishek Singhc3269a52014-05-21 17:22:24 +053012290 case WLAN_REASON_DEAUTH_LEAVING:
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
12292 break;
12293
Jeff Johnson295189b2012-06-20 16:38:30 -070012294 default:
12295 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
12296 break;
12297 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012298 pScanInfo = &pHddCtx->scan_info;
12299 if (pScanInfo->mScanPending)
12300 {
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012301 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012302 "Aborting Scan");
Kaushik, Sushant4975a572014-10-21 16:07:48 +053012303 hdd_abort_mac_scan(pHddCtx, pScanInfo->sessionId,
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053012304 eCSR_SCAN_ABORT_DEFAULT);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +053012305 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012306
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012307#ifdef FEATURE_WLAN_TDLS
12308 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012309 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012310 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012311 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
12312 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012313 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -080012314 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012315 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053012316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012317 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -080012318 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070012319 MAC_ADDR_ARRAY(mac));
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053012320 status = sme_DeleteTdlsPeerSta(
12321 WLAN_HDD_GET_HAL_CTX(pAdapter),
12322 pAdapter->sessionId,
12323 mac);
12324 if (status != eHAL_STATUS_SUCCESS) {
12325 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
12326 return -EPERM;
12327 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -080012328 }
12329 }
12330#endif
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +053012331 hddLog(LOG1, FL("Disconnecting with reasoncode:%u"), reasonCode);
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012332 status = wlan_hdd_disconnect(pAdapter, reasonCode);
12333 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -070012334 {
12335 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012336 "%s wlan_hdd_disconnect failure, returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012337 __func__, (int)status );
12338 return -EINVAL;
12339 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012340 }
Mahesh A Saptasagar280fd5a2013-12-05 15:38:31 +053012341 else
12342 {
12343 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unexpected cfg disconnect API"
12344 "called while in %d state", __func__,
12345 pHddStaCtx->conn_info.connState);
12346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012347 }
12348 else
12349 {
12350 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
12351 }
12352
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012353 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012354 return status;
12355}
12356
Mahesh A Saptasagarfafb7fe2014-05-16 13:19:37 +053012357static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
12358 struct net_device *dev,
12359 u16 reason
12360 )
12361{
12362 int ret;
12363 vos_ssr_protect(__func__);
12364 ret = __wlan_hdd_cfg80211_disconnect(wiphy, dev, reason);
12365 vos_ssr_unprotect(__func__);
12366
12367 return ret;
12368}
Gopichand Nakkala78a6c812013-05-13 16:39:49 +053012369
Jeff Johnson295189b2012-06-20 16:38:30 -070012370/*
12371 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012372 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -070012373 * settings in IBSS mode.
12374 */
12375static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012376 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 struct cfg80211_ibss_params *params
12378 )
12379{
12380 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012381 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012382 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
12383 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012384
Jeff Johnson295189b2012-06-20 16:38:30 -070012385 ENTER();
12386
12387 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -070012388 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070012389
12390 if (params->ie_len && ( NULL != params->ie) )
12391 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012392 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12393 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 {
12395 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
12396 encryptionType = eCSR_ENCRYPT_TYPE_AES;
12397 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012398 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -070012399 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012400 tDot11fIEWPA dot11WPAIE;
12401 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012402 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012403
Wilson Yang00256342013-10-10 23:13:38 -070012404 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012405 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
12406 params->ie_len, DOT11F_EID_WPA);
12407 if ( NULL != ie )
12408 {
12409 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
12410 // Unpack the WPA IE
12411 //Skip past the EID byte and length byte - and four byte WiFi OUI
12412 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
12413 &ie[2+4],
12414 ie[1] - 4,
12415 &dot11WPAIE);
12416 /*Extract the multicast cipher, the encType for unicast
12417 cipher for wpa-none is none*/
12418 encryptionType =
12419 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
12420 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012421 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -070012422
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
12424
12425 if (0 > status)
12426 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012427 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 __func__);
12429 return status;
12430 }
12431 }
12432
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012433 pWextState->roamProfile.AuthType.authType[0] =
12434 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -070012435 eCSR_AUTH_TYPE_OPEN_SYSTEM;
12436
12437 if (params->privacy)
12438 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012439 /* Security enabled IBSS, At this time there is no information available
12440 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -070012441 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012442 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -070012443 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012444 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -070012445 *enable privacy bit in beacons */
12446
12447 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
12448 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070012449 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
12450 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012451 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
12452 pWextState->roamProfile.EncryptionType.numEntries = 1;
12453 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 return status;
12455}
12456
12457/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012458 * FUNCTION: __wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012459 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012461static int __wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 struct net_device *dev,
12463 struct cfg80211_ibss_params *params
12464 )
12465{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012466 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -070012467 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12468 tCsrRoamProfile *pRoamProfile;
12469 int status;
krunal sonie9002db2013-11-25 14:24:17 -080012470 bool alloc_bssid = VOS_FALSE;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012471 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
12472 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012473
12474 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012475
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012476 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12477 TRACE_CODE_HDD_CFG80211_JOIN_IBSS,
12478 pAdapter->sessionId, pAdapter->device_mode));
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012479 hddLog(VOS_TRACE_LEVEL_INFO,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012480 "%s: device_mode = %s (%d)", __func__,
12481 hdd_device_modetoString(pAdapter->device_mode),
12482 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012483
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012484 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012485 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -070012486 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012487 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012488 }
12489
12490 if (NULL == pWextState)
12491 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012492 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012493 __func__);
12494 return -EIO;
12495 }
12496
Agarwal Ashish51325b52014-06-16 16:50:49 +053012497 if (vos_max_concurrent_connections_reached()) {
12498 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
12499 return -ECONNREFUSED;
12500 }
12501
Vinay Krishna Eranna21042322014-01-08 19:21:39 +053012502 /*Try disconnecting if already in connected state*/
12503 status = wlan_hdd_try_disconnect(pAdapter);
12504 if ( 0 > status)
12505 {
12506 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
12507 " IBSS connection"));
12508 return -EALREADY;
12509 }
12510
Jeff Johnson295189b2012-06-20 16:38:30 -070012511 pRoamProfile = &pWextState->roamProfile;
12512
12513 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
12514 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012515 hddLog (VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080012516 "%s Interface type is not set to IBSS", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070012517 return -EINVAL;
12518 }
12519
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012520 /* BSSID is provided by upper layers hence no need to AUTO generate */
12521 if (NULL != params->bssid) {
12522 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12523 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
12524 hddLog (VOS_TRACE_LEVEL_ERROR,
12525 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12526 return -EIO;
12527 }
12528 }
krunal sonie9002db2013-11-25 14:24:17 -080012529 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
12530 {
12531 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
12532 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
12533 {
12534 hddLog (VOS_TRACE_LEVEL_ERROR,
12535 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
12536 return -EIO;
12537 }
Sachin Ahuja46ff4912015-03-23 22:48:43 +053012538 params->bssid = vos_mem_malloc(VOS_MAC_ADDR_SIZE);
krunal sonie9002db2013-11-25 14:24:17 -080012539 if (!params->bssid)
12540 {
12541 hddLog (VOS_TRACE_LEVEL_ERROR,
12542 "%s:Failed memory allocation", __func__);
12543 return -EIO;
12544 }
12545 vos_mem_copy((v_U8_t *)params->bssid,
12546 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
12547 VOS_MAC_ADDR_SIZE);
12548 alloc_bssid = VOS_TRUE;
12549 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -070012550
Jeff Johnson295189b2012-06-20 16:38:30 -070012551 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -070012552 if (NULL !=
12553#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12554 params->chandef.chan)
12555#else
12556 params->channel)
12557#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012558 {
12559 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012560 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
12561 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
12562 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
12563 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -070012564
12565 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012566 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -070012567 ieee80211_frequency_to_channel(
12568#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
12569 params->chandef.chan->center_freq);
12570#else
12571 params->channel->center_freq);
12572#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012573
12574 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
12575 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012577 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
12578 __func__);
12579 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -070012580 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012581
12582 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -070012583 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012584 if (channelNum == validChan[indx])
12585 {
12586 break;
12587 }
12588 }
12589 if (indx >= numChans)
12590 {
12591 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070012592 __func__, channelNum);
12593 return -EINVAL;
12594 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012595 /* Set the Operational Channel */
12596 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
12597 channelNum);
12598 pRoamProfile->ChannelInfo.numOfChannels = 1;
12599 pHddStaCtx->conn_info.operationChannel = channelNum;
12600 pRoamProfile->ChannelInfo.ChannelList =
12601 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 }
12603
12604 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012605 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -070012606 if (status < 0)
12607 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012608 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -070012609 __func__);
12610 return status;
12611 }
12612
12613 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012614 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -070012615 params->ssid_len, params->bssid,
12616 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -070012617
12618 if (0 > status)
12619 {
12620 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
12621 return status;
12622 }
12623
krunal sonie9002db2013-11-25 14:24:17 -080012624 if (NULL != params->bssid &&
12625 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
12626 alloc_bssid == VOS_TRUE)
12627 {
12628 vos_mem_free(params->bssid);
12629 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012630 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012631 return 0;
12632}
12633
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012634static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
12635 struct net_device *dev,
12636 struct cfg80211_ibss_params *params
12637 )
12638{
12639 int ret = 0;
12640
12641 vos_ssr_protect(__func__);
12642 ret = __wlan_hdd_cfg80211_join_ibss(wiphy, dev, params);
12643 vos_ssr_unprotect(__func__);
12644
12645 return ret;
12646}
12647
Jeff Johnson295189b2012-06-20 16:38:30 -070012648/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012649 * FUNCTION: __wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012650 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -070012651 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012652static int __wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012653 struct net_device *dev
12654 )
12655{
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012656 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012657 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
12658 tCsrRoamProfile *pRoamProfile;
12659 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012660 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012661
12662 ENTER();
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053012663
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012664 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12665 TRACE_CODE_HDD_CFG80211_LEAVE_IBSS,
12666 pAdapter->sessionId, eCSR_DISCONNECT_REASON_IBSS_LEAVE));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012667 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012668 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012669 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012670 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012671 }
12672
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053012673 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %s (%d)", __func__,
12674 hdd_device_modetoString(pAdapter->device_mode),
12675 pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -070012676 if (NULL == pWextState)
12677 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080012678 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption",
Jeff Johnson295189b2012-06-20 16:38:30 -070012679 __func__);
12680 return -EIO;
12681 }
12682
12683 pRoamProfile = &pWextState->roamProfile;
12684
12685 /* Issue disconnect only if interface type is set to IBSS */
12686 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
12687 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012688 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 __func__);
12690 return -EINVAL;
12691 }
12692
12693 /* Issue Disconnect request */
12694 INIT_COMPLETION(pAdapter->disconnect_comp_var);
12695 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
12696 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
12697
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012698 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012699 return 0;
12700}
12701
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053012702static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
12703 struct net_device *dev
12704 )
12705{
12706 int ret = 0;
12707
12708 vos_ssr_protect(__func__);
12709 ret = __wlan_hdd_cfg80211_leave_ibss(wiphy, dev);
12710 vos_ssr_unprotect(__func__);
12711
12712 return ret;
12713}
12714
Jeff Johnson295189b2012-06-20 16:38:30 -070012715/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012716 * FUNCTION: __wlan_hdd_cfg80211_set_wiphy_params
Jeff Johnson295189b2012-06-20 16:38:30 -070012717 * This function is used to set the phy parameters
12718 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
12719 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012720static int __wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -070012721 u32 changed)
12722{
12723 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
12724 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012725 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012726
12727 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012728
12729 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012730 TRACE_CODE_HDD_CFG80211_SET_WIPHY_PARAMS,
12731 NO_SESSION, wiphy->rts_threshold));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012732
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012733 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012734 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012735 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012736 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012737 }
12738
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
12740 {
12741 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
12742 WNI_CFG_RTS_THRESHOLD_STAMAX :
12743 wiphy->rts_threshold;
12744
12745 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012746 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -070012747 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012748 hddLog(VOS_TRACE_LEVEL_ERROR,
12749 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012750 __func__, rts_threshold);
12751 return -EINVAL;
12752 }
12753
12754 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
12755 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012756 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012757 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012758 hddLog(VOS_TRACE_LEVEL_ERROR,
12759 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012760 __func__, rts_threshold);
12761 return -EIO;
12762 }
12763
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012764 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012765 rts_threshold);
12766 }
12767
12768 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
12769 {
12770 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
12771 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
12772 wiphy->frag_threshold;
12773
12774 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012775 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012776 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012777 hddLog(VOS_TRACE_LEVEL_ERROR,
12778 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -070012779 frag_threshold);
12780 return -EINVAL;
12781 }
12782
12783 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
12784 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012785 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012786 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012787 hddLog(VOS_TRACE_LEVEL_ERROR,
12788 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 __func__, frag_threshold);
12790 return -EIO;
12791 }
12792
12793 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
12794 frag_threshold);
12795 }
12796
12797 if ((changed & WIPHY_PARAM_RETRY_SHORT)
12798 || (changed & WIPHY_PARAM_RETRY_LONG))
12799 {
12800 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
12801 wiphy->retry_short :
12802 wiphy->retry_long;
12803
12804 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
12805 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
12806 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012807 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 __func__, retry_value);
12809 return -EINVAL;
12810 }
12811
12812 if (changed & WIPHY_PARAM_RETRY_SHORT)
12813 {
12814 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
12815 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012816 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012817 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012818 hddLog(VOS_TRACE_LEVEL_ERROR,
12819 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 __func__, retry_value);
12821 return -EIO;
12822 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012823 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012824 __func__, retry_value);
12825 }
12826 else if (changed & WIPHY_PARAM_RETRY_SHORT)
12827 {
12828 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
12829 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012830 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012831 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012832 hddLog(VOS_TRACE_LEVEL_ERROR,
12833 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012834 __func__, retry_value);
12835 return -EIO;
12836 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012837 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 __func__, retry_value);
12839 }
12840 }
12841
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012842 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012843 return 0;
12844}
12845
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012846static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
12847 u32 changed)
12848{
12849 int ret;
12850
12851 vos_ssr_protect(__func__);
12852 ret = __wlan_hdd_cfg80211_set_wiphy_params(wiphy, changed);
12853 vos_ssr_unprotect(__func__);
12854
12855 return ret;
12856}
12857
Jeff Johnson295189b2012-06-20 16:38:30 -070012858/*
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012859 * FUNCTION: __wlan_hdd_cfg80211_set_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070012860 * This function is used to set the txpower
12861 */
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012862static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070012863#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12864 struct wireless_dev *wdev,
12865#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012866#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012867 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070012868#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012869 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -070012870#endif
12871 int dbm)
12872{
12873 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012874 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012875 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
12876 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012877 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012878
12879 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012880
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053012881 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
12882 TRACE_CODE_HDD_CFG80211_SET_TXPOWER,
12883 NO_SESSION, type ));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012884 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012885 if (0 != status)
12886 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012887 return status;
12888 }
12889
12890 hHal = pHddCtx->hHal;
12891
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012892 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
12893 dbm, ccmCfgSetCallback,
12894 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -070012895 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012896 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -070012897 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
12898 return -EIO;
12899 }
12900
12901 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
12902 dbm);
12903
12904 switch(type)
12905 {
12906 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
12907 /* Fall through */
12908 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
12909 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
12910 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012911 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
12912 __func__);
12913 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -070012914 }
12915 break;
12916 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012917 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -070012918 __func__);
12919 return -EOPNOTSUPP;
12920 break;
12921 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +053012922 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
12923 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -070012924 return -EIO;
12925 }
12926
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053012927 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012928 return 0;
12929}
12930
Mahesh A Saptasagar179d2252014-06-02 21:32:21 +053012931static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
12932#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12933 struct wireless_dev *wdev,
12934#endif
12935#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12936 enum tx_power_setting type,
12937#else
12938 enum nl80211_tx_power_setting type,
12939#endif
12940 int dbm)
12941{
12942 int ret;
12943 vos_ssr_protect(__func__);
12944 ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
12945#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12946 wdev,
12947#endif
12948#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
12949 type,
12950#else
12951 type,
12952#endif
12953 dbm);
12954 vos_ssr_unprotect(__func__);
12955
12956 return ret;
12957}
12958
Jeff Johnson295189b2012-06-20 16:38:30 -070012959/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012960 * FUNCTION: __wlan_hdd_cfg80211_get_txpower
Jeff Johnson295189b2012-06-20 16:38:30 -070012961 * This function is used to read the txpower
12962 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012963static int __wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -070012964#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12965 struct wireless_dev *wdev,
12966#endif
12967 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -070012968{
12969
12970 hdd_adapter_t *pAdapter;
12971 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012972 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070012973
Jeff Johnsone7245742012-09-05 17:12:55 -070012974 ENTER();
12975
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012976 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012977 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012978 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053012979 *dbm = 0;
12980 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012981 }
12982
Jeff Johnson295189b2012-06-20 16:38:30 -070012983 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
12984 if (NULL == pAdapter)
12985 {
12986 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
12987 return -ENOENT;
12988 }
12989
12990 wlan_hdd_get_classAstats(pAdapter);
12991 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
12992
Jeff Johnsone7245742012-09-05 17:12:55 -070012993 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070012994 return 0;
12995}
12996
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053012997static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
12998#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
12999 struct wireless_dev *wdev,
13000#endif
13001 int *dbm)
13002{
13003 int ret;
13004
13005 vos_ssr_protect(__func__);
13006 ret = __wlan_hdd_cfg80211_get_txpower(wiphy,
13007#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
13008 wdev,
13009#endif
13010 dbm);
13011 vos_ssr_unprotect(__func__);
13012
13013 return ret;
13014}
13015
13016
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013017static int __wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -070013018 u8* mac, struct station_info *sinfo)
13019{
13020 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
13021 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
13022 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
c_hpothu44ff4e02014-05-08 00:13:57 +053013023 tANI_U32 rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -070013024
13025 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
13026 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -070013027
13028 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
13029 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
13030 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
13031 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
13032 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
13033 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
13034 tANI_U16 maxRate = 0;
13035 tANI_U16 myRate;
13036 tANI_U16 currentRate = 0;
13037 tANI_U8 maxSpeedMCS = 0;
13038 tANI_U8 maxMCSIdx = 0;
13039 tANI_U8 rateFlag = 1;
c_hpothu79aab322014-07-14 21:11:01 +053013040 tANI_U8 i, j, rssidx, mode=0;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -070013041 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013042 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013043
Leo Chang6f8870f2013-03-26 18:11:36 -070013044#ifdef WLAN_FEATURE_11AC
13045 tANI_U32 vht_mcs_map;
13046 eDataRate11ACMaxMcs vhtMaxMcs;
13047#endif /* WLAN_FEATURE_11AC */
13048
Jeff Johnsone7245742012-09-05 17:12:55 -070013049 ENTER();
13050
Jeff Johnson295189b2012-06-20 16:38:30 -070013051 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
13052 (0 == ssidlen))
13053 {
13054 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
13055 " Invalid ssidlen, %d", __func__, ssidlen);
13056 /*To keep GUI happy*/
13057 return 0;
13058 }
13059
Mukul Sharma811205f2014-07-09 21:07:30 +053013060 if (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
13061 {
13062 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
13063 "%s: Roaming in progress, so unable to proceed this request", __func__);
13064 return 0;
13065 }
13066
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013067 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013068 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013069 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013070 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013071 }
13072
Jeff Johnson295189b2012-06-20 16:38:30 -070013073
Kiet Lam3b17fc82013-09-27 05:24:08 +053013074 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
13075 sinfo->filled |= STATION_INFO_SIGNAL;
13076
c_hpothu09f19542014-05-30 21:53:31 +053013077 wlan_hdd_get_station_stats(pAdapter);
13078 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
13079
13080 /*overwrite rate_flags if MAX link-speed need to be reported*/
c_hpothu44ff4e02014-05-08 00:13:57 +053013081 if ((eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed) ||
13082 (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed &&
c_hpothu79aab322014-07-14 21:11:01 +053013083 sinfo->signal >= pCfg->linkSpeedRssiLow))
c_hpothu44ff4e02014-05-08 00:13:57 +053013084 {
13085 rate_flags = pAdapter->maxRateFlags;
13086 }
c_hpothu44ff4e02014-05-08 00:13:57 +053013087
Jeff Johnson295189b2012-06-20 16:38:30 -070013088 //convert to the UI units of 100kbps
13089 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
13090
13091#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -070013092 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 -070013093 sinfo->signal,
13094 pCfg->reportMaxLinkSpeed,
13095 myRate,
13096 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013097 (int) pCfg->linkSpeedRssiMid,
13098 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -070013099 (int) rate_flags,
13100 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -070013101#endif //LINKSPEED_DEBUG_ENABLED
13102
13103 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
13104 {
13105 // we do not want to necessarily report the current speed
13106 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
13107 {
13108 // report the max possible speed
13109 rssidx = 0;
13110 }
13111 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
13112 {
13113 // report the max possible speed with RSSI scaling
13114 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
13115 {
13116 // report the max possible speed
13117 rssidx = 0;
13118 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013119 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -070013120 {
13121 // report middle speed
13122 rssidx = 1;
13123 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013124 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
13125 {
13126 // report middle speed
13127 rssidx = 2;
13128 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013129 else
13130 {
13131 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -070013132 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -070013133 }
13134 }
13135 else
13136 {
13137 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
13138 hddLog(VOS_TRACE_LEVEL_ERROR,
13139 "%s: Invalid value for reportMaxLinkSpeed: %u",
13140 __func__, pCfg->reportMaxLinkSpeed);
13141 rssidx = 0;
13142 }
13143
13144 maxRate = 0;
13145
13146 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013147 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
13148 OperationalRates, &ORLeng))
13149 {
13150 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13151 /*To keep GUI happy*/
13152 return 0;
13153 }
13154
Jeff Johnson295189b2012-06-20 16:38:30 -070013155 for (i = 0; i < ORLeng; i++)
13156 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013157 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013158 {
13159 /* Validate Rate Set */
13160 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
13161 {
13162 currentRate = supported_data_rate[j].supported_rate[rssidx];
13163 break;
13164 }
13165 }
13166 /* Update MAX rate */
13167 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13168 }
13169
13170 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013171 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
13172 ExtendedRates, &ERLeng))
13173 {
13174 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13175 /*To keep GUI happy*/
13176 return 0;
13177 }
13178
Jeff Johnson295189b2012-06-20 16:38:30 -070013179 for (i = 0; i < ERLeng; i++)
13180 {
Jeff Johnsone7245742012-09-05 17:12:55 -070013181 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013182 {
13183 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
13184 {
13185 currentRate = supported_data_rate[j].supported_rate[rssidx];
13186 break;
13187 }
13188 }
13189 /* Update MAX rate */
13190 maxRate = (currentRate > maxRate)?currentRate:maxRate;
13191 }
c_hpothu79aab322014-07-14 21:11:01 +053013192
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013193 /* Get MCS Rate Set --
Kaushik, Sushantdc304d82014-01-22 10:58:37 +053013194 Only if we are always reporting max speed (or)
Kiet Lamb69f8dc2013-11-15 15:34:27 +053013195 if we have good rssi */
c_hpothu79aab322014-07-14 21:11:01 +053013196 if ((3 != rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -070013197 {
c_hpothu79aab322014-07-14 21:11:01 +053013198 if (rate_flags & eHAL_TX_RATE_VHT80)
13199 mode = 2;
13200 else if (rate_flags & (eHAL_TX_RATE_VHT40 | eHAL_TX_RATE_HT40))
13201 mode = 1;
13202 else
13203 mode = 0;
13204
Gopichand Nakkala05ab1322013-02-15 11:28:38 +053013205 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
13206 MCSRates, &MCSLeng))
13207 {
13208 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
13209 /*To keep GUI happy*/
13210 return 0;
13211 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013212 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -070013213#ifdef WLAN_FEATURE_11AC
13214 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013215 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013217 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013218 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -070013219 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -070013220 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013221 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013223 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -070013224 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013225 maxMCSIdx = 7;
13226 }
13227 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
13228 {
13229 maxMCSIdx = 8;
13230 }
13231 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
13232 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013233 //VHT20 is supporting 0~8
13234 if (rate_flags & eHAL_TX_RATE_VHT20)
13235 maxMCSIdx = 8;
13236 else
13237 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -070013238 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013239
c_hpothu79aab322014-07-14 21:11:01 +053013240 if (0 != rssidx)/*check for scaled */
13241 {
13242 //get middle rate MCS index if rssi=1/2
13243 for (i=0; i <= maxMCSIdx; i++)
13244 {
13245 if (sinfo->signal <= rssiMcsTbl[mode][i])
13246 {
13247 maxMCSIdx = i;
13248 break;
13249 }
13250 }
13251 }
13252
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013253 if (rate_flags & eHAL_TX_RATE_VHT80)
13254 {
13255 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
13256 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
13257 }
13258 else if (rate_flags & eHAL_TX_RATE_VHT40)
13259 {
13260 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
13261 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
13262 }
13263 else if (rate_flags & eHAL_TX_RATE_VHT20)
13264 {
13265 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
13266 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
13267 }
13268
Leo Chang6f8870f2013-03-26 18:11:36 -070013269 maxSpeedMCS = 1;
13270 if (currentRate > maxRate)
13271 {
13272 maxRate = currentRate;
13273 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013274
Leo Chang6f8870f2013-03-26 18:11:36 -070013275 }
13276 else
13277#endif /* WLAN_FEATURE_11AC */
13278 {
13279 if (rate_flags & eHAL_TX_RATE_HT40)
13280 {
13281 rateFlag |= 1;
13282 }
13283 if (rate_flags & eHAL_TX_RATE_SGI)
13284 {
13285 rateFlag |= 2;
13286 }
13287
Girish Gowli01abcee2014-07-31 20:18:55 +053013288 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
c_hpothu79aab322014-07-14 21:11:01 +053013289 if (rssidx == 1 || rssidx == 2)
13290 {
13291 //get middle rate MCS index if rssi=1/2
13292 for (i=0; i <= 7; i++)
13293 {
13294 if (sinfo->signal <= rssiMcsTbl[mode][i])
13295 {
13296 temp = i+1;
13297 break;
13298 }
13299 }
13300 }
c_hpothu79aab322014-07-14 21:11:01 +053013301
13302 for (i = 0; i < MCSLeng; i++)
13303 {
Leo Chang6f8870f2013-03-26 18:11:36 -070013304 for (j = 0; j < temp; j++)
13305 {
13306 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
13307 {
13308 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
13309 break;
13310 }
13311 }
13312 if ((j < temp) && (currentRate > maxRate))
13313 {
13314 maxRate = currentRate;
13315 maxSpeedMCS = 1;
13316 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
13317 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013318 }
13319 }
13320 }
13321
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013322 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
13323 {
13324 maxRate = myRate;
13325 maxSpeedMCS = 1;
13326 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13327 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013328 // make sure we report a value at least as big as our current rate
c_hpothu79aab322014-07-14 21:11:01 +053013329 if ((maxRate < myRate) || (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 {
13331 maxRate = myRate;
13332 if (rate_flags & eHAL_TX_RATE_LEGACY)
13333 {
13334 maxSpeedMCS = 0;
13335 }
13336 else
13337 {
13338 maxSpeedMCS = 1;
13339 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
13340 }
13341 }
13342
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013343 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -070013344 {
13345 sinfo->txrate.legacy = maxRate;
13346#ifdef LINKSPEED_DEBUG_ENABLED
13347 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
13348#endif //LINKSPEED_DEBUG_ENABLED
13349 }
13350 else
13351 {
13352 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -070013353#ifdef WLAN_FEATURE_11AC
13354 sinfo->txrate.nss = 1;
13355 if (rate_flags & eHAL_TX_RATE_VHT80)
13356 {
13357 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013358 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -070013359 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013360 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -070013361 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013362 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13363 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13364 }
13365 else if (rate_flags & eHAL_TX_RATE_VHT20)
13366 {
13367 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13368 }
13369#endif /* WLAN_FEATURE_11AC */
13370 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
13371 {
13372 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13373 if (rate_flags & eHAL_TX_RATE_HT40)
13374 {
13375 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13376 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013377 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013378 if (rate_flags & eHAL_TX_RATE_SGI)
13379 {
13380 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13381 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +053013382
Jeff Johnson295189b2012-06-20 16:38:30 -070013383#ifdef LINKSPEED_DEBUG_ENABLED
13384 pr_info("Reporting MCS rate %d flags %x\n",
13385 sinfo->txrate.mcs,
13386 sinfo->txrate.flags );
13387#endif //LINKSPEED_DEBUG_ENABLED
13388 }
13389 }
13390 else
13391 {
13392 // report current rate instead of max rate
13393
13394 if (rate_flags & eHAL_TX_RATE_LEGACY)
13395 {
13396 //provide to the UI in units of 100kbps
13397 sinfo->txrate.legacy = myRate;
13398#ifdef LINKSPEED_DEBUG_ENABLED
13399 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
13400#endif //LINKSPEED_DEBUG_ENABLED
13401 }
13402 else
13403 {
13404 //must be MCS
13405 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -070013406#ifdef WLAN_FEATURE_11AC
13407 sinfo->txrate.nss = 1;
13408 if (rate_flags & eHAL_TX_RATE_VHT80)
13409 {
13410 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
13411 }
13412 else
13413#endif /* WLAN_FEATURE_11AC */
13414 {
13415 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
13416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 if (rate_flags & eHAL_TX_RATE_SGI)
13418 {
13419 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
13420 }
13421 if (rate_flags & eHAL_TX_RATE_HT40)
13422 {
13423 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
13424 }
Leo Chang6f8870f2013-03-26 18:11:36 -070013425#ifdef WLAN_FEATURE_11AC
13426 else if (rate_flags & eHAL_TX_RATE_VHT80)
13427 {
13428 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
13429 }
13430#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -070013431#ifdef LINKSPEED_DEBUG_ENABLED
13432 pr_info("Reporting actual MCS rate %d flags %x\n",
13433 sinfo->txrate.mcs,
13434 sinfo->txrate.flags );
13435#endif //LINKSPEED_DEBUG_ENABLED
13436 }
13437 }
13438 sinfo->filled |= STATION_INFO_TX_BITRATE;
13439
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013440 sinfo->tx_packets =
13441 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
13442 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
13443 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
13444 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
13445
13446 sinfo->tx_retries =
13447 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
13448 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
13449 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
13450 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
13451
13452 sinfo->tx_failed =
13453 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
13454 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
13455 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
13456 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
13457
13458 sinfo->filled |=
13459 STATION_INFO_TX_PACKETS |
13460 STATION_INFO_TX_RETRIES |
13461 STATION_INFO_TX_FAILED;
13462
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013463 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13464 TRACE_CODE_HDD_CFG80211_GET_STA,
13465 pAdapter->sessionId, maxRate));
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -070013466 EXIT();
13467 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013468}
13469
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013470static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
13471 u8* mac, struct station_info *sinfo)
13472{
13473 int ret;
13474
13475 vos_ssr_protect(__func__);
13476 ret = __wlan_hdd_cfg80211_get_station(wiphy, dev, mac, sinfo);
13477 vos_ssr_unprotect(__func__);
13478
13479 return ret;
13480}
13481
13482static int __wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -070013483 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -070013484{
13485 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013486 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -070013487 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013488 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013489
Jeff Johnsone7245742012-09-05 17:12:55 -070013490 ENTER();
13491
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 if (NULL == pAdapter)
13493 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080013494 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 return -ENODEV;
13496 }
13497
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013498 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13499 TRACE_CODE_HDD_CFG80211_SET_POWER_MGMT,
13500 pAdapter->sessionId, timeout));
13501
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013502 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013503 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013504 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013505 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013506 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013507 }
13508
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013509 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
13510 (TRUE == pHddCtx->hdd_wlan_suspended) &&
13511 (pHddCtx->cfg_ini->fhostArpOffload) &&
13512 (eConnectionState_Associated ==
13513 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
13514 {
Amar Singhald53568e2013-09-26 11:03:45 -070013515
13516 hddLog(VOS_TRACE_LEVEL_INFO,
13517 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +053013518 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013519 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13520 {
13521 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -080013522 "%s:Failed to enable ARPOFFLOAD Feature %d",
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053013523 __func__, vos_status);
13524 }
13525 }
13526
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 /**The get power cmd from the supplicant gets updated by the nl only
13528 *on successful execution of the function call
13529 *we are oppositely mapped w.r.t mode in the driver
13530 **/
13531 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
13532
13533 if (VOS_STATUS_E_FAILURE == vos_status)
13534 {
c_hpothu6ff1c3c2013-10-01 19:01:57 +053013535 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13536 "%s: failed to enter bmps mode", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 return -EINVAL;
13538 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013539 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 return 0;
13541}
13542
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013543static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
13544 struct net_device *dev, bool mode, int timeout)
13545{
13546 int ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013547
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013548 vos_ssr_protect(__func__);
13549 ret = __wlan_hdd_cfg80211_set_power_mgmt(wiphy, dev, mode, timeout);
13550 vos_ssr_unprotect(__func__);
13551
13552 return ret;
13553}
Jeff Johnson295189b2012-06-20 16:38:30 -070013554#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013555static int __wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
13556 struct net_device *netdev,
13557 u8 key_index)
13558{
13559 ENTER();
13560 return 0;
13561}
13562
Jeff Johnson295189b2012-06-20 16:38:30 -070013563static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013564 struct net_device *netdev,
13565 u8 key_index)
13566{
13567 int ret;
13568 vos_ssr_protect(__func__);
13569 ret = __wlan_hdd_set_default_mgmt_key(wiphy, netdev, key_index);
13570 vos_ssr_unprotect(__func__);
13571 return ret;
13572}
13573#endif //LINUX_VERSION_CODE
13574
13575#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13576static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13577 struct net_device *dev,
13578 struct ieee80211_txq_params *params)
13579{
13580 ENTER();
13581 return 0;
13582}
13583#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13584static int __wlan_hdd_set_txq_params(struct wiphy *wiphy,
13585 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013586{
Jeff Johnsone7245742012-09-05 17:12:55 -070013587 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -070013588 return 0;
13589}
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013590#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -070013591
13592#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
13593static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013594 struct net_device *dev,
13595 struct ieee80211_txq_params *params)
Jeff Johnson295189b2012-06-20 16:38:30 -070013596{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013597 int ret;
13598
13599 vos_ssr_protect(__func__);
13600 ret = __wlan_hdd_set_txq_params(wiphy, dev, params);
13601 vos_ssr_unprotect(__func__);
13602 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013603}
13604#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
13605static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
13606 struct ieee80211_txq_params *params)
13607{
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013608 int ret;
13609
13610 vos_ssr_protect(__func__);
13611 ret = __wlan_hdd_set_txq_params(wiphy, params);
13612 vos_ssr_unprotect(__func__);
13613 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -070013614}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013615#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013616
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013617static int __wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013618 struct net_device *dev,
13619 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -070013620{
13621 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013622 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013623 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013624 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013625 v_U8_t staId;
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013626 v_CONTEXT_t pVosContext = NULL;
13627 ptSapContext pSapCtx = NULL;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013628
Jeff Johnsone7245742012-09-05 17:12:55 -070013629 ENTER();
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013630
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013631 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013633 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 return -EINVAL;
13635 }
13636
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013637 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13638 TRACE_CODE_HDD_CFG80211_DEL_STA,
13639 pAdapter->sessionId, pAdapter->device_mode));
13640
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013641 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13642 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013643 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013644 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013645 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013646 }
13647
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013649 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -070013650 )
13651 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013652 pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
13653 pSapCtx = VOS_GET_SAP_CB(pVosContext);
13654 if(pSapCtx == NULL){
13655 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13656 FL("psapCtx is NULL"));
13657 return -ENOENT;
13658 }
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013659 if (vos_is_macaddr_broadcast((v_MACADDR_t *)pDelStaParams->peerMacAddr))
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 {
13661 v_U16_t i;
13662 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
13663 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013664 if ((pSapCtx->aStaInfo[i].isUsed) &&
13665 (!pSapCtx->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -070013666 {
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013667 vos_mem_copy(pDelStaParams->peerMacAddr,
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013668 pSapCtx->aStaInfo[i].macAddrSTA.bytes,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013669 ETHER_ADDR_LEN);
13670
Jeff Johnson295189b2012-06-20 16:38:30 -070013671 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013672 "%s: Delete STA with MAC::"
13673 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013674 __func__,
13675 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
13676 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -070013677 if (VOS_IS_STATUS_SUCCESS(vos_status))
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013678 pSapCtx->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013679 }
13680 }
13681 }
13682 else
13683 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013684
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013685 vos_status = hdd_softap_GetStaId(pAdapter,
13686 (v_MACADDR_t *)pDelStaParams->peerMacAddr, &staId);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013687 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13688 {
13689 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013690 "%s: Skip this DEL STA as this is not used::"
13691 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013692 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013693 return -ENOENT;
13694 }
13695
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013696 if( pSapCtx->aStaInfo[staId].isDeauthInProgress == TRUE)
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013697 {
13698 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -080013699 "%s: Skip this DEL STA as deauth is in progress::"
13700 MAC_ADDRESS_STR,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013701 __func__, MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013702 return -ENOENT;
13703 }
13704
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013705 pSapCtx->aStaInfo[staId].isDeauthInProgress = TRUE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013706
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 hddLog(VOS_TRACE_LEVEL_INFO,
13708 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013709 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -070013710 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013711 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013712
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013713 vos_status = hdd_softap_sta_deauth(pAdapter, pDelStaParams);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013714 if (!VOS_IS_STATUS_SUCCESS(vos_status))
13715 {
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053013716 pSapCtx->aStaInfo[staId].isDeauthInProgress = FALSE;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013717 hddLog(VOS_TRACE_LEVEL_INFO,
13718 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -080013719 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013720 __func__,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013721 MAC_ADDR_ARRAY(pDelStaParams->peerMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080013722 return -ENOENT;
13723 }
13724
Jeff Johnson295189b2012-06-20 16:38:30 -070013725 }
13726 }
13727
13728 EXIT();
13729
13730 return 0;
13731}
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013732
13733#ifdef CFG80211_DEL_STA_V2
13734static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13735 struct net_device *dev,
13736 struct station_del_parameters *param)
13737#else
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013738static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
13739 struct net_device *dev, u8 *mac)
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013740#endif
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013741{
13742 int ret;
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013743 struct tagCsrDelStaParams delStaParams;
Jeff Johnson295189b2012-06-20 16:38:30 -070013744
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013745 vos_ssr_protect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013746
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013747#ifdef CFG80211_DEL_STA_V2
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013748 if (NULL == param) {
13749 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid argumet passed", __func__);
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053013750 vos_ssr_unprotect(__func__);
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013751 return -EINVAL;
13752 }
13753
13754 WLANSAP_PopulateDelStaParams(param->mac, param->reason_code,
13755 param->subtype, &delStaParams);
13756
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013757#else
Sushant Kaushik4cd28f62014-12-26 14:23:50 +053013758 WLANSAP_PopulateDelStaParams(mac, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013759 (SIR_MAC_MGMT_DEAUTH >> 4), &delStaParams);
Naresh Jayaram69e3f282014-10-14 12:29:12 +053013760#endif
Hanumantha Reddy Pothulabfd06f72014-10-31 14:03:37 +053013761 ret = __wlan_hdd_cfg80211_del_station(wiphy, dev, &delStaParams);
13762
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013763 vos_ssr_unprotect(__func__);
13764
13765 return ret;
13766}
13767
13768static int __wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013769 struct net_device *dev, u8 *mac, struct station_parameters *params)
13770{
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013771 hdd_adapter_t *pAdapter;
13772 hdd_context_t *pHddCtx;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013773 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013774#ifdef FEATURE_WLAN_TDLS
13775 u32 mask, set;
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013776
Hoonki Lee11f7dda2013-02-14 16:55:44 -080013777 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013778
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013779 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13780 if (NULL == pAdapter)
13781 {
13782 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
13783 "%s: Adapter is NULL",__func__);
13784 return -EINVAL;
13785 }
13786 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13787 status = wlan_hdd_validate_context(pHddCtx);
13788 if (0 != status)
13789 {
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053013790 return status;
13791 }
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053013792
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013793 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13794 TRACE_CODE_HDD_CFG80211_ADD_STA,
13795 pAdapter->sessionId, params->listen_interval));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013796 mask = params->sta_flags_mask;
13797
13798 set = params->sta_flags_set;
13799
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053013800 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070013801 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
13802 __func__, mask, set, MAC_ADDR_ARRAY(mac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013803
13804 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
13805 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -080013806 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080013807 }
13808 }
13809#endif
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013810 EXIT();
Gopichand Nakkalab977a972013-02-18 19:15:09 -080013811 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013812}
13813
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013814static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
13815 struct net_device *dev, u8 *mac, struct station_parameters *params)
13816{
13817 int ret;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013818
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053013819 vos_ssr_protect(__func__);
13820 ret = __wlan_hdd_cfg80211_add_station(wiphy, dev, mac, params);
13821 vos_ssr_unprotect(__func__);
13822
13823 return ret;
13824}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013825#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -070013826
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013827static int __wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -070013828 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013829{
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013830 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13831 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013832 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013833 int status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013834 hdd_context_t *pHddCtx;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013835 tPmkidCacheInfo pmk_id;
Jeff Johnsone7245742012-09-05 17:12:55 -070013836
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013837 ENTER();
13838
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013839 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013840 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013841 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013842 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013843 return -EINVAL;
13844 }
13845
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013846 if (!pmksa) {
13847 hddLog(LOGE, FL("pmksa is NULL"));
13848 return -EINVAL;
13849 }
13850
13851 if (!pmksa->bssid || !pmksa->pmkid) {
13852 hddLog(LOGE, FL("pmksa->bssid(%p) or pmksa->pmkid(%p) is NULL"),
13853 pmksa->bssid, pmksa->pmkid);
13854 return -EINVAL;
13855 }
13856
13857 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
13858 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
13859
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013860 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13861 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013862 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013863 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053013864 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013865 }
13866
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013867 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013868 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13869
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013870 vos_mem_copy(pmk_id.BSSID, pmksa->bssid, ETHER_ADDR_LEN);
13871 vos_mem_copy(pmk_id.PMKID, pmksa->pmkid, CSR_RSN_PMKID_SIZE);
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013872
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013873 /* Add to the PMKSA ID Cache in CSR */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053013874 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013875 &pmk_id, 1, FALSE);
13876
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053013877 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
13878 TRACE_CODE_HDD_CFG80211_SET_PMKSA,
13879 pAdapter->sessionId, result));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013880
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013881 EXIT();
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013882 return HAL_STATUS_SUCCESS(result) ? 0 : -EINVAL;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013883}
13884
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013885static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
13886 struct cfg80211_pmksa *pmksa)
13887{
13888 int ret;
13889
13890 vos_ssr_protect(__func__);
13891 ret = __wlan_hdd_cfg80211_set_pmksa(wiphy, dev, pmksa);
13892 vos_ssr_unprotect(__func__);
13893
13894 return ret;
13895}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013896
Wilson Yang6507c4e2013-10-01 20:11:19 -070013897
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013898static int __wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -070013899 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013900{
Wilson Yang6507c4e2013-10-01 20:11:19 -070013901 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13902 tHalHandle halHandle;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013903 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080013904 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013905
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013906 ENTER();
13907
Wilson Yang6507c4e2013-10-01 20:11:19 -070013908 /* Validate pAdapter */
13909 if (NULL == pAdapter)
13910 {
13911 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
13912 return -EINVAL;
13913 }
13914
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013915 if (!pmksa) {
13916 hddLog(LOGE, FL("pmksa is NULL"));
13917 return -EINVAL;
13918 }
13919
13920 if (!pmksa->bssid) {
13921 hddLog(LOGE, FL("pmksa->bssid is NULL"));
13922 return -EINVAL;
13923 }
13924
Kiet Lam98c46a12014-10-31 15:34:57 -070013925 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
13926 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
13927
Wilson Yang6507c4e2013-10-01 20:11:19 -070013928 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13929 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070013930 if (0 != status)
13931 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070013932 return status;
13933 }
13934
13935 /*Retrieve halHandle*/
13936 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13937
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013938 /* Delete the PMKID CSR cache */
13939 if (eHAL_STATUS_SUCCESS !=
13940 sme_RoamDelPMKIDfromCache(halHandle,
13941 pAdapter->sessionId, pmksa->bssid, FALSE)) {
13942 hddLog(LOGE, FL("Failed to delete PMKSA for "MAC_ADDRESS_STR),
13943 MAC_ADDR_ARRAY(pmksa->bssid));
13944 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013945 }
13946
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013947 EXIT();
13948 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013949}
13950
Wilson Yang6507c4e2013-10-01 20:11:19 -070013951
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013952static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
13953 struct cfg80211_pmksa *pmksa)
13954{
13955 int ret;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013956
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053013957 vos_ssr_protect(__func__);
13958 ret = __wlan_hdd_cfg80211_del_pmksa(wiphy, dev, pmksa);
13959 vos_ssr_unprotect(__func__);
13960
13961 return ret;
13962
13963}
13964
13965static int __wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013966{
Wilson Yang6507c4e2013-10-01 20:11:19 -070013967 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
13968 tHalHandle halHandle;
13969 hdd_context_t *pHddCtx;
Wilson Yangef657d32014-01-15 19:19:23 -080013970 int status = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013971
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013972 ENTER();
Wilson Yang6507c4e2013-10-01 20:11:19 -070013973
13974 /* Validate pAdapter */
13975 if (NULL == pAdapter)
13976 {
13977 hddLog(VOS_TRACE_LEVEL_ERROR,
13978 "%s: Invalid Adapter" ,__func__);
13979 return -EINVAL;
13980 }
13981
13982 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
13983 status = wlan_hdd_validate_context(pHddCtx);
Wilson Yang6507c4e2013-10-01 20:11:19 -070013984 if (0 != status)
13985 {
Wilson Yang6507c4e2013-10-01 20:11:19 -070013986 return status;
13987 }
13988
13989 /*Retrieve halHandle*/
13990 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
13991
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053013992 /* Flush the PMKID cache in CSR */
13993 if (eHAL_STATUS_SUCCESS !=
13994 sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, NULL, TRUE)) {
13995 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Cannot flush PMKIDCache"));
13996 status = -EINVAL;
Wilson Yang6507c4e2013-10-01 20:11:19 -070013997 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053013998 EXIT();
Wilson Yangef657d32014-01-15 19:19:23 -080013999 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014000}
Mahesh A Saptasagarf7418d72014-06-02 14:48:54 +053014001
14002static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
14003{
14004 int ret;
14005
14006 vos_ssr_protect(__func__);
14007 ret = __wlan_hdd_cfg80211_flush_pmksa(wiphy, dev);
14008 vos_ssr_unprotect(__func__);
14009
14010 return ret;
14011}
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014012#endif
14013
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014014#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014015static int __wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14016 struct net_device *dev,
14017 struct cfg80211_update_ft_ies_params *ftie)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014018{
14019 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14020 hdd_station_ctx_t *pHddStaCtx;
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014021 hdd_context_t *pHddCtx;
14022 int ret = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014023
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014024 ENTER();
14025
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014026 if (NULL == pAdapter)
14027 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014028 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014029 return -ENODEV;
14030 }
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014031 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14032 ret = wlan_hdd_validate_context(pHddCtx);
14033 if (0 != ret)
14034 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053014035 return ret;
14036 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014037 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014038 if (NULL == pHddStaCtx)
14039 {
14040 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: STA Context is NULL", __func__);
14041 return -EINVAL;
14042 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014043
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014044 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14045 TRACE_CODE_HDD_CFG80211_UPDATE_FT_IES,
14046 pAdapter->sessionId, pHddStaCtx->conn_info.connState));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014047 // Added for debug on reception of Re-assoc Req.
14048 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
14049 {
Arif Hussain6d2a3322013-11-17 19:50:10 -080014050 hddLog(LOGE, FL("Called with Ie of length = %zu when not associated"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014051 ftie->ie_len);
Arif Hussain6d2a3322013-11-17 19:50:10 -080014052 hddLog(LOGE, FL("Should be Re-assoc Req IEs"));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014053 }
14054
14055#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Arif Hussain6d2a3322013-11-17 19:50:10 -080014056 hddLog(LOGE, FL("%s called with Ie of length = %zu"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014057 ftie->ie_len);
14058#endif
14059
14060 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +053014061 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
14062 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014063 ftie->ie_len);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014064
14065 EXIT();
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014066 return 0;
14067}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053014068
14069static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
14070 struct net_device *dev,
14071 struct cfg80211_update_ft_ies_params *ftie)
14072{
14073 int ret;
14074
14075 vos_ssr_protect(__func__);
14076 ret = __wlan_hdd_cfg80211_update_ft_ies(wiphy, dev, ftie);
14077 vos_ssr_unprotect(__func__);
14078
14079 return ret;
14080}
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070014081#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070014082
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014083#ifdef FEATURE_WLAN_SCAN_PNO
14084
14085void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
14086 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
14087{
14088 int ret;
14089 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
14090 hdd_context_t *pHddCtx;
14091
Nirav Shah80830bf2013-12-31 16:35:12 +053014092 ENTER();
14093
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014094 if (NULL == pAdapter)
14095 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053014096 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014097 "%s: HDD adapter is Null", __func__);
14098 return ;
14099 }
14100
14101 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14102 if (NULL == pHddCtx)
14103 {
14104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14105 "%s: HDD context is Null!!!", __func__);
14106 return ;
14107 }
14108
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014109 spin_lock(&pHddCtx->schedScan_lock);
14110 if (TRUE == pHddCtx->isWiphySuspended)
14111 {
14112 pHddCtx->isSchedScanUpdatePending = TRUE;
14113 spin_unlock(&pHddCtx->schedScan_lock);
14114 hddLog(VOS_TRACE_LEVEL_INFO,
14115 "%s: Update cfg80211 scan database after it resume", __func__);
14116 return ;
14117 }
14118 spin_unlock(&pHddCtx->schedScan_lock);
14119
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014120 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
14121
14122 if (0 > ret)
14123 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
14124
14125 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14127 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014128}
14129
14130/*
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014131 * FUNCTION: wlan_hdd_is_pno_allowed
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014132 * Disallow pno if any session is active
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014133 */
14134static eHalStatus wlan_hdd_is_pno_allowed(hdd_adapter_t *pAdapter)
14135{
14136 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
14137 hdd_adapter_t *pTempAdapter = NULL;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014138 hdd_station_ctx_t *pStaCtx;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014139 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14140 int status = 0;
14141 status = hdd_get_front_adapter(pHddCtx, &pAdapterNode);
14142
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014143 /* The current firmware design does not allow PNO during any
14144 * active sessions. Hence, determine the active sessions
14145 * and return a failure.
14146 */
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014147 while ((NULL != pAdapterNode) && (VOS_STATUS_SUCCESS == status))
14148 {
14149 pTempAdapter = pAdapterNode->pAdapter;
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014150 pStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pTempAdapter);
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014151
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014152 if (((WLAN_HDD_INFRA_STATION == pTempAdapter->device_mode)
14153 && (eConnectionState_NotConnected != pStaCtx->conn_info.connState))
14154 || (WLAN_HDD_P2P_CLIENT == pTempAdapter->device_mode)
14155 || (WLAN_HDD_P2P_GO == pTempAdapter->device_mode)
14156 || (WLAN_HDD_SOFTAP == pTempAdapter->device_mode)
Siddharth Bhal63a19a72014-11-07 14:31:56 +053014157 || (WLAN_HDD_TM_LEVEL_4 == pHddCtx->tmInfo.currentTmLevel)
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014158 )
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014159 {
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014160 return eHAL_STATUS_FAILURE;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014161 }
14162 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
14163 pAdapterNode = pNext;
14164 }
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014165 return eHAL_STATUS_SUCCESS;
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014166}
14167
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014168void hdd_cfg80211_sched_scan_start_status_cb(void *callbackContext, VOS_STATUS status)
14169{
14170 hdd_adapter_t *pAdapter = callbackContext;
14171 hdd_context_t *pHddCtx;
14172
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014173 ENTER();
14174
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014175 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
14176 {
14177 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14178 FL("Invalid adapter or adapter has invalid magic"));
14179 return;
14180 }
14181
14182 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
14183 if (0 != wlan_hdd_validate_context(pHddCtx))
14184 {
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014185 return;
14186 }
14187
c_hpothub53c45d2014-08-18 16:53:14 +053014188 if (VOS_STATUS_SUCCESS != status)
14189 {
14190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014191 FL("PNO enable response status = %d"), status);
c_hpothub53c45d2014-08-18 16:53:14 +053014192 pHddCtx->isPnoEnable = FALSE;
14193 }
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014194
14195 pAdapter->pno_req_status = (status == VOS_STATUS_SUCCESS) ? 0 : -EBUSY;
14196 complete(&pAdapter->pno_comp_var);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014197 EXIT();
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014198}
14199
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014200/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014201 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_start
14202 * Function to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014203 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014204static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014205 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14206{
14207 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014208 tSirPNOScanReq pnoRequest = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014209 hdd_context_t *pHddCtx;
14210 tHalHandle hHal;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014211 v_U32_t i, indx, num_ch, tempInterval, j;
Sushant Kaushikd62d9782014-02-19 15:39:40 +053014212 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
14213 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014214 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
14215 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014216 int ret = 0;
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014217 hdd_config_t *pConfig = NULL;
14218 v_U32_t num_ignore_dfs_ch = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014219
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014220 ENTER();
14221
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014222 if (NULL == pAdapter)
14223 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014225 "%s: HDD adapter is Null", __func__);
14226 return -ENODEV;
14227 }
14228
14229 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014230 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014231
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014232 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014233 {
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014234 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014235 }
14236
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014237 pConfig = pHddCtx->cfg_ini;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014238 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14239 if (NULL == hHal)
14240 {
14241 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14242 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014243 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014244 }
Sushant Kaushik2fe89932014-09-03 10:58:09 +053014245 sme_ScanFlushResult(hHal, pAdapter->sessionId);
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014246 ret = wlan_hdd_scan_abort(pAdapter);
Girish Gowli4bf7a632014-06-12 13:42:11 +053014247 if (ret < 0)
Mahesh A Saptasagar2395ee62014-05-21 19:12:21 +053014248 {
14249 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14250 "%s: aborting the existing scan is unsuccessfull", __func__);
14251 return -EBUSY;
14252 }
14253
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014254 if (eHAL_STATUS_SUCCESS != wlan_hdd_is_pno_allowed(pAdapter))
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014255 {
Vinay Krishna Erannacbf75f42014-02-26 17:35:20 +053014256 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Vinay Krishna Eranna23ffd182013-12-26 19:16:55 +053014257 FL("Cannot handle sched_scan"));
Mahesh A Saptasagar0f7b0372013-11-28 23:23:07 +053014258 return -EBUSY;
14259 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014260
c_hpothu37f21312014-04-09 21:49:54 +053014261 if (TRUE == pHddCtx->isPnoEnable)
14262 {
14263 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
14264 FL("already PNO is enabled"));
14265 return -EBUSY;
14266 }
c_hpothu225aa7c2014-10-22 17:45:13 +053014267
14268 if (VOS_STATUS_SUCCESS != wlan_hdd_cancel_remain_on_channel(pHddCtx))
14269 {
14270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14271 "%s: abort ROC failed ", __func__);
14272 return -EBUSY;
14273 }
14274
c_hpothu37f21312014-04-09 21:49:54 +053014275 pHddCtx->isPnoEnable = TRUE;
14276
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014277 pnoRequest.enable = 1; /*Enable PNO */
14278 pnoRequest.ucNetworksCount = request->n_match_sets;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014279
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014280 if (( !pnoRequest.ucNetworksCount ) ||
14281 ( pnoRequest.ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014282 {
14283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014284 "%s: Network input is not correct %d Max Network supported is %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014285 __func__, pnoRequest.ucNetworksCount,
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014286 SIR_PNO_MAX_SUPP_NETWORKS);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014287 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014288 goto error;
14289 }
14290
14291 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
14292 {
14293 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014294 "%s: Incorrect number of channels %d",
14295 __func__, request->n_channels);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014296 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014297 goto error;
14298 }
14299
14300 /* Framework provides one set of channels(all)
14301 * common for all saved profile */
14302 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
14303 channels_allowed, &num_channels_allowed))
14304 {
14305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14306 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014307 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014308 goto error;
14309 }
14310 /* Checking each channel against allowed channel list */
14311 num_ch = 0;
Nirav Shah80830bf2013-12-31 16:35:12 +053014312 if (request->n_channels)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014313 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014314 char chList [(request->n_channels*5)+1];
14315 int len;
14316 for (i = 0, len = 0; i < request->n_channels; i++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014317 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014318 for (indx = 0; indx < num_channels_allowed; indx++)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014319 {
Nirav Shah80830bf2013-12-31 16:35:12 +053014320 if (request->channels[i]->hw_value == channels_allowed[indx])
14321 {
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014322 if ((!pConfig->enableDFSPnoChnlScan) &&
14323 (NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(channels_allowed[indx])))
14324 {
14325 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14326 "%s : Dropping DFS channel : %d",
14327 __func__,channels_allowed[indx]);
14328 num_ignore_dfs_ch++;
14329 break;
14330 }
14331
Nirav Shah80830bf2013-12-31 16:35:12 +053014332 valid_ch[num_ch++] = request->channels[i]->hw_value;
14333 len += snprintf(chList+len, 5, "%d ",
14334 request->channels[i]->hw_value);
14335 break ;
14336 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014337 }
14338 }
Nirav Shah80830bf2013-12-31 16:35:12 +053014339 hddLog(VOS_TRACE_LEVEL_INFO,"Channel-List: %s ", chList);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014340
Sachin Ahuja697ba3f2014-11-12 18:57:11 +053014341 /*If all channels are DFS and dropped, then ignore the PNO request*/
14342 if (num_ignore_dfs_ch == request->n_channels)
14343 {
14344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14345 "%s : All requested channels are DFS channels", __func__);
14346 ret = -EINVAL;
14347 goto error;
14348 }
14349 }
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014350
14351 pnoRequest.aNetworks =
14352 vos_mem_malloc(sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14353 if (pnoRequest.aNetworks == NULL)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014354 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014355 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14356 FL("failed to allocate memory aNetworks %u"),
14357 (uint32)sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14358 goto error;
14359 }
14360 vos_mem_zero(pnoRequest.aNetworks,
14361 sizeof(tSirNetworkType)*pnoRequest.ucNetworksCount);
14362
14363 /* Filling per profile params */
14364 for (i = 0; i < pnoRequest.ucNetworksCount; i++)
14365 {
14366 pnoRequest.aNetworks[i].ssId.length =
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014367 request->match_sets[i].ssid.ssid_len;
14368
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014369 if (( 0 == pnoRequest.aNetworks[i].ssId.length ) ||
14370 ( pnoRequest.aNetworks[i].ssId.length > 32 ) )
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014371 {
14372 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014373 "%s: SSID Len %d is not correct for network %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014374 __func__, pnoRequest.aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014375 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014376 goto error;
14377 }
14378
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014379 memcpy(pnoRequest.aNetworks[i].ssId.ssId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014380 request->match_sets[i].ssid.ssid,
14381 request->match_sets[i].ssid.ssid_len);
Sushant Kaushik1e406c32014-05-09 15:57:52 +053014382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14383 "%s: SSID of network %d is %s ", __func__,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014384 i, pnoRequest.aNetworks[i].ssId.ssId);
14385 pnoRequest.aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
14386 pnoRequest.aNetworks[i].encryption = 0; /*eED_ANY*/
14387 pnoRequest.aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014388
14389 /*Copying list of valid channel into request */
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014390 memcpy(pnoRequest.aNetworks[i].aChannels, valid_ch, num_ch);
14391 pnoRequest.aNetworks[i].ucChannelCount = num_ch;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014392
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014393 pnoRequest.aNetworks[i].rssiThreshold = 0; //Default value
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014394 }
14395
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014396 for (i = 0; i < request->n_ssids; i++)
14397 {
14398 j = 0;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014399 while (j < pnoRequest.ucNetworksCount)
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014400 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014401 if ((pnoRequest.aNetworks[j].ssId.length ==
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014402 request->ssids[i].ssid_len) &&
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014403 (0 == memcmp(pnoRequest.aNetworks[j].ssId.ssId,
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014404 request->ssids[i].ssid,
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014405 pnoRequest.aNetworks[j].ssId.length)))
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014406 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014407 pnoRequest.aNetworks[j].bcastNetwType = eBCAST_HIDDEN;
Mahesh A Saptasagar7bd6ad42014-07-21 18:56:33 +053014408 break;
14409 }
14410 j++;
14411 }
14412 }
14413 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14414 "Number of hidden networks being Configured = %d",
14415 request->n_ssids);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnson59a121e2013-11-30 09:46:08 -080014417 "request->ie_len = %zu", request->ie_len);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014418
14419 pnoRequest.p24GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14420 if (pnoRequest.p24GProbeTemplate == NULL)
14421 {
14422 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14423 FL("failed to allocate memory p24GProbeTemplate %u"),
14424 SIR_PNO_MAX_PB_REQ_SIZE);
14425 goto error;
14426 }
14427
14428 pnoRequest.p5GProbeTemplate = vos_mem_malloc(SIR_PNO_MAX_PB_REQ_SIZE);
14429 if (pnoRequest.p5GProbeTemplate == NULL)
14430 {
14431 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
14432 FL("failed to allocate memory p5GProbeTemplate %u"),
14433 SIR_PNO_MAX_PB_REQ_SIZE);
14434 goto error;
14435 }
14436
14437 vos_mem_zero(pnoRequest.p24GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14438 vos_mem_zero(pnoRequest.p5GProbeTemplate, SIR_PNO_MAX_PB_REQ_SIZE);
14439
Hanumantha Reddy Pothula06e87b22015-03-02 18:02:23 +053014440 if ((0 < request->ie_len) && (request->ie_len <= SIR_PNO_MAX_PB_REQ_SIZE) &&
14441 (NULL != request->ie))
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014442 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014443 pnoRequest.us24GProbeTemplateLen = request->ie_len;
14444 memcpy(pnoRequest.p24GProbeTemplate, request->ie,
14445 pnoRequest.us24GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014446
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014447 pnoRequest.us5GProbeTemplateLen = request->ie_len;
14448 memcpy(pnoRequest.p5GProbeTemplate, request->ie,
14449 pnoRequest.us5GProbeTemplateLen);
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +053014450 }
14451
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014452 /* Driver gets only one time interval which is hardcoded in
14453 * supplicant for 10000ms. Taking power consumption into account 6 timers
14454 * will be used, Timervalue is increased exponentially i.e 10,20,40,
14455 * 80,160,320 secs. And number of scan cycle for each timer
14456 * is configurable through INI param gPNOScanTimerRepeatValue.
14457 * If it is set to 0 only one timer will be used and PNO scan cycle
14458 * will be repeated after each interval specified by supplicant
14459 * till PNO is disabled.
14460 */
14461 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014462 pnoRequest.scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014463 else
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014464 pnoRequest.scanTimers.ucScanTimersCount =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014465 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
14466
14467 tempInterval = (request->interval)/1000;
14468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14469 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
14470 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014471 for ( i = 0; i < pnoRequest.scanTimers.ucScanTimersCount; i++)
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014472 {
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014473 pnoRequest.scanTimers.aTimerValues[i].uTimerRepeat =
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014474 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014475 pnoRequest.scanTimers.aTimerValues[i].uTimerValue = tempInterval;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014476 tempInterval *= 2;
14477 }
14478 //Repeat last timer until pno disabled.
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014479 pnoRequest.scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +053014480
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014481 pnoRequest.modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014482
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014483 INIT_COMPLETION(pAdapter->pno_comp_var);
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014484 pnoRequest.statusCallback = hdd_cfg80211_sched_scan_start_status_cb;
14485 pnoRequest.callbackContext = pAdapter;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014486 pAdapter->pno_req_status = 0;
14487
Nirav Shah80830bf2013-12-31 16:35:12 +053014488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14489 "SessionId %d, enable %d, modePNO %d, ucScanTimersCount %d",
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014490 pAdapter->sessionId, pnoRequest.enable, pnoRequest.modePNO,
14491 pnoRequest.scanTimers.ucScanTimersCount);
Nirav Shah80830bf2013-12-31 16:35:12 +053014492
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014493 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014494 &pnoRequest, pAdapter->sessionId,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014495 hdd_cfg80211_sched_scan_done_callback, pAdapter);
14496 if (eHAL_STATUS_SUCCESS != status)
14497 {
14498 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Nirav Shah80830bf2013-12-31 16:35:12 +053014499 "%s: Failed to enable PNO", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014500 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014501 goto error;
14502 }
14503
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014504 ret = wait_for_completion_timeout(
14505 &pAdapter->pno_comp_var,
14506 msecs_to_jiffies(WLAN_WAIT_TIME_PNO));
14507 if (0 >= ret)
14508 {
14509 // Did not receive the response for PNO enable in time.
14510 // Assuming the PNO enable was success.
14511 // Returning error from here, because we timeout, results
14512 // in side effect of Wifi (Wifi Setting) not to work.
14513 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14514 FL("Timed out waiting for PNO to be Enabled"));
14515 ret = 0;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014516 }
14517
14518 ret = pAdapter->pno_req_status;
c_hpothu37f21312014-04-09 21:49:54 +053014519 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014520
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014521error:
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14523 FL("PNO scanRequest offloaded ret = %d"), ret);
c_hpothu37f21312014-04-09 21:49:54 +053014524 pHddCtx->isPnoEnable = FALSE;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014525 if (pnoRequest.aNetworks)
14526 vos_mem_free(pnoRequest.aNetworks);
14527 if (pnoRequest.p24GProbeTemplate)
14528 vos_mem_free(pnoRequest.p24GProbeTemplate);
14529 if (pnoRequest.p5GProbeTemplate)
14530 vos_mem_free(pnoRequest.p5GProbeTemplate);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053014531
14532 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014533 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014534}
14535
14536/*
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014537 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
14538 * NL interface to enable PNO
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014539 */
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014540static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
14541 struct net_device *dev, struct cfg80211_sched_scan_request *request)
14542{
14543 int ret;
14544
14545 vos_ssr_protect(__func__);
14546 ret = __wlan_hdd_cfg80211_sched_scan_start(wiphy, dev, request);
14547 vos_ssr_unprotect(__func__);
14548
14549 return ret;
14550}
14551
14552/*
14553 * FUNCTION: __wlan_hdd_cfg80211_sched_scan_stop
14554 * Function to disable PNO
14555 */
14556static int __wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014557 struct net_device *dev)
14558{
14559 eHalStatus status = eHAL_STATUS_FAILURE;
14560 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14561 hdd_context_t *pHddCtx;
14562 tHalHandle hHal;
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014563 tSirPNOScanReq pnoRequest = {0};
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014564 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014565
14566 ENTER();
14567
14568 if (NULL == pAdapter)
14569 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014570 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014571 "%s: HDD adapter is Null", __func__);
14572 return -ENODEV;
14573 }
14574
14575 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014576
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014577 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014578 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053014579 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014580 "%s: HDD context is Null", __func__);
14581 return -ENODEV;
14582 }
14583
14584 /* The return 0 is intentional when isLogpInProgress and
14585 * isLoadUnloadInProgress. We did observe a crash due to a return of
14586 * failure in sched_scan_stop , especially for a case where the unload
14587 * of the happens at the same time. The function __cfg80211_stop_sched_scan
14588 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
14589 * success. If it returns a failure , then its next invocation due to the
14590 * clean up of the second interface will have the dev pointer corresponding
14591 * to the first one leading to a crash.
14592 */
14593 if (pHddCtx->isLogpInProgress)
14594 {
14595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14596 "%s: LOGP in Progress. Ignore!!!", __func__);
14597 return ret;
14598 }
14599
Mihir Shete18156292014-03-11 15:38:30 +053014600 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014601 {
14602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14603 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14604 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014605 }
14606
14607 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
14608 if (NULL == hHal)
14609 {
14610 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14611 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014612 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014613 }
14614
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014615 pnoRequest.enable = 0; /* Disable PNO */
14616 pnoRequest.ucNetworksCount = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014617
Hanumantha Reddy Pothulad769f3e2015-02-19 17:00:02 +053014618 status = sme_SetPreferredNetworkList(hHal, &pnoRequest,
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014619 pAdapter->sessionId,
14620 NULL, pAdapter);
14621 if (eHAL_STATUS_SUCCESS != status)
14622 {
14623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14624 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014625 ret = -EINVAL;
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014626 goto error;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014627 }
c_hpothu37f21312014-04-09 21:49:54 +053014628 pHddCtx->isPnoEnable = FALSE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014629
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014630error:
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053014631 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Vinay Krishna Erannaf0e523b2014-03-01 21:00:16 +053014632 FL("PNO scan disabled ret = %d"), ret);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014633
14634 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +053014635 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014636}
14637
Mahesh A Saptasagar6cc38562014-05-23 21:22:17 +053014638/*
14639 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
14640 * NL interface to disable PNO
14641 */
14642static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
14643 struct net_device *dev)
14644{
14645 int ret;
14646
14647 vos_ssr_protect(__func__);
14648 ret = __wlan_hdd_cfg80211_sched_scan_stop(wiphy, dev);
14649 vos_ssr_unprotect(__func__);
14650
14651 return ret;
14652}
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053014653#endif /*FEATURE_WLAN_SCAN_PNO*/
14654
14655
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014656#ifdef FEATURE_WLAN_TDLS
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014657#if TDLS_MGMT_VERSION2
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014658static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014659 u8 *peer, u8 action_code, u8 dialog_token,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014660 u16 status_code, u32 peer_capability, const u8 *buf, size_t len)
14661#else
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014662static int __wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014663 u8 *peer, u8 action_code, u8 dialog_token,
14664 u16 status_code, const u8 *buf, size_t len)
14665#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014666{
14667
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014668 hdd_adapter_t *pAdapter;
14669 hdd_context_t *pHddCtx;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014670 u8 peerMac[6];
14671 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -070014672 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -080014673 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -070014674 long rc;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014675 int ret;
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053014676#if !(TDLS_MGMT_VERSION2)
14677 u32 peer_capability = 0;
14678#endif
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014679 tANI_U16 numCurrTdlsPeers;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053014680
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014681 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
14682 if (NULL == pAdapter)
14683 {
14684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14685 "%s: Adapter is NULL",__func__);
14686 return -EINVAL;
14687 }
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053014688 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
14689 TRACE_CODE_HDD_CFG80211_TDLS_MGMT,
14690 pAdapter->sessionId, action_code));
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014691 pHddCtx = wiphy_priv(wiphy);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014692 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014693 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +053014694 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014695 "Invalid arguments");
14696 return -EINVAL;
14697 }
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014698 if (pHddCtx->isLogpInProgress)
14699 {
14700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14701 "%s:LOGP in Progress. Ignore!!!", __func__);
Atul Mittal115287b2014-07-08 13:26:33 +053014702 wlan_hdd_tdls_set_link_status(pAdapter,
14703 peer,
14704 eTDLS_LINK_IDLE,
14705 eTDLS_LINK_UNSPECIFIED);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080014706 return -EBUSY;
14707 }
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053014708 if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx))
14709 {
14710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14711 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
14712 return -EAGAIN;
14713 }
Hoonki Lee27511902013-03-14 18:19:06 -070014714 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014715 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014716 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014717 "%s: TDLS mode is disabled OR not enabled in FW."
14718 MAC_ADDRESS_STR " action %d declined.",
14719 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014720 return -ENOTSUPP;
14721 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014722
Hoonki Lee27511902013-03-14 18:19:06 -070014723 /* other than teardown frame, other mgmt frames are not sent if disabled */
14724 if (SIR_MAC_TDLS_TEARDOWN != action_code)
14725 {
14726 /* if tdls_mode is disabled to respond to peer's request */
14727 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
14728 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014729 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Hoonki Lee27511902013-03-14 18:19:06 -070014730 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014731 " TDLS mode is disabled. action %d declined.",
14732 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -070014733
14734 return -ENOTSUPP;
14735 }
Agarwal Ashish4b87f922014-06-18 03:03:21 +053014736
14737 if (vos_max_concurrent_connections_reached())
14738 {
14739 hddLog(VOS_TRACE_LEVEL_INFO, FL("Reached max concurrent connections"));
14740 return -EINVAL;
14741 }
Hoonki Lee27511902013-03-14 18:19:06 -070014742 }
14743
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014744 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
14745 {
Pradeep Reddy POTTETI9db32f02015-01-29 15:22:54 +053014746 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014747 {
14748 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014749 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014750 " TDLS setup is ongoing. action %d declined.",
14751 __func__, MAC_ADDR_ARRAY(peer), action_code);
14752 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014753 }
14754 }
14755
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014756 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
14757 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -080014758 {
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014759 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
14760 if (HDD_MAX_NUM_TDLS_STA <= numCurrTdlsPeers)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014761 {
14762 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
14763 we return error code at 'add_station()'. Hence we have this
14764 check again in addtion to add_station().
14765 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014766 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -080014767 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014768 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14769 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014770 " TDLS Max peer already connected. action (%d) declined. Num of peers (%d), Max allowed (%d).",
14771 __func__, MAC_ADDR_ARRAY(peer), action_code,
14772 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Sunil Dutt388ac8f2013-11-28 18:06:52 +053014773 return -EINVAL;
Lee Hoonkic1262f22013-01-24 21:59:00 -080014774 }
14775 else
14776 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014777 /* maximum reached. tweak to send error code to peer and return
14778 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014779 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014780 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14781 "%s: " MAC_ADDRESS_STR
Rajesh Chauhana34c6e62014-03-25 16:37:58 +053014782 " TDLS Max peer already connected, send response status (%d). Num of peers (%d), Max allowed (%d).",
14783 __func__, MAC_ADDR_ARRAY(peer), status_code,
14784 numCurrTdlsPeers, HDD_MAX_NUM_TDLS_STA);
Gopichand Nakkala05922802013-03-14 12:23:19 -070014785 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014786 /* fall through to send setup resp with failure status
14787 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -080014788 }
14789 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014790 else
14791 {
14792 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014793 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070014794 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014795 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014796 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -070014797 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
14798 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014799 return -EPERM;
14800 }
14801 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080014802 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014803 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014804
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014805 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014806 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %zu",
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070014807 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
14808 action_code, dialog_token, status_code, len);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014809
Hoonki Leea34dd892013-02-05 22:56:02 -080014810 /*Except teardown responder will not be used so just make 0*/
14811 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -080014812 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -080014813 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014814
14815 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +053014816 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014817
14818 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
14819 responder = pTdlsPeer->is_responder;
14820 else
Hoonki Leea34dd892013-02-05 22:56:02 -080014821 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -070014822 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arun Kumar Khandavalli9fb625e2014-03-17 16:07:40 +053014823 "%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 -070014824 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
14825 dialog_token, status_code, len);
14826 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -080014827 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014828 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014829
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014830 /* For explicit trigger of DIS_REQ come out of BMPS for
14831 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -070014832 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014833 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
14834 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -070014835 {
14836 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
14837 {
Masti, Narayanraddi34e0e562015-03-05 18:23:03 +053014838 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +053014839 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014840 status = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
14841 if (status != VOS_STATUS_SUCCESS) {
14842 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set BMPS/IMPS"));
14843 }
Hoonki Lee14621352013-04-16 17:51:19 -070014844 }
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014845 if (SIR_MAC_TDLS_DIS_REQ != action_code) {
14846 if (0 != wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED)) {
14847 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS capabilities"));
14848 }
14849 }
Hoonki Lee14621352013-04-16 17:51:19 -070014850 }
14851
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014852 /* make sure doesn't call send_mgmt() while it is pending */
14853 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
14854 {
14855 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -080014856 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY",
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014857 __func__, MAC_ADDR_ARRAY(peer), action_code);
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014858 ret = -EBUSY;
14859 goto tx_failed;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014860 }
14861
14862 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014863 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
14864
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014865 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Pradeep Reddy POTTETIca171f82014-03-21 14:17:35 +053014866 peerMac, action_code, dialog_token, status_code, peer_capability, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014867
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014868 if (VOS_STATUS_SUCCESS != status)
14869 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14871 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014872 pAdapter->mgmtTxCompletionStatus = FALSE;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014873 ret = -EINVAL;
14874 goto tx_failed;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014875 }
14876
Hoonki Leed37cbb32013-04-20 00:31:14 -070014877 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
14878 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
14879
14880 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014881 {
Hoonki Leed37cbb32013-04-20 00:31:14 -070014882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -070014883 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -070014884 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -070014885 pAdapter->mgmtTxCompletionStatus = FALSE;
Yue Ma4f55ef32014-01-23 16:45:33 -080014886
14887 if (pHddCtx->isLogpInProgress)
14888 {
14889 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14890 "%s: LOGP in Progress. Ignore!!!", __func__);
14891 return -EAGAIN;
14892 }
14893
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014894 ret = -EINVAL;
14895 goto tx_failed;
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014896 }
14897
Gopichand Nakkala05922802013-03-14 12:23:19 -070014898 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -070014899 {
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014900 ret = max_sta_failed;
14901 goto tx_failed;
Hoonki Lee14621352013-04-16 17:51:19 -070014902 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -080014903
Hoonki Leea34dd892013-02-05 22:56:02 -080014904 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
14905 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014906 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE)) {
14907 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
14908 }
Hoonki Leea34dd892013-02-05 22:56:02 -080014909 }
14910 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
14911 {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014912 if (0 != wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE)) {
14913 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set TDLS responder: Setup Response"));
14914 }
Hoonki Leea34dd892013-02-05 22:56:02 -080014915 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014916
14917 return 0;
Ganesh Kondabattini862aec92015-01-22 20:58:46 +053014918
14919tx_failed:
14920 /* add_station will be called before sending TDLS_SETUP_REQ and
14921 * TDLS_SETUP_RSP and as part of add_station driver will enable
14922 * BMPS. NL80211_TDLS_DISABLE_LINK will be called if the tx of
14923 * TDLS_SETUP_REQ or TDLS_SETUP_RSP fails. BMPS will be enabled
14924 * as part of processing NL80211_TDLS_DISABLE_LINK. So need to
14925 * enable BMPS for TDLS_SETUP_REQ and TDLS_SETUP_RSP if tx fails.
14926 */
14927
14928 if ((SIR_MAC_TDLS_SETUP_REQ == action_code) ||
14929 (SIR_MAC_TDLS_SETUP_RSP == action_code))
14930 wlan_hdd_tdls_check_bmps(pAdapter);
14931 return ret;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080014932}
14933
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053014934#if TDLS_MGMT_VERSION2
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, u32 peer_capability,
14938 const u8 *buf, size_t len)
14939#else
14940static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
14941 u8 *peer, u8 action_code, u8 dialog_token,
14942 u16 status_code, const u8 *buf, size_t len)
14943#endif
14944{
14945 int ret;
14946
14947 vos_ssr_protect(__func__);
14948#if TDLS_MGMT_VERSION2
14949 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
14950 status_code, peer_capability, buf, len);
14951#else
14952 ret = __wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer, action_code, dialog_token,
14953 status_code, buf, len);
14954#endif
14955 vos_ssr_unprotect(__func__);
14956
14957 return ret;
14958}
Atul Mittal115287b2014-07-08 13:26:33 +053014959
14960int wlan_hdd_tdls_extctrl_config_peer(hdd_adapter_t *pAdapter,
14961 u8 *peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053014962 tdls_req_params_t *tdls_peer_params,
Atul Mittal115287b2014-07-08 13:26:33 +053014963 cfg80211_exttdls_callback callback)
14964{
14965
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053014966 hddTdlsPeer_t *pTdlsPeer = NULL;
Atul Mittal115287b2014-07-08 13:26:33 +053014967 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053014968 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Atul Mittal115287b2014-07-08 13:26:33 +053014969 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
14970 " %s : NL80211_TDLS_SETUP for " MAC_ADDRESS_STR,
14971 __func__, MAC_ADDR_ARRAY(peer));
14972
14973 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
14974 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
14975
14976 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053014977 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
14978 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
14979 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053014980 return -ENOTSUPP;
14981 }
14982
14983 /* To cater the requirement of establishing the TDLS link
14984 * irrespective of the data traffic , get an entry of TDLS peer.
14985 */
14986 pTdlsPeer = wlan_hdd_tdls_get_peer(pAdapter, peer);
14987 if (pTdlsPeer == NULL) {
14988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
14989 "%s: peer " MAC_ADDRESS_STR " not existing",
14990 __func__, MAC_ADDR_ARRAY(peer));
14991 return -EINVAL;
14992 }
14993
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053014994 /* check FW TDLS Off Channel capability */
14995 if ((TRUE == sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL)) &&
14996 (NULL != tdls_peer_params))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053014997 {
14998 pTdlsPeer->peerParams.channel = tdls_peer_params->channel;
14999 pTdlsPeer->peerParams.global_operating_class =
15000 tdls_peer_params->global_operating_class;
15001 pTdlsPeer->peerParams.max_latency_ms = tdls_peer_params->max_latency_ms;
15002 pTdlsPeer->peerParams.min_bandwidth_kbps =
15003 tdls_peer_params->min_bandwidth_kbps;
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015004 /* check configured channel is valid, non dfs and
15005 * not current operating channel */
15006 if ((sme_IsTdlsOffChannelValid(WLAN_HDD_GET_HAL_CTX(pAdapter),
15007 tdls_peer_params->channel)) &&
15008 (pHddStaCtx) &&
15009 (tdls_peer_params->channel !=
15010 pHddStaCtx->conn_info.operationChannel))
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015011 {
15012 pTdlsPeer->isOffChannelConfigured = TRUE;
15013 }
15014 else
15015 {
15016 pTdlsPeer->isOffChannelConfigured = FALSE;
15017 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15018 "%s: Configured Tdls Off Channel is not valid", __func__);
15019
15020 }
15021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015022 "%s: tdls_off_channel %d isOffChannelConfigured %d "
15023 "current operating channel %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015024 __func__, pTdlsPeer->peerParams.channel,
Pradeep Reddy POTTETIe30ed252015-02-18 14:27:55 +053015025 pTdlsPeer->isOffChannelConfigured,
15026 (pHddStaCtx ? pHddStaCtx->conn_info.operationChannel : 0));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015027 }
15028 else
15029 {
15030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pradeep Reddy POTTETI60ad2402015-02-26 16:48:21 +053015031 "%s: TDLS off channel FW capability %d or "
15032 "Invalid TDLS Peer Params", __func__,
15033 sme_IsFeatureSupportedByFW(TDLS_OFF_CHANNEL));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015034 }
15035
Atul Mittal115287b2014-07-08 13:26:33 +053015036 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, TRUE) ) {
15037
15038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15039 " %s TDLS Add Force Peer Failed",
15040 __func__);
15041 return -EINVAL;
15042 }
15043 /*EXT TDLS*/
15044
15045 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, callback) ) {
15046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15047 " %s TDLS set callback Failed",
15048 __func__);
15049 return -EINVAL;
15050 }
15051
15052 return(0);
15053
15054}
15055
15056int wlan_hdd_tdls_extctrl_deconfig_peer(hdd_adapter_t *pAdapter, u8 *peer)
15057{
15058
15059 hddTdlsPeer_t *pTdlsPeer;
15060 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15061 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15062 " %s : NL80211_TDLS_TEARDOWN for " MAC_ADDRESS_STR,
15063 __func__, MAC_ADDR_ARRAY(peer));
15064
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015065 if (0 != wlan_hdd_validate_context(pHddCtx)) {
15066 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD context is NULL"));
15067 return -EINVAL;
15068 }
15069
Atul Mittal115287b2014-07-08 13:26:33 +053015070 if ( (FALSE == pHddCtx->cfg_ini->fTDLSExternalControl) ||
15071 (FALSE == pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger) ) {
15072
15073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015074 " %s TDLS External control (%d) and Implicit Trigger (%d) not enabled ",
15075 __func__, pHddCtx->cfg_ini->fTDLSExternalControl,
15076 pHddCtx->cfg_ini->fEnableTDLSImplicitTrigger);
Atul Mittal115287b2014-07-08 13:26:33 +053015077 return -ENOTSUPP;
15078 }
15079
15080
15081 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15082
15083 if ( NULL == pTdlsPeer ) {
15084 hddLog(VOS_TRACE_LEVEL_INFO, "%s: " MAC_ADDRESS_STR
15085 " peer not exsting",
15086 __func__, MAC_ADDR_ARRAY(peer));
15087 return -EINVAL;
15088 }
15089 else {
15090 wlan_hdd_tdls_indicate_teardown(pAdapter, pTdlsPeer,
15091 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015092 /* if channel switch is configured, reset
15093 the channel for this peer */
15094 if (TRUE == pTdlsPeer->isOffChannelConfigured)
15095 {
15096 pTdlsPeer->peerParams.channel = 0;
15097 pTdlsPeer->isOffChannelConfigured = FALSE;
15098 }
Atul Mittal115287b2014-07-08 13:26:33 +053015099 }
15100
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015101 if ( 0 != wlan_hdd_tdls_set_force_peer(pAdapter, peer, FALSE) ) {
15102 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to set force peer"));
Atul Mittal115287b2014-07-08 13:26:33 +053015103 return -EINVAL;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015104 }
Atul Mittal115287b2014-07-08 13:26:33 +053015105
15106 /*EXT TDLS*/
15107
15108 if ( 0 != wlan_hdd_set_callback(pTdlsPeer, NULL )) {
15109
15110 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15111 " %s TDLS set callback Failed",
15112 __func__);
15113 return -EINVAL;
15114 }
15115 return(0);
15116
15117}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015118static int __wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015119 u8 *peer, enum nl80211_tdls_operation oper)
15120{
15121 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15122 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015123 int status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015124 hddTdlsPeer_t *pTdlsPeer;
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015125
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015126 ENTER();
15127
Chandrasekaran, Manishekar41b8e1f2015-03-10 13:30:28 +053015128 if (!pAdapter) {
15129 hddLog(VOS_TRACE_LEVEL_ERROR, FL("HDD adpater is NULL"));
15130 return -EINVAL;
15131 }
15132
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015133 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15134 TRACE_CODE_HDD_CFG80211_TDLS_OPER,
15135 pAdapter->sessionId, oper));
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015136 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015137 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -080015138 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -070015139 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015140 return -EINVAL;
15141 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015142
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015143 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015144 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015145 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015146 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -080015147 }
15148
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015149
15150 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015151 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015152 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -080015153 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015154 "TDLS Disabled in INI (%d) OR not enabled in FW (%d) "
15155 "Cannot process TDLS commands",
15156 pHddCtx->cfg_ini->fEnableTDLSSupport,
15157 sme_IsFeatureSupportedByFW(TDLS));
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015158 return -ENOTSUPP;
15159 }
15160
15161 switch (oper) {
15162 case NL80211_TDLS_ENABLE_LINK:
15163 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015164 VOS_STATUS status;
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015165 long ret;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015166 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Agarwal Ashish16020c42014-12-29 22:01:11 +053015167 WLAN_STADescType staDesc;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015168 tANI_U16 numCurrTdlsPeers = 0;
15169 hddTdlsPeer_t *connPeer = NULL;
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015170 tANI_U8 suppChannelLen = 0;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015171
Sunil Dutt41de4e22013-11-14 18:09:02 +053015172 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015173 memset(&staDesc, 0, sizeof(staDesc));
Sunil Dutt41de4e22013-11-14 18:09:02 +053015174 if ( NULL == pTdlsPeer ) {
15175 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15176 " (oper %d) not exsting. ignored",
15177 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15178 return -EINVAL;
15179 }
15180
15181 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15182 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15183 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15184 "NL80211_TDLS_ENABLE_LINK");
15185
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -070015186 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
15187 {
15188 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
15189 MAC_ADDRESS_STR " failed",
15190 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
15191 return -EINVAL;
15192 }
15193
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015194 /* before starting tdls connection, set tdls
15195 * off channel established status to default value */
15196 pTdlsPeer->isOffChannelEstablished = FALSE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015197 /* TDLS Off Channel, Disable tdls channel switch,
15198 when there are more than one tdls link */
15199 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +053015200 if (numCurrTdlsPeers == 2)
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015201 {
15202 /* get connected peer and send disable tdls off chan */
15203 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15204 if (connPeer && (connPeer->isOffChannelConfigured == TRUE))
15205 {
15206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15207 "%s: More then one peer connected, Disable "
15208 "TDLS channel switch", __func__);
15209
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015210 connPeer->isOffChannelEstablished = FALSE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015211 ret = sme_SendTdlsChanSwitchReq(
15212 WLAN_HDD_GET_HAL_CTX(pAdapter),
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015213 pAdapter->sessionId,
15214 connPeer->peerMac,
15215 connPeer->peerParams.channel,
15216 TDLS_OFF_CHANNEL_BW_OFFSET,
15217 TDLS_CHANNEL_SWITCH_DISABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015218 if (ret != VOS_STATUS_SUCCESS) {
15219 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel request"));
15220 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015221 }
15222 else
15223 {
15224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15225 "%s: No TDLS Connected Peer or "
15226 "isOffChannelConfigured %d",
15227 __func__,
15228 (connPeer ? connPeer->isOffChannelConfigured : -1));
15229 }
15230 }
15231
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015232 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015233 {
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015234 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +053015235
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015236 if (0 != wlan_hdd_tdls_get_link_establish_params(
15237 pAdapter, peer,&tdlsLinkEstablishParams)) {
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015238 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to get link establishment params"));
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015239 return -EINVAL;
15240 }
15241 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015242
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015243 ret = sme_SendTdlsLinkEstablishParams(
15244 WLAN_HDD_GET_HAL_CTX(pAdapter),
15245 pAdapter->sessionId, peer,
15246 &tdlsLinkEstablishParams);
15247 if (ret != VOS_STATUS_SUCCESS) {
15248 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send link establishment params"));
15249 }
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053015250 /* Send TDLS peer UAPSD capabilities to the firmware and
15251 * register with the TL on after the response for this operation
15252 * is received .
15253 */
15254 ret = wait_for_completion_interruptible_timeout(
15255 &pAdapter->tdls_link_establish_req_comp,
15256 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
15257 if (ret <= 0)
15258 {
15259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15260 "%s: Link Establish Request Faled Status %ld",
15261 __func__, ret);
15262 return -EINVAL;
15263 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015264 }
Atul Mittal115287b2014-07-08 13:26:33 +053015265 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15266 eTDLS_LINK_CONNECTED,
15267 eTDLS_LINK_SUCCESS);
Agarwal Ashish16020c42014-12-29 22:01:11 +053015268 staDesc.ucSTAId = pTdlsPeer->staId;
15269 staDesc.ucQosEnabled = tdlsLinkEstablishParams.qos;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015270 ret = WLANTL_UpdateTdlsSTAClient(
15271 pHddCtx->pvosContext,
15272 &staDesc);
15273 if (ret != VOS_STATUS_SUCCESS) {
15274 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to update TDLS STA params"));
15275 }
Agarwal Ashish16020c42014-12-29 22:01:11 +053015276
Gopichand Nakkala471708b2013-06-04 20:03:01 +053015277 /* Mark TDLS client Authenticated .*/
15278 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
15279 pTdlsPeer->staId,
15280 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015281 if (VOS_STATUS_SUCCESS == status)
15282 {
Hoonki Lee14621352013-04-16 17:51:19 -070015283 if (pTdlsPeer->is_responder == 0)
15284 {
15285 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
15286
15287 wlan_hdd_tdls_timer_restart(pAdapter,
15288 &pTdlsPeer->initiatorWaitTimeoutTimer,
15289 WAIT_TIME_TDLS_INITIATOR);
15290 /* suspend initiator TX until it receives direct packet from the
15291 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015292 ret = WLANTL_SuspendDataTx(
15293 (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15294 &staId, NULL);
15295 if (ret != VOS_STATUS_SUCCESS) {
15296 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to suspend data tx"));
15297 }
Hoonki Lee14621352013-04-16 17:51:19 -070015298 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015299
Pradeep Reddy POTTETIfcac7902015-04-16 12:25:17 +053015300 suppChannelLen =
15301 tdlsLinkEstablishParams.supportedChannelsLen;
15302 if ((TRUE == pTdlsPeer->isOffChannelSupported) &&
15303 (TRUE == pTdlsPeer->isOffChannelConfigured) &&
15304 (suppChannelLen > 0) &&
15305 (suppChannelLen <= SIR_MAC_MAX_SUPP_CHANNELS))
15306 {
15307 int offChan = pTdlsPeer->peerParams.channel;
15308 int i = 0;
15309 for (i = 0U; i < suppChannelLen; i++)
15310 {
15311 pTdlsPeer->isOffChannelConfigured = FALSE;
15312 if (
15313 (tdlsLinkEstablishParams.supportedChannels[i]
15314 <= offChan) &&
15315 (tdlsLinkEstablishParams.supportedChannels[i]
15316 == offChan))
15317 {
15318 pTdlsPeer->isOffChannelConfigured = TRUE;
15319 break;
15320 }
15321 }
15322 }
15323 else
15324 {
15325 pTdlsPeer->isOffChannelConfigured = FALSE;
15326 }
15327 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15328 "%s: TDLS channel switch request for channel "
15329 "%d isOffChannelConfigured %d suppChannelLen "
15330 "%d", __func__, pTdlsPeer->peerParams.channel,
15331 pTdlsPeer->isOffChannelConfigured,
15332 suppChannelLen);
15333
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015334 /* TDLS Off Channel, Enable tdls channel switch,
15335 when their is only one tdls link and it supports */
15336 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15337 if ((numCurrTdlsPeers == 1) &&
15338 (TRUE == pTdlsPeer->isOffChannelSupported) &&
15339 (TRUE == pTdlsPeer->isOffChannelConfigured))
15340 {
15341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15342 "%s: Send TDLS channel switch request for channel %d",
15343 __func__, pTdlsPeer->peerParams.channel);
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015344
15345 pTdlsPeer->isOffChannelEstablished = TRUE;
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015346 ret = sme_SendTdlsChanSwitchReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
15347 pAdapter->sessionId,
15348 pTdlsPeer->peerMac,
15349 pTdlsPeer->peerParams.channel,
15350 TDLS_OFF_CHANNEL_BW_OFFSET,
15351 TDLS_CHANNEL_SWITCH_ENABLE);
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015352 if (ret != VOS_STATUS_SUCCESS) {
15353 hddLog(VOS_TRACE_LEVEL_ERROR, FL("TDLS offchannel: Failed to send TDLS switch channel req"));
15354 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015355 }
15356 else
15357 {
15358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15359 "%s: TDLS channel switch request not sent"
15360 " numCurrTdlsPeers %d "
15361 "isOffChannelSupported %d "
15362 "isOffChannelConfigured %d",
15363 __func__, numCurrTdlsPeers,
15364 pTdlsPeer->isOffChannelSupported,
15365 pTdlsPeer->isOffChannelConfigured);
15366 }
15367
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -070015368 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015369 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015370
15371 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015372 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
15373 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015374 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015375 int ac;
15376 uint8 ucAc[4] = { WLANTL_AC_VO,
15377 WLANTL_AC_VI,
15378 WLANTL_AC_BK,
15379 WLANTL_AC_BE };
15380 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
15381 for(ac=0; ac < 4; ac++)
15382 {
15383 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
15384 pTdlsPeer->staId, ucAc[ac],
15385 tlTid[ac], tlTid[ac], 0, 0,
15386 WLANTL_BI_DIR );
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015387 if (status != VOS_STATUS_SUCCESS) {
15388 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to enable UAPSD for AC"));
15389 }
Gopichand Nakkala574f6d12013-06-27 19:38:43 +053015390 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053015391 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015392 }
15393
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015394 }
15395 break;
15396 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -080015397 {
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015398 tANI_U16 numCurrTdlsPeers = 0;
15399 hddTdlsPeer_t *connPeer = NULL;
15400
Sunil Dutt41de4e22013-11-14 18:09:02 +053015401 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
15402
15403 if ( NULL == pTdlsPeer ) {
15404 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR
15405 " (oper %d) not exsting. ignored",
15406 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
15407 return -EINVAL;
15408 }
15409
15410 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15411 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
15412 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
15413 "NL80211_TDLS_DISABLE_LINK");
15414
Hoonki Lee5305c3a2013-04-29 23:28:59 -070015415 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -080015416 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015417 long status;
15418
Pradeep Reddy POTTETIf3148e82015-04-16 12:10:33 +053015419 /* set tdls off channel status to false for this peer */
15420 pTdlsPeer->isOffChannelEstablished = FALSE;
Atul Mittal271a7652014-09-12 13:18:22 +053015421 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
15422 eTDLS_LINK_TEARING,
15423 (pTdlsPeer->link_status == eTDLS_LINK_TEARING)?
15424 eTDLS_LINK_UNSPECIFIED:
15425 eTDLS_LINK_DROPPED_BY_REMOTE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015426 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
15427
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015428 status = sme_DeleteTdlsPeerSta(
15429 WLAN_HDD_GET_HAL_CTX(pAdapter),
15430 pAdapter->sessionId, peer );
15431 if (status != VOS_STATUS_SUCCESS) {
15432 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to delete TDLS peer STA"));
15433 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015434
15435 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
15436 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
Atul Mittal271a7652014-09-12 13:18:22 +053015437 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer,
Atul Mittal454664b2014-10-10 11:03:46 +053015438 eTDLS_LINK_IDLE,
15439 eTDLS_LINK_UNSPECIFIED);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015440 if (status <= 0)
15441 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -070015442 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15443 "%s: Del station failed status %ld",
15444 __func__, status);
15445 return -EPERM;
15446 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015447
15448 /* TDLS Off Channel, Enable tdls channel switch,
15449 when their is only one tdls link and it supports */
15450 numCurrTdlsPeers = wlan_hdd_tdlsConnectedPeers(pAdapter);
15451 if (numCurrTdlsPeers == 1)
15452 {
15453 connPeer = wlan_hdd_tdls_get_connected_peer(pAdapter);
15454 if ((connPeer) &&
15455 (connPeer->isOffChannelSupported == TRUE) &&
15456 (connPeer->isOffChannelConfigured == TRUE))
15457 {
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015458 connPeer->isOffChannelEstablished = TRUE;
Chandrasekaran, Manishekar0de84dc2015-03-10 15:12:34 +053015459 status = sme_SendTdlsChanSwitchReq(
15460 WLAN_HDD_GET_HAL_CTX(pAdapter),
15461 pAdapter->sessionId,
15462 connPeer->peerMac,
15463 connPeer->peerParams.channel,
15464 TDLS_OFF_CHANNEL_BW_OFFSET,
15465 TDLS_CHANNEL_SWITCH_ENABLE);
15466 if (status != VOS_STATUS_SUCCESS) {
15467 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to send TDLS switch channel req"));
15468 }
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015469 }
15470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15471 "%s: TDLS channel switch "
15472 "isOffChannelSupported %d "
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015473 "isOffChannelConfigured %d "
15474 "isOffChannelEstablished %d",
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015475 __func__,
15476 (connPeer ? connPeer->isOffChannelSupported : -1),
Pradeep Reddy POTTETI16d83332015-03-26 18:28:13 +053015477 (connPeer ? connPeer->isOffChannelConfigured : -1),
15478 (connPeer ? connPeer->isOffChannelEstablished : -1));
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015479 }
15480 else
15481 {
15482 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15483 "%s: TDLS channel switch request not sent "
15484 "numCurrTdlsPeers %d ",
15485 __func__, numCurrTdlsPeers);
15486 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015487 }
15488 else
15489 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15491 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -080015492 }
Lee Hoonkic1262f22013-01-24 21:59:00 -080015493 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -070015494 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015495 case NL80211_TDLS_TEARDOWN:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015496 {
Atul Mittal115287b2014-07-08 13:26:33 +053015497 status = wlan_hdd_tdls_extctrl_deconfig_peer(pAdapter, peer);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015498
Atul Mittal115287b2014-07-08 13:26:33 +053015499 if (0 != status)
15500 {
15501 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15502 "%s: Error in TDLS Teardown", __func__);
15503 return status;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015504 }
Sunil Dutt41de4e22013-11-14 18:09:02 +053015505 break;
15506 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015507 case NL80211_TDLS_SETUP:
Sunil Dutt41de4e22013-11-14 18:09:02 +053015508 {
Atul Mittal115287b2014-07-08 13:26:33 +053015509 status = wlan_hdd_tdls_extctrl_config_peer(pAdapter,
15510 peer,
Pradeep Reddy POTTETIe309c152015-02-06 13:21:07 +053015511 NULL,
Atul Mittal115287b2014-07-08 13:26:33 +053015512 NULL);
Sunil Dutt41de4e22013-11-14 18:09:02 +053015513
Atul Mittal115287b2014-07-08 13:26:33 +053015514 if (0 != status)
15515 {
15516 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15517 "%s: Error in TDLS Setup", __func__);
15518 return status;
Naresh Jayaram937abdf2013-11-26 19:50:25 +053015519 }
Naresh Jayaramdb4514b2013-11-25 18:08:10 +053015520 break;
Sunil Dutt41de4e22013-11-14 18:09:02 +053015521 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015522 case NL80211_TDLS_DISCOVERY_REQ:
15523 /* We don't support in-driver setup/teardown/discovery */
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015524 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
15525 "%s: We don't support in-driver setup/teardown/discovery "
15526 ,__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015527 return -ENOTSUPP;
15528 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053015529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15530 "%s: unsupported event",__func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015531 return -ENOTSUPP;
15532 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015533
15534 EXIT();
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015535 return 0;
15536}
Chilam NG571c65a2013-01-19 12:27:36 +053015537
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015538static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
15539 u8 *peer, enum nl80211_tdls_operation oper)
15540{
15541 int ret;
15542
15543 vos_ssr_protect(__func__);
15544 ret = __wlan_hdd_cfg80211_tdls_oper(wiphy, dev, peer, oper);
15545 vos_ssr_unprotect(__func__);
15546
15547 return ret;
15548}
15549
Chilam NG571c65a2013-01-19 12:27:36 +053015550int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
15551 struct net_device *dev, u8 *peer)
15552{
Arif Hussaina7c8e412013-11-20 11:06:42 -080015553 hddLog(VOS_TRACE_LEVEL_INFO,
15554 "tdls send discover req: "MAC_ADDRESS_STR,
15555 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +053015556
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015557#if TDLS_MGMT_VERSION2
15558 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15559 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, NULL, 0);
15560#else
Chilam NG571c65a2013-01-19 12:27:36 +053015561 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
15562 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
Sunil Dutt Undekarieacac6f2014-03-21 14:08:53 +053015563#endif
Chilam NG571c65a2013-01-19 12:27:36 +053015564}
Mohit Khanna698ba2a2012-12-04 15:08:18 -080015565#endif
15566
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015567#ifdef WLAN_FEATURE_GTK_OFFLOAD
15568/*
15569 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
15570 * Callback rountine called upon receiving response for
15571 * get offload info
15572 */
15573void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
15574 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
15575{
15576
15577 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015578 tANI_U8 tempReplayCounter[8];
15579 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015580
15581 ENTER();
15582
15583 if (NULL == pAdapter)
15584 {
Agarwal Ashish971c2882013-10-30 20:11:12 +053015585 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015586 "%s: HDD adapter is Null", __func__);
15587 return ;
15588 }
15589
15590 if (NULL == pGtkOffloadGetInfoRsp)
15591 {
15592 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15593 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
15594 return ;
15595 }
15596
15597 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
15598 {
15599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15600 "%s: wlan Failed to get replay counter value",
15601 __func__);
15602 return ;
15603 }
15604
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015605 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15606 /* Update replay counter */
15607 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
15608 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15609
15610 {
15611 /* changing from little to big endian since supplicant
15612 * works on big endian format
15613 */
15614 int i;
15615 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
15616
15617 for (i = 0; i < 8; i++)
15618 {
15619 tempReplayCounter[7-i] = (tANI_U8)p[i];
15620 }
15621 }
15622
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015623 /* Update replay counter to NL */
15624 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015625 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015626}
15627
15628/*
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015629 * FUNCTION: __wlan_hdd_cfg80211_set_rekey_data
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015630 * This function is used to offload GTK rekeying job to the firmware.
15631 */
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015632int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015633 struct cfg80211_gtk_rekey_data *data)
15634{
15635 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15636 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
15637 hdd_station_ctx_t *pHddStaCtx;
15638 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015639 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015640 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015641 eHalStatus status = eHAL_STATUS_FAILURE;
15642
15643 ENTER();
15644
15645 if (NULL == pAdapter)
15646 {
Kaushik, Sushantb1ed0f42014-07-01 18:26:31 +053015647 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015648 "%s: HDD adapter is Null", __func__);
15649 return -ENODEV;
15650 }
15651
Sushant Kaushik4b7cb302014-01-06 17:45:01 +053015652 MTRACE(vos_trace(VOS_MODULE_ID_HDD,
15653 TRACE_CODE_HDD_CFG80211_SET_REKEY_DATA,
15654 pAdapter->sessionId, pAdapter->device_mode));
15655
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015656 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015657 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015658 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +053015659 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015660 }
15661
15662 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
15663 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
15664 if (NULL == hHal)
15665 {
15666 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15667 "%s: HAL context is Null!!!", __func__);
15668 return -EAGAIN;
15669 }
15670
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015671 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
15672 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
15673 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
15674 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015675 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015676 {
15677 /* changing from big to little endian since driver
15678 * works on little endian format
15679 */
15680 tANI_U8 *p =
15681 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
15682 int i;
15683
15684 for (i = 0; i < 8; i++)
15685 {
15686 p[7-i] = data->replay_ctr[i];
15687 }
15688 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015689
15690 if (TRUE == pHddCtx->hdd_wlan_suspended)
15691 {
15692 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015693 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
15694 sizeof (tSirGtkOffloadParams));
15695 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015696 pAdapter->sessionId);
15697
15698 if (eHAL_STATUS_SUCCESS != status)
15699 {
15700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15701 "%s: sme_SetGTKOffload failed, returned %d",
15702 __func__, status);
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015703
15704 /* Need to clear any trace of key value in the memory.
15705 * Thus zero out the memory even though it is local
15706 * variable.
15707 */
15708 vos_mem_zero(&hddGtkOffloadReqParams,
15709 sizeof(hddGtkOffloadReqParams));
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015710 return status;
15711 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015712 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15713 "%s: sme_SetGTKOffload successfull", __func__);
15714 }
15715 else
15716 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15718 "%s: wlan not suspended GTKOffload request is stored",
15719 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015720 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015721
Vinay Krishna Eranna6f22c1f2014-10-13 16:03:06 +053015722 /* Need to clear any trace of key value in the memory.
15723 * Thus zero out the memory even though it is local
15724 * variable.
15725 */
15726 vos_mem_zero(&hddGtkOffloadReqParams,
15727 sizeof(hddGtkOffloadReqParams));
15728
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015729 EXIT();
Gopichand Nakkalad36ee622013-05-07 14:13:27 +053015730 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015731}
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053015732
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015733int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
15734 struct cfg80211_gtk_rekey_data *data)
15735{
15736 int ret;
15737
15738 vos_ssr_protect(__func__);
15739 ret = __wlan_hdd_cfg80211_set_rekey_data(wiphy, dev, data);
15740 vos_ssr_unprotect(__func__);
15741
15742 return ret;
15743}
15744#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015745/*
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015746 * FUNCTION: __wlan_hdd_cfg80211_set_mac_acl
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015747 * This function is used to set access control policy
15748 */
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015749static int __wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15750 struct net_device *dev,
15751 const struct cfg80211_acl_data *params)
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015752{
15753 int i;
15754 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
15755 hdd_hostapd_state_t *pHostapdState;
15756 tsap_Config_t *pConfig;
15757 v_CONTEXT_t pVosContext = NULL;
15758 hdd_context_t *pHddCtx;
15759 int status;
15760
15761 ENTER();
15762
15763 if (NULL == pAdapter)
15764 {
15765 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15766 "%s: HDD adapter is Null", __func__);
15767 return -ENODEV;
15768 }
15769
15770 if (NULL == params)
15771 {
15772 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15773 "%s: params is Null", __func__);
15774 return -EINVAL;
15775 }
15776
15777 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
15778 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015779 if (0 != status)
15780 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015781 return status;
15782 }
15783
15784 pVosContext = pHddCtx->pvosContext;
15785 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
15786
15787 if (NULL == pHostapdState)
15788 {
15789 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
15790 "%s: pHostapdState is Null", __func__);
15791 return -EINVAL;
15792 }
15793
15794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
15795 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
15796
15797 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
15798 {
15799 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
15800
15801 /* default value */
15802 pConfig->num_accept_mac = 0;
15803 pConfig->num_deny_mac = 0;
15804
15805 /**
15806 * access control policy
15807 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
15808 * listed in hostapd.deny file.
15809 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
15810 * listed in hostapd.accept file.
15811 */
15812 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
15813 {
15814 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
15815 }
15816 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
15817 {
15818 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
15819 }
15820 else
15821 {
15822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15823 "%s:Acl Policy : %d is not supported",
15824 __func__, params->acl_policy);
15825 return -ENOTSUPP;
15826 }
15827
15828 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
15829 {
15830 pConfig->num_accept_mac = params->n_acl_entries;
15831 for (i = 0; i < params->n_acl_entries; i++)
15832 {
15833 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15834 "** Add ACL MAC entry %i in WhiletList :"
15835 MAC_ADDRESS_STR, i,
15836 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
15837
15838 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
15839 sizeof(qcmacaddr));
15840 }
15841 }
15842 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
15843 {
15844 pConfig->num_deny_mac = params->n_acl_entries;
15845 for (i = 0; i < params->n_acl_entries; i++)
15846 {
15847 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
15848 "** Add ACL MAC entry %i in BlackList :"
15849 MAC_ADDRESS_STR, i,
15850 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
15851
15852 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
15853 sizeof(qcmacaddr));
15854 }
15855 }
15856
15857 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
15858 {
15859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15860 "%s: SAP Set Mac Acl fail", __func__);
15861 return -EINVAL;
15862 }
15863 }
15864 else
15865 {
15866 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Sushant Kaushik8bc7df22014-04-09 17:55:29 +053015867 "%s: Invalid device_mode = %s (%d)",
15868 __func__, hdd_device_modetoString(pAdapter->device_mode),
15869 pAdapter->device_mode);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015870 return -EINVAL;
15871 }
15872
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015873 EXIT();
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053015874 return 0;
15875}
15876
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053015877static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
15878 struct net_device *dev,
15879 const struct cfg80211_acl_data *params)
15880{
15881 int ret;
15882 vos_ssr_protect(__func__);
15883 ret = __wlan_hdd_cfg80211_set_mac_acl(wiphy, dev, params);
15884 vos_ssr_unprotect(__func__);
15885
15886 return ret;
15887}
15888
Leo Chang9056f462013-08-01 19:21:11 -070015889#ifdef WLAN_NL80211_TESTMODE
15890#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -070015891void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -070015892(
15893 void *pAdapter,
15894 void *indCont
15895)
15896{
Leo Changd9df8aa2013-09-26 13:32:26 -070015897 tSirLPHBInd *lphbInd;
15898 struct sk_buff *skb;
c_hpothu73f35e62014-04-18 13:40:08 +053015899 hdd_context_t *pHddCtxt;
Leo Chang9056f462013-08-01 19:21:11 -070015900
15901 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070015902 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -070015903
c_hpothu73f35e62014-04-18 13:40:08 +053015904 if (pAdapter == NULL)
15905 {
15906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15907 "%s: pAdapter is NULL\n",__func__);
15908 return;
15909 }
15910
Leo Chang9056f462013-08-01 19:21:11 -070015911 if (NULL == indCont)
15912 {
15913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -070015914 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -070015915 return;
15916 }
15917
c_hpothu73f35e62014-04-18 13:40:08 +053015918 pHddCtxt = (hdd_context_t *)pAdapter;
Leo Changd9df8aa2013-09-26 13:32:26 -070015919 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -070015920 skb = cfg80211_testmode_alloc_event_skb(
c_hpothu73f35e62014-04-18 13:40:08 +053015921 pHddCtxt->wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -070015922 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -070015923 GFP_ATOMIC);
15924 if (!skb)
15925 {
15926 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15927 "LPHB timeout, NL buffer alloc fail");
15928 return;
15929 }
15930
Leo Changac3ba772013-10-07 09:47:04 -070015931 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -070015932 {
15933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15934 "WLAN_HDD_TM_ATTR_CMD put fail");
15935 goto nla_put_failure;
15936 }
Leo Changac3ba772013-10-07 09:47:04 -070015937 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -070015938 {
15939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15940 "WLAN_HDD_TM_ATTR_TYPE put fail");
15941 goto nla_put_failure;
15942 }
Leo Changac3ba772013-10-07 09:47:04 -070015943 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -070015944 sizeof(tSirLPHBInd), lphbInd))
15945 {
15946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15947 "WLAN_HDD_TM_ATTR_DATA put fail");
15948 goto nla_put_failure;
15949 }
Leo Chang9056f462013-08-01 19:21:11 -070015950 cfg80211_testmode_event(skb, GFP_ATOMIC);
15951 return;
15952
15953nla_put_failure:
15954 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15955 "NLA Put fail");
15956 kfree_skb(skb);
15957
15958 return;
15959}
15960#endif /* FEATURE_WLAN_LPHB */
15961
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053015962static int __wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
Leo Chang9056f462013-08-01 19:21:11 -070015963{
15964 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
15965 int err = 0;
15966#ifdef FEATURE_WLAN_LPHB
15967 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -070015968 eHalStatus smeStatus;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053015969
15970 ENTER();
15971
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053015972 err = wlan_hdd_validate_context(pHddCtx);
15973 if (0 != err)
15974 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053015975 return err;
15976 }
Leo Chang9056f462013-08-01 19:21:11 -070015977#endif /* FEATURE_WLAN_LPHB */
15978
15979 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
15980 if (err)
15981 {
15982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15983 "%s Testmode INV ATTR", __func__);
15984 return err;
15985 }
15986
15987 if (!tb[WLAN_HDD_TM_ATTR_CMD])
15988 {
15989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
15990 "%s Testmode INV CMD", __func__);
15991 return -EINVAL;
15992 }
15993
15994 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
15995 {
15996#ifdef FEATURE_WLAN_LPHB
15997 /* Low Power Heartbeat configuration request */
15998 case WLAN_HDD_TM_CMD_WLAN_HB:
15999 {
16000 int buf_len;
16001 void *buf;
16002 tSirLPHBReq *hb_params = NULL;
Amar Singhal05852702014-02-04 14:40:00 -080016003 tSirLPHBReq *hb_params_temp = NULL;
Leo Chang9056f462013-08-01 19:21:11 -070016004
16005 if (!tb[WLAN_HDD_TM_ATTR_DATA])
16006 {
16007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16008 "%s Testmode INV DATA", __func__);
16009 return -EINVAL;
16010 }
16011
16012 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
16013 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
Amar Singhal05852702014-02-04 14:40:00 -080016014
16015 hb_params_temp =(tSirLPHBReq *)buf;
16016 if ((hb_params_temp->cmd == LPHB_SET_TCP_PARAMS_INDID) &&
16017 (hb_params_temp->params.lphbTcpParamReq.timePeriodSec == 0))
16018 return -EINVAL;
16019
Leo Chang9056f462013-08-01 19:21:11 -070016020 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
16021 if (NULL == hb_params)
16022 {
16023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16024 "%s Request Buffer Alloc Fail", __func__);
16025 return -EINVAL;
16026 }
16027
16028 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -070016029 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
16030 hb_params,
16031 wlan_hdd_cfg80211_lphb_ind_handler);
16032 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -070016033 {
Leo Changd9df8aa2013-09-26 13:32:26 -070016034 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16035 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -070016036 vos_mem_free(hb_params);
16037 }
Leo Chang9056f462013-08-01 19:21:11 -070016038 return 0;
16039 }
16040#endif /* FEATURE_WLAN_LPHB */
16041 default:
c_hpothu6ff1c3c2013-10-01 19:01:57 +053016042 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
16043 "%s: unsupported event",__func__);
Leo Chang9056f462013-08-01 19:21:11 -070016044 return -EOPNOTSUPP;
16045 }
16046
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016047 EXIT();
16048 return err;
Leo Chang9056f462013-08-01 19:21:11 -070016049}
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016050
16051static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
16052{
16053 int ret;
16054
16055 vos_ssr_protect(__func__);
16056 ret = __wlan_hdd_cfg80211_testmode(wiphy, data, len);
16057 vos_ssr_unprotect(__func__);
16058
16059 return ret;
16060}
Leo Chang9056f462013-08-01 19:21:11 -070016061#endif /* CONFIG_NL80211_TESTMODE */
16062
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016063static int __wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016064 struct net_device *dev,
16065 int idx, struct survey_info *survey)
16066{
16067 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
16068 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +053016069 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016070 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +053016071 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016072 v_S7_t snr,rssi;
16073 int status, i, j, filled = 0;
16074
16075 ENTER();
16076
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016077 if (NULL == pAdapter)
16078 {
16079 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16080 "%s: HDD adapter is Null", __func__);
16081 return -ENODEV;
16082 }
16083
16084 if (NULL == wiphy)
16085 {
16086 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
16087 "%s: wiphy is Null", __func__);
16088 return -ENODEV;
16089 }
16090
16091 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
16092 status = wlan_hdd_validate_context(pHddCtx);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016093 if (0 != status)
16094 {
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016095 return status;
16096 }
16097
Mihir Sheted9072e02013-08-21 17:02:29 +053016098 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
16099
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016100 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +053016101 0 != pAdapter->survey_idx ||
16102 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016103 {
16104 /* The survey dump ops when implemented completely is expected to
16105 * return a survey of all channels and the ops is called by the
16106 * kernel with incremental values of the argument 'idx' till it
16107 * returns -ENONET. But we can only support the survey for the
16108 * operating channel for now. survey_idx is used to track
16109 * that the ops is called only once and then return -ENONET for
16110 * the next iteration
16111 */
16112 pAdapter->survey_idx = 0;
16113 return -ENONET;
16114 }
16115
16116 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
16117
16118 wlan_hdd_get_snr(pAdapter, &snr);
16119 wlan_hdd_get_rssi(pAdapter, &rssi);
16120
16121 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
16122 hdd_wlan_get_freq(channel, &freq);
16123
16124
16125 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
16126 {
16127 if (NULL == wiphy->bands[i])
16128 {
16129 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
16130 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
16131 continue;
16132 }
16133
16134 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
16135 {
16136 struct ieee80211_supported_band *band = wiphy->bands[i];
16137
16138 if (band->channels[j].center_freq == (v_U16_t)freq)
16139 {
16140 survey->channel = &band->channels[j];
16141 /* The Rx BDs contain SNR values in dB for the received frames
16142 * while the supplicant expects noise. So we calculate and
16143 * return the value of noise (dBm)
16144 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
16145 */
16146 survey->noise = rssi - snr;
16147 survey->filled = SURVEY_INFO_NOISE_DBM;
16148 filled = 1;
16149 }
16150 }
16151 }
16152
16153 if (filled)
16154 pAdapter->survey_idx = 1;
16155 else
16156 {
16157 pAdapter->survey_idx = 0;
16158 return -ENONET;
16159 }
16160
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016161 EXIT();
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016162 return 0;
16163}
16164
Mahesh A Saptasagar27574072014-06-17 13:39:04 +053016165static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
16166 struct net_device *dev,
16167 int idx, struct survey_info *survey)
16168{
16169 int ret;
16170
16171 vos_ssr_protect(__func__);
16172 ret = __wlan_hdd_cfg80211_dump_survey(wiphy, dev, idx, survey);
16173 vos_ssr_unprotect(__func__);
16174
16175 return ret;
16176}
16177
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016178/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016179 * FUNCTION: __wlan_hdd_cfg80211_resume_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016180 * this is called when cfg80211 driver resume
16181 * driver updates latest sched_scan scan result(if any) to cfg80211 database
16182 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016183int __wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016184{
16185 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
16186 hdd_adapter_t *pAdapter;
16187 hdd_adapter_list_node_t *pAdapterNode, *pNext;
16188 VOS_STATUS status = VOS_STATUS_SUCCESS;
16189
16190 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016191
Mahesh A Saptasagar74088392015-02-05 17:22:09 +053016192 if (0 != wlan_hdd_validate_context(pHddCtx))
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016193 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016194 return 0;
16195 }
16196
16197 spin_lock(&pHddCtx->schedScan_lock);
16198 pHddCtx->isWiphySuspended = FALSE;
16199 if (TRUE != pHddCtx->isSchedScanUpdatePending)
16200 {
16201 spin_unlock(&pHddCtx->schedScan_lock);
16202 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16203 "%s: Return resume is not due to PNO indication", __func__);
16204 return 0;
16205 }
16206 // Reset flag to avoid updatating cfg80211 data old results again
16207 pHddCtx->isSchedScanUpdatePending = FALSE;
16208 spin_unlock(&pHddCtx->schedScan_lock);
16209
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016210
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016211 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
16212
16213 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
16214 {
16215 pAdapter = pAdapterNode->pAdapter;
16216 if ( (NULL != pAdapter) &&
16217 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
16218 {
16219 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016220 {
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
16222 "%s: NO SCAN result", __func__);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016223 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016224 else
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016225 {
16226 /* Acquire wakelock to handle the case where APP's tries to
16227 * suspend immediately after updating the scan results. Whis
16228 * results in app's is in suspended state and not able to
16229 * process the connect request to AP
16230 */
16231 hdd_prevent_suspend_timeout(2000);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016232 cfg80211_sched_scan_results(pHddCtx->wiphy);
Mahesh A Saptasagarb9c50402014-01-16 15:49:22 +053016233 }
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016234
16235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16236 "%s : cfg80211 scan result database updated", __func__);
16237
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016238 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016239 return 0;
16240
16241 }
16242 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
16243 pAdapterNode = pNext;
16244 }
16245
16246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
16247 "%s: Failed to find Adapter", __func__);
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016248 EXIT();
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016249 return 0;
16250}
16251
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016252int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
16253{
16254 int ret;
16255
16256 vos_ssr_protect(__func__);
16257 ret = __wlan_hdd_cfg80211_resume_wlan(wiphy);
16258 vos_ssr_unprotect(__func__);
16259
16260 return ret;
16261}
16262
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016263/*
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016264 * FUNCTION: __wlan_hdd_cfg80211_suspend_wlan
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016265 * this is called when cfg80211 driver suspends
16266 */
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016267int __wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016268 struct cfg80211_wowlan *wow)
16269{
16270 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016271 int ret = 0;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016272
16273 ENTER();
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +053016274
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016275 ret = wlan_hdd_validate_context(pHddCtx);
16276 if (0 != ret)
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016277 {
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016278 return ret;
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016279 }
16280
Masti, Narayanraddic80e2bf2015-01-27 16:39:00 +053016281
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016282 pHddCtx->isWiphySuspended = TRUE;
16283
16284 EXIT();
16285
16286 return 0;
16287}
16288
Mahesh A Saptasagarbcc5b662014-06-02 21:46:23 +053016289int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
16290 struct cfg80211_wowlan *wow)
16291{
16292 int ret;
16293
16294 vos_ssr_protect(__func__);
16295 ret = __wlan_hdd_cfg80211_suspend_wlan(wiphy, wow);
16296 vos_ssr_unprotect(__func__);
16297
16298 return ret;
16299}
Jeff Johnson295189b2012-06-20 16:38:30 -070016300/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +053016301static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -070016302{
16303 .add_virtual_intf = wlan_hdd_add_virtual_intf,
16304 .del_virtual_intf = wlan_hdd_del_virtual_intf,
16305 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
16306 .change_station = wlan_hdd_change_station,
16307#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
16308 .add_beacon = wlan_hdd_cfg80211_add_beacon,
16309 .del_beacon = wlan_hdd_cfg80211_del_beacon,
16310 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016311#else
16312 .start_ap = wlan_hdd_cfg80211_start_ap,
16313 .change_beacon = wlan_hdd_cfg80211_change_beacon,
16314 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -070016315#endif
16316 .change_bss = wlan_hdd_cfg80211_change_bss,
16317 .add_key = wlan_hdd_cfg80211_add_key,
16318 .get_key = wlan_hdd_cfg80211_get_key,
16319 .del_key = wlan_hdd_cfg80211_del_key,
16320 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016321#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -070016322 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -080016323#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016324 .scan = wlan_hdd_cfg80211_scan,
16325 .connect = wlan_hdd_cfg80211_connect,
16326 .disconnect = wlan_hdd_cfg80211_disconnect,
16327 .join_ibss = wlan_hdd_cfg80211_join_ibss,
16328 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
16329 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
16330 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
16331 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -070016332 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
16333 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
DARAM SUDHA39eede62014-02-12 11:16:40 +053016334 .mgmt_tx = wlan_hdd_mgmt_tx,
Jeff Johnson295189b2012-06-20 16:38:30 -070016335#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
16336 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
16337 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
16338 .set_txq_params = wlan_hdd_set_txq_params,
16339#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016340 .get_station = wlan_hdd_cfg80211_get_station,
16341 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
16342 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016343 .add_station = wlan_hdd_cfg80211_add_station,
16344#ifdef FEATURE_WLAN_LFR
16345 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
16346 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
16347 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
16348#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -070016349#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
16350 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
16351#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016352#ifdef FEATURE_WLAN_TDLS
16353 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
16354 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
16355#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +053016356#ifdef WLAN_FEATURE_GTK_OFFLOAD
16357 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
16358#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +053016359#ifdef FEATURE_WLAN_SCAN_PNO
16360 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
16361 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
16362#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +053016363 .resume = wlan_hdd_cfg80211_resume_wlan,
16364 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +053016365 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -070016366#ifdef WLAN_NL80211_TESTMODE
16367 .testmode_cmd = wlan_hdd_cfg80211_testmode,
16368#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016369 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -070016370};
16371